Changeset 1372

Show
Ignore:
Timestamp:
02/26/08 00:53:35 (3 months ago)
Author:
mikey
Message:

implemented refactoring #121: remove suppot for dots as package separator

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/stubClassLoader.php

    r1301 r1372  
    8787     * <code> 
    8888     * net::stubbles::stubClassNotFoundException { 
    89      *     message(string): The class example.Foo loaded in bar.php on line 6 was not found. 
    90      *     classname(string): example.Foo 
     89     *     message(string): The class example::Foo loaded in bar.php on line 6 was not found. 
     90     *     classname(string): example::Foo 
    9191     *     file(string): stubClassLoader.php 
    9292     *     line(integer): 179 
     
    166166     * method to load files from source path 
    167167     * 
    168      * Usage: stubblesClassLoader::load('path.to.Classfile'); 
     168     * Usage: stubblesClassLoader::load('path::to::Classfile'); 
    169169     * 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' 
    172172     * ); 
    173173     * You may name as many files as you like, there is no restriction 
     
    190190        foreach ($classNames as $fqClassName) { 
    191191            $nqClassName = self::getNonQualifiedClassName($fqClassName); 
    192             // backward compatibility for dot as package separator 
    193             $fqClassName = str_replace('.', '::', $fqClassName); 
    194192            if (isset(self::$classNames[$nqClassName]) === true) { 
    195193                continue; 
     
    234232        } 
    235233 
    236         $dirName = self::$sourcePath . str_replace('.', DIRECTORY_SEPARATOR, str_replace('::', DIRECTORY_SEPARATOR, $packageName)); 
     234        $dirName = self::$sourcePath . str_replace('::', DIRECTORY_SEPARATOR, $packageName); 
    237235        if (file_exists($dirName) == false) { 
    238236            return array(); 
     
    282280    public static function getNonQualifiedClassName($fqClassName) 
    283281    { 
    284         if (strstr($fqClassName, '.') === false) { 
    285             $classNameParts = explode('::', $fqClassName); 
    286         } else { 
    287             $classNameParts = explode('.', $fqClassName); 
    288         } 
    289          
     282        $classNameParts = explode('::', $fqClassName); 
    290283        return $classNameParts[count($classNameParts) - 1]; 
    291284    } 
  • trunk/src/test/php/net/stubbles/stubClassLoaderTestCase.php

    r1267 r1372  
    5757        } catch (stubClassNotFoundException $cnfe) { 
    5858            $this->assertEquals('org::stubbles::test::DoesNotExist', $cnfe->getNotFoundClassName()); 
    59             /*$this->assertEquals("net::stubbles::stubClassNotFoundException {\n" 
     59            $this->assertEquals("net::stubbles::stubClassNotFoundException {\n" 
    6060                              . '    message(string): The class org::stubbles::test::DoesNotExist loaded in ' . __FILE__ . ' on line ' . (__LINE__ - 4) . " was not found.\n" 
    6161                              . "    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" 
    6464                              . '    code(integer): ' . 0 . "\n}\n", 
    65                                 (string) $cnfe);*/ 
     65                                (string) $cnfe); 
    6666            return; 
    6767        } 
     
    6969        $this->fail('Expected stubClassNotFoundException, got nothing or another exception.'); 
    7070    } 
     71 
     72    /** 
     73     * loading nothing does not do any harm 
     74     * 
     75     * @test 
     76     */ 
     77    public function loadNothing() 
     78    { 
     79        stubClassLoader::load(); 
     80    } 
    7181} 
    7282?>