diff --git a/.travis.yml b/.travis.yml index 825aa21..37e59b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,8 @@ php: - 5.3 - 5.4 - 5.5 + - 5.6 before_script: - - "mkdir -p ~/.composer" - - cp src/test/resources/travis-composer-config.json ~/.composer/config.json - wget https://raw.github.com/ehough/throwback/develop/src/main/bash/travis-setup.sh - chmod a+x travis-setup.sh - ./travis-setup.sh diff --git a/src/main/php/ehough/pulsar/ApcClassLoader.php b/src/main/php/ehough/pulsar/ApcClassLoader.php index c84b9a6..078b87d 100644 --- a/src/main/php/ehough/pulsar/ApcClassLoader.php +++ b/src/main/php/ehough/pulsar/ApcClassLoader.php @@ -77,7 +77,7 @@ public function __construct($prefix, $decorated) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -106,7 +106,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/src/main/php/ehough/pulsar/ClassCollectionLoader.php b/src/main/php/ehough/pulsar/ClassCollectionLoader.php index 4d41876..5130969 100644 --- a/src/main/php/ehough/pulsar/ClassCollectionLoader.php +++ b/src/main/php/ehough/pulsar/ClassCollectionLoader.php @@ -26,8 +26,8 @@ class ehough_pulsar_ClassCollectionLoader * @param array $classes An array of classes to load * @param string $cacheDir A cache directory * @param string $name The cache name prefix - * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not - * @param Boolean $adaptive Whether to remove already declared classes or not + * @param bool $autoReload Whether to flush the cache when the cache is stale or not + * @param bool $adaptive Whether to remove already declared classes or not * @param string $extension File extension of the resulting file * * @throws InvalidArgumentException When class can't be loaded @@ -198,7 +198,7 @@ public static function fixNamespaceDeclarations($source) */ public static function enableTokenizer($bool) { - self::$useTokenizer = (Boolean) $bool; + self::$useTokenizer = (bool) $bool; } /** diff --git a/src/main/php/ehough/pulsar/ClassLoader.php b/src/main/php/ehough/pulsar/ClassLoader.php index 5b9d5e6..097c2fd 100644 --- a/src/main/php/ehough/pulsar/ClassLoader.php +++ b/src/main/php/ehough/pulsar/ClassLoader.php @@ -101,7 +101,7 @@ public function addPrefix($prefix, $paths) /** * Turns on searching the include for class files. * - * @param Boolean $useIncludePath + * @param bool $useIncludePath */ public function setUseIncludePath($useIncludePath) { @@ -112,7 +112,7 @@ public function setUseIncludePath($useIncludePath) * Can be used to check if the autoloader uses the include path to check * for classes. * - * @return Boolean + * @return bool */ public function getUseIncludePath() { @@ -122,7 +122,7 @@ public function getUseIncludePath() /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -142,7 +142,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/src/main/php/ehough/pulsar/DebugClassLoader.php b/src/main/php/ehough/pulsar/DebugClassLoader.php index 50c0607..08fd90e 100644 --- a/src/main/php/ehough/pulsar/DebugClassLoader.php +++ b/src/main/php/ehough/pulsar/DebugClassLoader.php @@ -96,7 +96,7 @@ public function findFile($class) * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded * * @throws \RuntimeException */ diff --git a/src/main/php/ehough/pulsar/DebugUniversalClassLoader.php b/src/main/php/ehough/pulsar/DebugUniversalClassLoader.php index 2248e9d..06ac73c 100644 --- a/src/main/php/ehough/pulsar/DebugUniversalClassLoader.php +++ b/src/main/php/ehough/pulsar/DebugUniversalClassLoader.php @@ -46,7 +46,7 @@ public static function enable() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClass($class) { diff --git a/src/main/php/ehough/pulsar/MapClassLoader.php b/src/main/php/ehough/pulsar/MapClassLoader.php index e4effa7..ed4078e 100644 --- a/src/main/php/ehough/pulsar/MapClassLoader.php +++ b/src/main/php/ehough/pulsar/MapClassLoader.php @@ -31,7 +31,7 @@ public function __construct(array $map) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { diff --git a/src/main/php/ehough/pulsar/Psr4ClassLoader.php b/src/main/php/ehough/pulsar/Psr4ClassLoader.php index f230bd5..3b2470b 100644 --- a/src/main/php/ehough/pulsar/Psr4ClassLoader.php +++ b/src/main/php/ehough/pulsar/Psr4ClassLoader.php @@ -58,7 +58,7 @@ public function findFile($class) /** * @param string $class * - * @return Boolean + * @return bool */ public function loadClass($class) { @@ -75,7 +75,7 @@ public function loadClass($class) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend + * @param bool $prepend */ public function register($prepend = false) { diff --git a/src/main/php/ehough/pulsar/UniversalClassLoader.php b/src/main/php/ehough/pulsar/UniversalClassLoader.php index 02932d8..fa1bf05 100644 --- a/src/main/php/ehough/pulsar/UniversalClassLoader.php +++ b/src/main/php/ehough/pulsar/UniversalClassLoader.php @@ -68,7 +68,7 @@ class ehough_pulsar_UniversalClassLoader * Turns on searching the include for class files. Allows easy loading * of installed PEAR packages * - * @param Boolean $useIncludePath + * @param bool $useIncludePath */ public function useIncludePath($useIncludePath) { @@ -79,7 +79,7 @@ public function useIncludePath($useIncludePath) * Can be used to check if the autoloader uses the include path to check * for classes. * - * @return Boolean + * @return bool */ public function getUseIncludePath() { @@ -227,7 +227,7 @@ public function registerPrefix($prefix, $paths) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not * * @api */ @@ -250,7 +250,7 @@ public function register($prepend = false) * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/src/main/php/ehough/pulsar/WinCacheClassLoader.php b/src/main/php/ehough/pulsar/WinCacheClassLoader.php index 6ce4378..cff466f 100644 --- a/src/main/php/ehough/pulsar/WinCacheClassLoader.php +++ b/src/main/php/ehough/pulsar/WinCacheClassLoader.php @@ -74,7 +74,7 @@ public function __construct($prefix, $decorated) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -94,7 +94,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/src/main/php/ehough/pulsar/XcacheClassLoader.php b/src/main/php/ehough/pulsar/XcacheClassLoader.php index 7026af5..96b5a63 100644 --- a/src/main/php/ehough/pulsar/XcacheClassLoader.php +++ b/src/main/php/ehough/pulsar/XcacheClassLoader.php @@ -71,7 +71,7 @@ public function __construct($prefix, $classFinder) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -100,7 +100,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/src/test/php/ehough/pulsar/ClassCollectionLoaderTest.php b/src/test/php/ehough/pulsar/ClassCollectionLoaderTest.php index 9d54e03..0f8a419 100644 --- a/src/test/php/ehough/pulsar/ClassCollectionLoaderTest.php +++ b/src/test/php/ehough/pulsar/ClassCollectionLoaderTest.php @@ -9,13 +9,24 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/GInterface.php'; -require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/CInterface.php'; -require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/B.php'; -require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/A.php'; +if (version_compare(phpversion(), '5.3') >= 0) { + require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/GInterface.php'; + require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/CInterface.php'; + require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/B.php'; + require_once dirname(__FILE__).'/../../../resources/Fixtures/ClassesWithParents/A.php'; +} class ehough_pulsar_ClassCollectionLoaderTest extends PHPUnit_Framework_TestCase { + public function setup() + { + if (version_compare(phpversion(), '5.3', '<')) { + $this->markTestSkipped('Requires PHP > 5.3'); + + return; + } + } + public function testTraitDependencies() { if (version_compare(phpversion(), '5.4', '<')) { @@ -26,7 +37,7 @@ public function testTraitDependencies() require_once dirname(__FILE__).'/../../../resources/Fixtures/deps/traits.php'; - $r = new \ReflectionClass('ehough_pulsar_ClassCollectionLoader'); + $r = new ReflectionClass('ehough_pulsar_ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); @@ -34,14 +45,14 @@ public function testTraitDependencies() $this->assertEquals( array('TD', 'TC', 'TB', 'TA', 'TZ', 'CTFoo'), - array_map(function ($class) { return $class->getName(); }, $ordered) + array_map(array($this, '__callbackGetClassName'), $ordered) ); $ordered = $m->invoke('ehough_pulsar_ClassCollectionLoader', array('CTBar')); $this->assertEquals( array('TD', 'TZ', 'TC', 'TB', 'TA', 'CTBar'), - array_map(function ($class) { return $class->getName(); }, $ordered) + array_map(array($this, '__callbackGetClassName'), $ordered) ); } @@ -50,6 +61,12 @@ public function testTraitDependencies() */ public function testClassReordering(array $classes) { + if (version_compare(phpversion(), '5.3', '<')) { + $this->markTestSkipped('Requires PHP > 5.3'); + + return; + } + $expected = array( 'ClassesWithParents\\GInterface', 'ClassesWithParents\\CInterface', @@ -57,13 +74,18 @@ public function testClassReordering(array $classes) 'ClassesWithParents\\A', ); - $r = new \ReflectionClass('ehough_pulsar_ClassCollectionLoader'); + $r = new ReflectionClass('ehough_pulsar_ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); $ordered = $m->invoke('ehough_pulsar_ClassCollectionLoader', $classes); - $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); + $this->assertEquals($expected, array_map(array($this, '__callbackGetClassName'), $ordered)); + } + + public function __callbackGetClassName($class) + { + return $class->getName(); } public function getDifferentOrders() @@ -120,13 +142,13 @@ public function testClassWithTraitsReordering(array $classes) 'ClassesWithParents\\E', ); - $r = new \ReflectionClass('ehough_pulsar_ClassCollectionLoader'); + $r = new ReflectionClass('ehough_pulsar_ClassCollectionLoader'); $m = $r->getMethod('getOrderedClasses'); $m->setAccessible(true); $ordered = $m->invoke('ehough_pulsar_ClassCollectionLoader', $classes); - $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); + $this->assertEquals($expected, array_map(array($this, '__callbackGetClassName'), $ordered)); } public function getDifferentOrdersForTraits() @@ -201,11 +223,7 @@ public function testCommentStripping() if (is_file($file = sys_get_temp_dir().'/bar.php')) { unlink($file); } - spl_autoload_register($r = function ($class) { - if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) { - require_once dirname(__FILE__).'/../../../resources/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.php'; - } - }); + spl_autoload_register($r = array($this, '__callback_testCommentStripping')); ehough_pulsar_ClassCollectionLoader::load( array('Namespaced\\WithComments', 'Pearlike_WithComments'), @@ -253,4 +271,11 @@ class Pearlike_WithComments unlink($file); } + + public function __callback_testCommentStripping($class) + { + if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) { + require_once dirname(__FILE__).'/../../../resources/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.php'; + } + } } diff --git a/src/test/php/ehough/pulsar/ClassMapGeneratorTest.php b/src/test/php/ehough/pulsar/ClassMapGeneratorTest.php index 7103853..4d405e3 100644 --- a/src/test/php/ehough/pulsar/ClassMapGeneratorTest.php +++ b/src/test/php/ehough/pulsar/ClassMapGeneratorTest.php @@ -16,6 +16,14 @@ class ehough_pulsar_ClassMapGeneratorTest extends PHPUnit_Framework_TestCase */ private $workspace = null; + public function setup() + { + if (version_compare(PHP_VERSION, '5.3') < 0) { + + $this->markTestSkipped('PHP 5.2'); + } + } + public function prepare_workspace() { $this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000); @@ -29,7 +37,7 @@ public function prepare_workspace() private function clean($file) { if (is_dir($file) && !is_link($file)) { - $dir = new \FilesystemIterator($file); + $dir = new FilesystemIterator($file); foreach ($dir as $childFile) { $this->clean($childFile); } @@ -120,7 +128,8 @@ public function testCreateMapFinderSupport() $this->markTestSkipped('Finder component is not available'); } - $finder = new \Symfony\Component\Finder\Finder(); + $ref = new ReflectionClass('Symfony\\Component\\Finder\\Finder'); + $finder = $ref->newInstance(); $finder->files()->in(dirname(__FILE__) . '/../../../resources/Fixtures/beta/NamespaceCollision'); $this->assertEqualsNormalized(array( diff --git a/src/test/resources/travis-composer-config.json b/src/test/resources/travis-composer-config.json deleted file mode 100644 index 135617e..0000000 --- a/src/test/resources/travis-composer-config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "config": { - "github-oauth": { - "github.com" : "636a870289082d5f5d70d7ebce004d70cce3a278" - } - } -} \ No newline at end of file