From 7d76667d4611d61bb066e8606211611b13fd8fd6 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 11 Oct 2020 18:24:12 +0200 Subject: [PATCH] Switch namespace --- docs/exceptions/filesCouldNotLocatePHP.md | 2 +- docs/exceptions/filesExecNotAvailable.md | 2 +- docs/exceptions/missingComposerConfig.md | 4 +- docs/exceptions/unknownNamespace.md | 2 +- src/AppConfig.php | 4 +- src/ClassFinder.php | 14 +++--- src/Classmap/ClassmapEntry.php | 4 +- src/Classmap/ClassmapEntryFactory.php | 6 +-- src/Classmap/ClassmapFinder.php | 6 +-- src/Exception/ClassFinderException.php | 2 +- src/Files/FilesEntry.php | 4 +- src/Files/FilesEntryFactory.php | 6 +-- src/Files/FilesFinder.php | 6 +-- src/FinderInterface.php | 2 +- src/PSR4/PSR4Finder.php | 6 +-- src/PSR4/PSR4Namespace.php | 8 ++-- src/PSR4/PSR4NamespaceFactory.php | 6 +-- test/app1/composer.json | 2 +- test/app1/composer.lock | 6 +-- test/app1/src/ClassFinderTest.php | 4 +- test/app1/src/ClassmapTest.php | 40 ++++++++-------- test/app1/src/FilesTest.php | 16 +++---- test/app1/src/PSR4Test.php | 58 +++++++++++------------ test/app2/ClassmapNoAutoloadTest.php | 40 ++++++++-------- test/app2/PSR4NoAutoloadTest.php | 48 +++++++++---------- test/app2/composer.json | 2 +- test/app2/composer.lock | 6 +-- test/unit/Classmap/ClassmapEntryTest.php | 6 +-- test/unit/Files/FilesEntryTest.php | 6 +-- test/unit/PSR4/PSR4NamespaceTest.php | 6 +-- 30 files changed, 162 insertions(+), 162 deletions(-) diff --git a/docs/exceptions/filesCouldNotLocatePHP.md b/docs/exceptions/filesCouldNotLocatePHP.md index 91895d1..524ad7f 100644 --- a/docs/exceptions/filesCouldNotLocatePHP.md +++ b/docs/exceptions/filesCouldNotLocatePHP.md @@ -7,7 +7,7 @@ Example PHP: require_once __DIR__ . '/../vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; ClassFinder::enableExperimentalFilesSupport(); $classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar'); diff --git a/docs/exceptions/filesExecNotAvailable.md b/docs/exceptions/filesExecNotAvailable.md index 531e162..1e4fa5a 100644 --- a/docs/exceptions/filesExecNotAvailable.md +++ b/docs/exceptions/filesExecNotAvailable.md @@ -7,7 +7,7 @@ Example PHP: require_once __DIR__ . '/../vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; ClassFinder::enableExperimentalFilesSupport(); $classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar'); diff --git a/docs/exceptions/missingComposerConfig.md b/docs/exceptions/missingComposerConfig.md index a9adfcb..cdc4c42 100644 --- a/docs/exceptions/missingComposerConfig.md +++ b/docs/exceptions/missingComposerConfig.md @@ -7,7 +7,7 @@ Example PHP: require_once __DIR__ . '/../vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; $classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar'); ``` @@ -25,7 +25,7 @@ is the directory that contains the composer.json configuration and where classes require_once __DIR__ . '/../vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; ClassFinder::setAppRoot(realpath(__DIR__ . '../../app/')); // This is suggesting that the app root is really someone else. $classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar'); diff --git a/docs/exceptions/unknownNamespace.md b/docs/exceptions/unknownNamespace.md index c7e62a4..ee311c7 100644 --- a/docs/exceptions/unknownNamespace.md +++ b/docs/exceptions/unknownNamespace.md @@ -9,7 +9,7 @@ Example PHP: require_once __DIR__ . '/../vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; $classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar'); ``` diff --git a/src/AppConfig.php b/src/AppConfig.php index 92993b6..0a5185a 100644 --- a/src/AppConfig.php +++ b/src/AppConfig.php @@ -1,8 +1,8 @@ countMatchingNamespaceSegments("TestApp1\\Multi") -> 2, TestApp1\\Multi matches * * PSR4Namespace $c; - * $c->namespace = "HaydenPierce\\Foo\\Bar"; + * $c->namespace = "danog\\Foo\\Bar"; * $c->countMatchingNamespaceSegments("TestApp1\\Multi") -> 0, No matches. * * @param string $namespace diff --git a/src/PSR4/PSR4NamespaceFactory.php b/src/PSR4/PSR4NamespaceFactory.php index f74bf53..10b5259 100644 --- a/src/PSR4/PSR4NamespaceFactory.php +++ b/src/PSR4/PSR4NamespaceFactory.php @@ -1,9 +1,9 @@ assertFalse(ClassFinder::namespaceHasClasses('DoesNotExist')); - $this->assertTrue(ClassFinder::namespaceHasClasses('HaydenPierce\ClassFinder')); + $this->assertTrue(ClassFinder::namespaceHasClasses('danog\ClassFinder')); } public function testCanFindSelf() { try { - $classes = ClassFinder::getClassesInNamespace('HaydenPierce\ClassFinder', ClassFinder::RECURSIVE_MODE); + $classes = ClassFinder::getClassesInNamespace('danog\ClassFinder', ClassFinder::RECURSIVE_MODE); } catch (\Exception $e) { $this->assertFalse(true, 'An exception occurred: ' . $e->getMessage()); $classes = array(); diff --git a/test/app2/ClassmapNoAutoloadTest.php b/test/app2/ClassmapNoAutoloadTest.php index 8032e7b..60c96f5 100644 --- a/test/app2/ClassmapNoAutoloadTest.php +++ b/test/app2/ClassmapNoAutoloadTest.php @@ -4,7 +4,7 @@ namespace TestApp2; require_once __DIR__ . '/vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; class ClassmapNoAutoloadTest extends \PHPUnit_Framework_TestCase { @@ -32,22 +32,22 @@ class ClassmapNoAutoloadTest extends \PHPUnit_Framework_TestCase { return array( array( - 'HaydenPierce\Classmap', + 'danog\Classmap', array( - 'HaydenPierce\Classmap\Classmap2ClassmapINC', - 'HaydenPierce\Classmap\Classmap2ClassmapPHP', - 'HaydenPierce\Classmap\Classmap3ClassesPHP', - 'HaydenPierce\Classmap\ClassmapClassmap2PHP' + 'danog\Classmap\Classmap2ClassmapINC', + 'danog\Classmap\Classmap2ClassmapPHP', + 'danog\Classmap\Classmap3ClassesPHP', + 'danog\Classmap\ClassmapClassmap2PHP' ), 'Classfinder should be able to load classes based on a classmap from 3rd party packages.' ), array( - 'HaydenPierce\Classmap2', + 'danog\Classmap2', array( - 'HaydenPierce\Classmap2\Classmap2ClassmapINC', - 'HaydenPierce\Classmap2\Classmap2ClassmapPHP', - 'HaydenPierce\Classmap2\Classmap3ClassesPHP', - 'HaydenPierce\Classmap2\ClassmapClassmap2PHP' + 'danog\Classmap2\Classmap2ClassmapINC', + 'danog\Classmap2\Classmap2ClassmapPHP', + 'danog\Classmap2\Classmap3ClassesPHP', + 'danog\Classmap2\ClassmapClassmap2PHP' ), 'Classfinder should be able to handle multiple namespaces in a single file for a classmap.' ) @@ -77,16 +77,16 @@ class ClassmapNoAutoloadTest extends \PHPUnit_Framework_TestCase { return array( array( - 'HaydenPierce', + 'danog', array( - 'HaydenPierce\Classmap2\Classmap2ClassmapINC', - 'HaydenPierce\Classmap2\Classmap2ClassmapPHP', - 'HaydenPierce\Classmap2\Classmap3ClassesPHP', - 'HaydenPierce\Classmap2\ClassmapClassmap2PHP', - 'HaydenPierce\Classmap\Classmap2ClassmapINC', - 'HaydenPierce\Classmap\Classmap2ClassmapPHP', - 'HaydenPierce\Classmap\Classmap3ClassesPHP', - 'HaydenPierce\Classmap\ClassmapClassmap2PHP', + 'danog\Classmap2\Classmap2ClassmapINC', + 'danog\Classmap2\Classmap2ClassmapPHP', + 'danog\Classmap2\Classmap3ClassesPHP', + 'danog\Classmap2\ClassmapClassmap2PHP', + 'danog\Classmap\Classmap2ClassmapINC', + 'danog\Classmap\Classmap2ClassmapPHP', + 'danog\Classmap\Classmap3ClassesPHP', + 'danog\Classmap\ClassmapClassmap2PHP', ), 'Classfinder should be able to load third party classes recursively based on a classmap.' ) diff --git a/test/app2/PSR4NoAutoloadTest.php b/test/app2/PSR4NoAutoloadTest.php index b5b2466..d0e70d6 100644 --- a/test/app2/PSR4NoAutoloadTest.php +++ b/test/app2/PSR4NoAutoloadTest.php @@ -4,7 +4,7 @@ namespace TestApp2; require_once __DIR__ . '/vendor/autoload.php'; -use HaydenPierce\ClassFinder\ClassFinder; +use danog\ClassFinder\ClassFinder; class PSR4NoAutoloadTest extends \PHPUnit_Framework_TestCase { @@ -35,46 +35,46 @@ class PSR4NoAutoloadTest extends \PHPUnit_Framework_TestCase { return array( array( - 'HaydenPierce\SandboxApp', + 'danog\SandboxApp', array( - 'HaydenPierce\SandboxApp\Foy' + 'danog\SandboxApp\Foy' ), 'ClassFinder should be able to find 3rd party classes' ), array( - 'HaydenPierce\SandboxApp\Foo\Bar', + 'danog\SandboxApp\Foo\Bar', array( - 'HaydenPierce\SandboxApp\Foo\Bar\Barc', - 'HaydenPierce\SandboxApp\Foo\Bar\Barp' + 'danog\SandboxApp\Foo\Bar\Barc', + 'danog\SandboxApp\Foo\Bar\Barp' ), 'ClassFinder should be able to find 3rd party classes multiple namespaces deep.' ), array( - 'HaydenPierce\SandboxAppMulti', + 'danog\SandboxAppMulti', array( - 'HaydenPierce\SandboxAppMulti\Zip', - 'HaydenPierce\SandboxAppMulti\Zop', - 'HaydenPierce\SandboxAppMulti\Zap', - 'HaydenPierce\SandboxAppMulti\Zit' + 'danog\SandboxAppMulti\Zip', + 'danog\SandboxAppMulti\Zop', + 'danog\SandboxAppMulti\Zap', + 'danog\SandboxAppMulti\Zit' ), - 'ClassFinder should be able to find 3rd party classes when a provided namespace root maps to multiple directories (Example: "HaydenPierce\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )' + 'ClassFinder should be able to find 3rd party classes when a provided namespace root maps to multiple directories (Example: "danog\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )' ) ); } public function testGetClassesInNamespaceRecursively() { - $namespace = 'HaydenPierce'; + $namespace = 'danog'; $expected = array( - 'HaydenPierce\SandboxApp\Foy', - 'HaydenPierce\SandboxApp\Fob\Soz', - 'HaydenPierce\SandboxApp\Foo\Larc', - 'HaydenPierce\SandboxApp\Foo\Bar\Barc', - 'HaydenPierce\SandboxApp\Foo\Bar\Barp', - 'HaydenPierce\SandboxAppMulti\Zip', - 'HaydenPierce\SandboxAppMulti\Zop', - 'HaydenPierce\SandboxAppMulti\Zap', - 'HaydenPierce\SandboxAppMulti\Zit' + 'danog\SandboxApp\Foy', + 'danog\SandboxApp\Fob\Soz', + 'danog\SandboxApp\Foo\Larc', + 'danog\SandboxApp\Foo\Bar\Barc', + 'danog\SandboxApp\Foo\Bar\Barp', + 'danog\SandboxAppMulti\Zip', + 'danog\SandboxAppMulti\Zop', + 'danog\SandboxAppMulti\Zap', + 'danog\SandboxAppMulti\Zit' ); $message = 'ClassFinder should be able to find 3rd party classes'; @@ -88,10 +88,10 @@ class PSR4NoAutoloadTest extends \PHPUnit_Framework_TestCase } // ClassFinder has the ability to find itself. This ability, while intended, is incontinent for tests - // because of the 'HaydenPierce' test case. Whenever ClassFinder would be updated, we would need to update the + // because of the 'danog' test case. Whenever ClassFinder would be updated, we would need to update the // test. To prevent the flakiness, we just remove ClassFinder's classes. $classes = array_filter($classes, function($class) { - return strpos($class, 'HaydenPierce\ClassFinder') !== 0; + return strpos($class, 'danog\ClassFinder') !== 0; }); ClassFinder::enableClassmapSupport(); diff --git a/test/app2/composer.json b/test/app2/composer.json index 5425005..e4f39fa 100644 --- a/test/app2/composer.json +++ b/test/app2/composer.json @@ -1,5 +1,5 @@ { - "name": "HaydenPierce/testApp", + "name": "danog/testApp", "type": "project", "license": "MIT", "authors": [ diff --git a/test/app2/composer.lock b/test/app2/composer.lock index 6155acf..21b1f87 100644 --- a/test/app2/composer.lock +++ b/test/app2/composer.lock @@ -81,7 +81,7 @@ "type": "library", "autoload": { "psr-4": { - "HaydenPierce\\ClassFinder\\": "src/" + "danog\\ClassFinder\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -113,8 +113,8 @@ "type": "library", "autoload": { "psr-4": { - "HaydenPierce\\SandboxApp\\": "src/", - "HaydenPierce\\SandboxAppMulti\\": [ + "danog\\SandboxApp\\": "src/", + "danog\\SandboxAppMulti\\": [ "multi/Bop", "multi/Bot" ] diff --git a/test/unit/Classmap/ClassmapEntryTest.php b/test/unit/Classmap/ClassmapEntryTest.php index b7c5354..a45e9da 100644 --- a/test/unit/Classmap/ClassmapEntryTest.php +++ b/test/unit/Classmap/ClassmapEntryTest.php @@ -1,9 +1,9 @@ getMockBuilder('\HaydenPierce\ClassFinder\PSR4\PSR4Namespace') + $namespace = $this->getMockBuilder('\danog\ClassFinder\PSR4\PSR4Namespace') ->setConstructorArgs(array( 'MyPSR4Root\\Foot\\', array($this->root->getChild('Baz')->path())