Pluf Framework

Review 10: Pluf::loadClass

Created:2011-04-07 09:35:29 (2 years 1 month ago)
Updated:1 year 11 months ago
Author:William Martin
Commit:7d1e4b9ea5eb32cb93d709d383d62aab831f1272
Description:Pluf::loadClass

This method don't check if an interface is loaded. It's break indefero phpunit, which try to load the interface in the file : - src/IDF/Scm/Monotone/IStdio.php
Reviewers:Thomas Keller, Thomas Riché,
Files: b/src/Pluf.php (1 diff, 2 comments)
 Archive Download the corresponding diff file
b/src/Pluf.php
OldNew
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
}
$file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
include $file;
if (!class_exists($class, false)) {
$error = 'Impossible to load the class: '.$class."\n".
'Tried to include: '.$file."\n".
'Include path: '.get_include_path();
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
}
$file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
include $file;
if (!class_exists($class, false) && !interface_exists($class, false)) {
$error = 'Impossible to load the class: '.$class."\n".
'Tried to include: '.$file."\n".
'Include path: '.get_include_path();

Comment 1 by Thomas Keller, Apr 7, 2011

I'm fine with that, the $error could however be improved to say 
"Impossible to load the class / interface: ".

Comment 2 by Thomas Riché, Jun 14, 2011

Perfect

General Comments

Comment 1 by Thomas Keller, Apr 7, 2011

Looks fine.
Status: Accepted

Comment 2 by Thomas Riché, Jun 14, 2011

Indeed !!!

I was trying to integrate PHPExcel to an existing app.
I saw that this lib is using the same duck typing conventions as we 
do in Pluf...

however, i ran into class loading errors.
I then remember reading about this revue.

YOU SAVED MY DAY !!!

Thanks