From 658a1aaa6a09f27252f2d37f424cd8b499799c3a Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 4 Mar 2021 13:31:08 +0100 Subject: [PATCH 1/2] Do not suggest installation of puli via composer or error messages --- composer.json | 1 - src/ClassDiscovery.php | 8 +++++++- tests/Exception/InitializeExceptionTest.php | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 3a8cc7c..5ded29e 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,6 @@ "puli/composer-plugin": "1.0.0-beta10" }, "suggest": { - "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.", "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" }, "autoload": { diff --git a/src/ClassDiscovery.php b/src/ClassDiscovery.php index ee280f3..959b782 100644 --- a/src/ClassDiscovery.php +++ b/src/ClassDiscovery.php @@ -27,6 +27,10 @@ abstract class ClassDiscovery Strategy\CommonPsr17ClassesStrategy::class, ]; + private static $deprecatedStrategies = [ + Strategy\PuliBetaStrategy::class => true, + ]; + /** * Discovery cache to make the second time we use discovery faster. * @@ -55,7 +59,9 @@ protected static function findOneByType($type) try { $candidates = call_user_func($strategy.'::getCandidates', $type); } catch (StrategyUnavailableException $e) { - $exceptions[] = $e; + if (!isset(self::$deprecatedStrategies[$strategy])) { + $exceptions[] = $e; + } continue; } diff --git a/tests/Exception/InitializeExceptionTest.php b/tests/Exception/InitializeExceptionTest.php index a9cdc56..2a00954 100644 --- a/tests/Exception/InitializeExceptionTest.php +++ b/tests/Exception/InitializeExceptionTest.php @@ -11,7 +11,6 @@ public function testInitialize() { $e[] = new DiscoveryException\ClassInstantiationFailedException(); $e[] = new DiscoveryException\NotFoundException(); - $e[] = new DiscoveryException\PuliUnavailableException(); $e[] = new DiscoveryException\StrategyUnavailableException(); $e[] = new DiscoveryException\NoCandidateFoundException('CommonClasses', []); $e[] = DiscoveryException\DiscoveryFailedException::create($e); From 1908c24d9765dab73d1e2d9dabdd081328d3e63c Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 7 Mar 2021 10:36:21 +0100 Subject: [PATCH 2/2] Reorder strategies --- src/ClassDiscovery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClassDiscovery.php b/src/ClassDiscovery.php index 959b782..4352985 100644 --- a/src/ClassDiscovery.php +++ b/src/ClassDiscovery.php @@ -22,9 +22,9 @@ abstract class ClassDiscovery * @var array */ private static $strategies = [ - Strategy\PuliBetaStrategy::class, Strategy\CommonClassesStrategy::class, Strategy\CommonPsr17ClassesStrategy::class, + Strategy\PuliBetaStrategy::class, ]; private static $deprecatedStrategies = [