Changeset 1372
- Timestamp:
- 02/26/08 00:53:35 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/stubClassLoader.php
r1301 r1372 87 87 * <code> 88 88 * net::stubbles::stubClassNotFoundException { 89 * message(string): The class example .Foo loaded in bar.php on line 6 was not found.90 * classname(string): example .Foo89 * message(string): The class example::Foo loaded in bar.php on line 6 was not found. 90 * classname(string): example::Foo 91 91 * file(string): stubClassLoader.php 92 92 * line(integer): 179 … … 166 166 * method to load files from source path 167 167 * 168 * Usage: stubblesClassLoader::load('path .to.Classfile');168 * Usage: stubblesClassLoader::load('path::to::Classfile'); 169 169 * or load more than one at once: 170 * stubblesClassLoader::load('path .to.first.Class',171 * 'path .to.second.Class'170 * stubblesClassLoader::load('path::to::first::Class', 171 * 'path::to::second.Class' 172 172 * ); 173 173 * You may name as many files as you like, there is no restriction … … 190 190 foreach ($classNames as $fqClassName) { 191 191 $nqClassName = self::getNonQualifiedClassName($fqClassName); 192 // backward compatibility for dot as package separator193 $fqClassName = str_replace('.', '::', $fqClassName);194 192 if (isset(self::$classNames[$nqClassName]) === true) { 195 193 continue; … … 234 232 } 235 233 236 $dirName = self::$sourcePath . str_replace(' .', DIRECTORY_SEPARATOR, str_replace('::', DIRECTORY_SEPARATOR, $packageName));234 $dirName = self::$sourcePath . str_replace('::', DIRECTORY_SEPARATOR, $packageName); 237 235 if (file_exists($dirName) == false) { 238 236 return array(); … … 282 280 public static function getNonQualifiedClassName($fqClassName) 283 281 { 284 if (strstr($fqClassName, '.') === false) { 285 $classNameParts = explode('::', $fqClassName); 286 } else { 287 $classNameParts = explode('.', $fqClassName); 288 } 289 282 $classNameParts = explode('::', $fqClassName); 290 283 return $classNameParts[count($classNameParts) - 1]; 291 284 } trunk/src/test/php/net/stubbles/stubClassLoaderTestCase.php
r1267 r1372 57 57 } catch (stubClassNotFoundException $cnfe) { 58 58 $this->assertEquals('org::stubbles::test::DoesNotExist', $cnfe->getNotFoundClassName()); 59 /*$this->assertEquals("net::stubbles::stubClassNotFoundException {\n"59 $this->assertEquals("net::stubbles::stubClassNotFoundException {\n" 60 60 . ' message(string): The class org::stubbles::test::DoesNotExist loaded in ' . __FILE__ . ' on line ' . (__LINE__ - 4) . " was not found.\n" 61 61 . " classname(string): org::stubbles::test::DoesNotExist\n" 62 . ' file(string): ' . __FILE__. "\n"63 . ' line(integer): ' . (__LINE__ - 7) . "\n"62 . ' file(string): ' . $cnfe->getFile() . "\n" 63 . ' line(integer): ' . $cnfe->getLine() . "\n" 64 64 . ' code(integer): ' . 0 . "\n}\n", 65 (string) $cnfe); */65 (string) $cnfe); 66 66 return; 67 67 } … … 69 69 $this->fail('Expected stubClassNotFoundException, got nothing or another exception.'); 70 70 } 71 72 /** 73 * loading nothing does not do any harm 74 * 75 * @test 76 */ 77 public function loadNothing() 78 { 79 stubClassLoader::load(); 80 } 71 81 } 72 82 ?>
