Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Koopzington committed Nov 20, 2016
1 parent be600e7 commit 9db2d13
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
9 changes: 9 additions & 0 deletions phpcs.xml
Expand Up @@ -2,6 +2,15 @@
<ruleset name="Zend Framework coding standard">
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>/src/Exception/*</exclude-pattern>
<exclude-pattern>/src/SplAutoloader.php</exclude-pattern>
<exclude-pattern>/src/AutoloaderFactory.php</exclude-pattern>
<exclude-pattern>/src/ClassMapAutoloader.php</exclude-pattern>
<exclude-pattern>/src/ModuleAutoloader.php</exclude-pattern>
<exclude-pattern>/src/StandardAutoloader.php</exclude-pattern>
</rule>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
Expand Down
5 changes: 4 additions & 1 deletion src/StandardAutoloader.php
Expand Up @@ -89,7 +89,10 @@ public function setOptions($options)
case self::AUTOREGISTER_ZF:
if ($pairs) {
$this->registerNamespace('Zend', dirname(__DIR__));
$this->registerNamespace('ZendXml', dirname(dirname((__DIR__))) . DIRECTORY_SEPARATOR . 'ZendXml');
$this->registerNamespace(
'ZendXml',
dirname(dirname((__DIR__))) . DIRECTORY_SEPARATOR . 'ZendXml'
);
}
break;
case self::LOAD_NS:
Expand Down
17 changes: 16 additions & 1 deletion test/ClassMapAutoloaderTest.php
Expand Up @@ -67,7 +67,9 @@ public function testValidMapFileNotReturningMapRaisesInvalidArgumentException()
public function testAllowsRegisteringArrayAutoloadMapDirectly()
{
$map = [
// @codingStandardsIgnoreStart
'Zend\Loader\Exception\ExceptionInterface' => __DIR__ . '/../../../library/Zend/Loader/Exception/ExceptionInterface.php',
// @codingStandardsIgnoreEnd
];
$this->loader->registerAutoloadMap($map);
$test = $this->loader->getAutoloadMap();
Expand All @@ -77,7 +79,9 @@ public function testAllowsRegisteringArrayAutoloadMapDirectly()
public function testAllowsRegisteringArrayAutoloadMapViaConstructor()
{
$map = [
// @codingStandardsIgnoreStart
'Zend\Loader\Exception\ExceptionInterface' => __DIR__ . '/../../../library/Zend/Loader/Exception/ExceptionInterface.php',
// @codingStandardsIgnoreEnd
];
$loader = new ClassMapAutoloader([$map]);
$test = $loader->getAutoloadMap();
Expand All @@ -101,7 +105,9 @@ public function testRegisteringValidMapFilePopulatesAutoloader()
public function testRegisteringMultipleMapsMergesThem()
{
$map = [
// @codingStandardsIgnoreStart
'Zend\Loader\Exception\ExceptionInterface' => __DIR__ . '/../../../library/Zend/Loader/Exception/ExceptionInterface.php',
// @codingStandardsIgnoreEnd
'ZendTest\Loader\StandardAutoloaderTest' => 'some/bogus/path.php',
];
$this->loader->registerAutoloadMap($map);
Expand All @@ -110,13 +116,18 @@ public function testRegisteringMultipleMapsMergesThem()
$test = $this->loader->getAutoloadMap();
$this->assertInternalType('array', $test);
$this->assertEquals(3, count($test));
$this->assertNotEquals($map['ZendTest\Loader\StandardAutoloaderTest'], $test['ZendTest\Loader\StandardAutoloaderTest']);
$this->assertNotEquals(
$map['ZendTest\Loader\StandardAutoloaderTest'],
$test['ZendTest\Loader\StandardAutoloaderTest']
);
}

public function testCanRegisterMultipleMapsAtOnce()
{
$map = [
// @codingStandardsIgnoreStart
'Zend\Loader\Exception\ExceptionInterface' => __DIR__ . '/../../../library/Zend/Loader/Exception/ExceptionInterface.php',
// @codingStandardsIgnoreEnd
'ZendTest\Loader\StandardAutoloaderTest' => 'some/bogus/path.php',
];
$maps = [$map, __DIR__ . '/_files/goodmap.php'];
Expand Down Expand Up @@ -167,14 +178,18 @@ public function testRegisterRegistersCallbackWithSplAutoload()

public function testCanLoadClassMapFromPhar()
{
// @codingStandardsIgnoreStart
$map = 'phar://' . str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/_files/classmap.phar/test/.//../autoload_classmap.php');
// @codingStandardsIgnoreEnd
$this->loader->registerAutoloadMap($map);
$loaded = $this->loader->autoload('some\loadedclass');
$this->assertSame('some\loadedclass', $loaded);
$this->assertTrue(class_exists('some\loadedclass', false));

// will not register duplicate, even with a different relative path
// @codingStandardsIgnoreStart
$map = 'phar://' . str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/_files/classmap.phar/test/./foo/../../autoload_classmap.php');
// @codingStandardsIgnoreEnd
$this->loader->registerAutoloadMap($map);
$test = $this->loader->getAutoloadMap();
$this->assertEquals(1, count($test));
Expand Down
4 changes: 3 additions & 1 deletion test/PluginClassLoaderTest.php
Expand Up @@ -239,7 +239,9 @@ public function testMapPrecedenceIsExplicitTrumpsConstructorTrumpsStaticTrumpsIn
$loader = new TestAsset\ExtendedPluginClassLoader();
$this->assertEquals(__CLASS__, $loader->getClassName('loader'));

$loader = new TestAsset\ExtendedPluginClassLoader(['loader' => 'ZendTest\Loader\TestAsset\ExtendedPluginClassLoader']);
$loader = new TestAsset\ExtendedPluginClassLoader(
['loader' => 'ZendTest\Loader\TestAsset\ExtendedPluginClassLoader']
);
$this->assertEquals('ZendTest\Loader\TestAsset\ExtendedPluginClassLoader', $loader->getClassName('loader'));

$loader->registerPlugin('loader', __CLASS__);
Expand Down

0 comments on commit 9db2d13

Please sign in to comment.