From 26f9dab58e33e6509a553998c3609c8f23e5668a Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 22 Apr 2024 09:14:09 +0200 Subject: [PATCH 01/10] Add support for ROBOTS_ALLOW_ALL_SHORT_URLS --- CHANGELOG.md | 17 ++++++++ config/config.php | 3 ++ .../RobotsAllowAllShortUrlsConfigOption.php | 25 +++++++++++ ...obotsAllowAllShortUrlsConfigOptionTest.php | 41 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php create mode 100644 test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4026134..7199071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] +### Added +* Add `ROBOTS_ALLOW_ALL_SHORT_URLS` config option. + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* *Nothing* + + ## [9.1.0] - 2024-04-14 ### Added * Add `MEMORY_LIMIT` config option. diff --git a/config/config.php b/config/config.php index 855af5d..4d04dcc 100644 --- a/config/config.php +++ b/config/config.php @@ -64,6 +64,8 @@ => Config\Option\UrlShortener\EnableMultiSegmentSlugsConfigOption::class, 'URL shortener > Trailing slashes' => Config\Option\UrlShortener\EnableTrailingSlashConfigOption::class, 'URL shortener > Mode' => Config\Option\UrlShortener\ShortUrlModeConfigOption::class, + 'URL shortener > robots.txt allow all' + => Config\Option\UrlShortener\RobotsAllowAllShortUrlsConfigOption::class, 'GeoLite2 license key' => Config\Option\UrlShortener\GeoLiteLicenseKeyConfigOption::class, 'Redirects > Status code (301/302)' => Config\Option\UrlShortener\RedirectStatusCodeConfigOption::class, 'Redirects > Caching life time' => Config\Option\UrlShortener\RedirectCacheLifeTimeConfigOption::class, @@ -148,6 +150,7 @@ Config\Option\UrlShortener\EnableMultiSegmentSlugsConfigOption::class => InvokableFactory::class, Config\Option\UrlShortener\EnableTrailingSlashConfigOption::class => InvokableFactory::class, Config\Option\UrlShortener\ShortUrlModeConfigOption::class => InvokableFactory::class, + Config\Option\UrlShortener\RobotsAllowAllShortUrlsConfigOption::class => InvokableFactory::class, Config\Option\Redis\RedisServersConfigOption::class => InvokableFactory::class, Config\Option\Redis\RedisSentinelServiceConfigOption::class => InvokableFactory::class, Config\Option\Redis\RedisPubSubConfigOption::class => InvokableFactory::class, diff --git a/src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php b/src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php new file mode 100644 index 0000000..7eccfec --- /dev/null +++ b/src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php @@ -0,0 +1,25 @@ +confirm( + 'Do you want all short URLs to be crawlable/allowed by the robots.txt file? ' + . 'You can still allow them individually, regardless of this.', + default: false, + ); + } +} diff --git a/test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php b/test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php new file mode 100644 index 0000000..ca3d987 --- /dev/null +++ b/test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php @@ -0,0 +1,41 @@ +configOption = new RobotsAllowAllShortUrlsConfigOption(); + } + + #[Test] + public function returnsExpectedEnvVar(): void + { + self::assertEquals('ROBOTS_ALLOW_ALL_SHORT_URLS', $this->configOption->getEnvVar()); + } + + #[Test] + public function expectedQuestionIsAsked(): void + { + $io = $this->createMock(StyleInterface::class); + $io->expects($this->once())->method('confirm')->with( + 'Do you want all short URLs to be crawlable/allowed by the robots.txt file? ' + . 'You can still allow them individually, regardless of this.', + false, + )->willReturn(true); + + $answer = $this->configOption->ask($io, []); + + self::assertTrue($answer); + } +} From b078bfc7ba97b7f34140a2cad585acd46c9c66f8 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 12 May 2024 12:38:29 +0200 Subject: [PATCH 02/10] Update to PHPUnit 11 --- CHANGELOG.md | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7199071..f995c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * Add `ROBOTS_ALLOW_ALL_SHORT_URLS` config option. ### Changed -* *Nothing* +* Update to PHPUnit 11 ### Deprecated * *Nothing* diff --git a/composer.json b/composer.json index 485b0c5..261e987 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "require": { "php": "^8.2", "laminas/laminas-config": "^3.9", - "laminas/laminas-config-aggregator": "^1.14", + "laminas/laminas-config-aggregator": "^1.15", "laminas/laminas-servicemanager": "^3.22", "laminas/laminas-stdlib": "^3.19", "shlinkio/shlink-config": "^3.0 || ^2.5", @@ -26,7 +26,7 @@ "devster/ubench": "^2.1", "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^11.1", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", "symfony/var-dumper": "^7.0 || ^6.4" From 3a1773789d5d41f7cfa7a02ad773d35ddd027cf9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 3 Jul 2024 10:11:22 +0200 Subject: [PATCH 03/10] Update to PHPStan 1.11 --- CHANGELOG.md | 1 + composer.json | 4 ++-- docker-compose.override.yml.dist | 2 -- docker-compose.yml | 2 -- phpstan.neon | 4 ++-- src/Config/ConfigOptionsManager.php | 3 +++ 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f995c83..6a99d72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Changed * Update to PHPUnit 11 +* Update to PHPStan 1.11 ### Deprecated * *Nothing* diff --git a/composer.json b/composer.json index 261e987..7b81974 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ }, "require-dev": { "devster/ubench": "^2.1", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-phpunit": "^1.4", "phpunit/phpunit": "^11.1", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", diff --git a/docker-compose.override.yml.dist b/docker-compose.override.yml.dist index 4a667f1..f823f01 100644 --- a/docker-compose.override.yml.dist +++ b/docker-compose.override.yml.dist @@ -1,5 +1,3 @@ -version: '3' - services: shlink_installer_php: user: 1000:1000 diff --git a/docker-compose.yml b/docker-compose.yml index 9220c3a..b0fcb7d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: shlink_installer_php: container_name: shlink_installer_php diff --git a/phpstan.neon b/phpstan.neon index 88060ed..ce86abc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,5 +2,5 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon parameters: - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + ignoreErrors: + - identifier: missingType.iterableValue diff --git a/src/Config/ConfigOptionsManager.php b/src/Config/ConfigOptionsManager.php index f91a3bc..10f1aeb 100644 --- a/src/Config/ConfigOptionsManager.php +++ b/src/Config/ConfigOptionsManager.php @@ -6,6 +6,9 @@ use Laminas\ServiceManager\AbstractPluginManager; +/** + * @extends AbstractPluginManager + */ class ConfigOptionsManager extends AbstractPluginManager implements ConfigOptionsManagerInterface { protected $instanceOf = Option\ConfigOptionInterface::class; // phpcs:ignore From cc8652b0fa2ace759452901fb3d983d6cd965a39 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 5 Jul 2024 09:10:41 +0200 Subject: [PATCH 04/10] Move RobotsAllowAllShortUrlsConfigOption to dedicated namespace --- composer.json | 10 +++++----- config/config.php | 8 +++++--- .../RobotsAllowAllShortUrlsConfigOption.php | 2 +- .../RobotsAllowAllShortUrlsConfigOptionTest.php | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) rename src/Config/Option/{UrlShortener => Robots}/RobotsAllowAllShortUrlsConfigOption.php (90%) rename test/Config/Option/{UrlShortener => Robots}/RobotsAllowAllShortUrlsConfigOptionTest.php (86%) diff --git a/composer.json b/composer.json index 7b81974..7dfec2c 100644 --- a/composer.json +++ b/composer.json @@ -17,10 +17,10 @@ "laminas/laminas-config-aggregator": "^1.15", "laminas/laminas-servicemanager": "^3.22", "laminas/laminas-stdlib": "^3.19", - "shlinkio/shlink-config": "^3.0 || ^2.5", - "symfony/console": "^7.0 || ^6.4", - "symfony/filesystem": "^7.0 || ^6.4", - "symfony/process": "^7.0 || ^6.4" + "shlinkio/shlink-config": "^3.0", + "symfony/console": "^7.1", + "symfony/filesystem": "^7.1", + "symfony/process": "^7.1" }, "require-dev": { "devster/ubench": "^2.1", @@ -29,7 +29,7 @@ "phpunit/phpunit": "^11.1", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", - "symfony/var-dumper": "^7.0 || ^6.4" + "symfony/var-dumper": "^7.1" }, "autoload": { "psr-4": { diff --git a/config/config.php b/config/config.php index 4d04dcc..072191d 100644 --- a/config/config.php +++ b/config/config.php @@ -64,12 +64,14 @@ => Config\Option\UrlShortener\EnableMultiSegmentSlugsConfigOption::class, 'URL shortener > Trailing slashes' => Config\Option\UrlShortener\EnableTrailingSlashConfigOption::class, 'URL shortener > Mode' => Config\Option\UrlShortener\ShortUrlModeConfigOption::class, - 'URL shortener > robots.txt allow all' - => Config\Option\UrlShortener\RobotsAllowAllShortUrlsConfigOption::class, 'GeoLite2 license key' => Config\Option\UrlShortener\GeoLiteLicenseKeyConfigOption::class, 'Redirects > Status code (301/302)' => Config\Option\UrlShortener\RedirectStatusCodeConfigOption::class, 'Redirects > Caching life time' => Config\Option\UrlShortener\RedirectCacheLifeTimeConfigOption::class, ], + 'ROBOTS' => [ + 'Robots.txt > allow all' => Config\Option\Robots\RobotsAllowAllShortUrlsConfigOption::class, +// 'Robots.txt > user agents' => Config\Option\Robots\RobotsUserAgents::class, + ], 'TRACKING' => [ 'Tracking > Orphan visits tracking' => Config\Option\Tracking\OrphanVisitsTrackingConfigOption::class, 'Tracking > Param to disable tracking' => Config\Option\Tracking\DisableTrackParamConfigOption::class, @@ -150,7 +152,7 @@ Config\Option\UrlShortener\EnableMultiSegmentSlugsConfigOption::class => InvokableFactory::class, Config\Option\UrlShortener\EnableTrailingSlashConfigOption::class => InvokableFactory::class, Config\Option\UrlShortener\ShortUrlModeConfigOption::class => InvokableFactory::class, - Config\Option\UrlShortener\RobotsAllowAllShortUrlsConfigOption::class => InvokableFactory::class, + Config\Option\Robots\RobotsAllowAllShortUrlsConfigOption::class => InvokableFactory::class, Config\Option\Redis\RedisServersConfigOption::class => InvokableFactory::class, Config\Option\Redis\RedisSentinelServiceConfigOption::class => InvokableFactory::class, Config\Option\Redis\RedisPubSubConfigOption::class => InvokableFactory::class, diff --git a/src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php b/src/Config/Option/Robots/RobotsAllowAllShortUrlsConfigOption.php similarity index 90% rename from src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php rename to src/Config/Option/Robots/RobotsAllowAllShortUrlsConfigOption.php index 7eccfec..4435ece 100644 --- a/src/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOption.php +++ b/src/Config/Option/Robots/RobotsAllowAllShortUrlsConfigOption.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Shlinkio\Shlink\Installer\Config\Option\UrlShortener; +namespace Shlinkio\Shlink\Installer\Config\Option\Robots; use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption; use Symfony\Component\Console\Style\StyleInterface; diff --git a/test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php b/test/Config/Option/Robots/RobotsAllowAllShortUrlsConfigOptionTest.php similarity index 86% rename from test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php rename to test/Config/Option/Robots/RobotsAllowAllShortUrlsConfigOptionTest.php index ca3d987..a76cafd 100644 --- a/test/Config/Option/UrlShortener/RobotsAllowAllShortUrlsConfigOptionTest.php +++ b/test/Config/Option/Robots/RobotsAllowAllShortUrlsConfigOptionTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace ShlinkioTest\Shlink\Installer\Config\Option\UrlShortener; +namespace ShlinkioTest\Shlink\Installer\Config\Option\Robots; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -use Shlinkio\Shlink\Installer\Config\Option\UrlShortener\RobotsAllowAllShortUrlsConfigOption; +use Shlinkio\Shlink\Installer\Config\Option\Robots\RobotsAllowAllShortUrlsConfigOption; use Symfony\Component\Console\Style\StyleInterface; class RobotsAllowAllShortUrlsConfigOptionTest extends TestCase From 1c1cb7520043bb5bc7a6a7604159fdb24869e6dc Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 5 Jul 2024 09:36:50 +0200 Subject: [PATCH 05/10] Add ROBOTS_USER_AGENTS config option --- CHANGELOG.md | 1 + config/config.php | 8 ++-- .../Robots/RobotsUserAgentsConfigOption.php | 23 +++++++++++ .../RobotsUserAgentsConfigOptionTest.php | 39 +++++++++++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/Config/Option/Robots/RobotsUserAgentsConfigOption.php create mode 100644 test/Config/Option/Robots/RobotsUserAgentsConfigOptionTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a99d72..55fe66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ## [Unreleased] ### Added * Add `ROBOTS_ALLOW_ALL_SHORT_URLS` config option. +* Add `ROBOTS_USER_AGENTS` config option. ### Changed * Update to PHPUnit 11 diff --git a/config/config.php b/config/config.php index 072191d..d3771e2 100644 --- a/config/config.php +++ b/config/config.php @@ -68,10 +68,6 @@ 'Redirects > Status code (301/302)' => Config\Option\UrlShortener\RedirectStatusCodeConfigOption::class, 'Redirects > Caching life time' => Config\Option\UrlShortener\RedirectCacheLifeTimeConfigOption::class, ], - 'ROBOTS' => [ - 'Robots.txt > allow all' => Config\Option\Robots\RobotsAllowAllShortUrlsConfigOption::class, -// 'Robots.txt > user agents' => Config\Option\Robots\RobotsUserAgents::class, - ], 'TRACKING' => [ 'Tracking > Orphan visits tracking' => Config\Option\Tracking\OrphanVisitsTrackingConfigOption::class, 'Tracking > Param to disable tracking' => Config\Option\Tracking\DisableTrackParamConfigOption::class, @@ -100,6 +96,10 @@ 'QR codes > Enabled for disabled short URLs' => Config\Option\QrCode\EnabledForDisabledShortUrlsConfigOption::class, ], + 'ROBOTS' => [ + 'Robots.txt > allow all' => Config\Option\Robots\RobotsAllowAllShortUrlsConfigOption::class, + 'Robots.txt > user agents' => Config\Option\Robots\RobotsUserAgentsConfigOption::class, + ], 'APPLICATION' => [ 'Delete short URLs > Visits threshold' => Config\Option\Visit\VisitsThresholdConfigOption::class, 'Base path' => Config\Option\BasePathConfigOption::class, diff --git a/src/Config/Option/Robots/RobotsUserAgentsConfigOption.php b/src/Config/Option/Robots/RobotsUserAgentsConfigOption.php new file mode 100644 index 0000000..566e23f --- /dev/null +++ b/src/Config/Option/Robots/RobotsUserAgentsConfigOption.php @@ -0,0 +1,23 @@ +ask( + 'Provide a comma-separated list of user agents for your robots.txt file. Defaults to all user agents (*)', + ); + } +} diff --git a/test/Config/Option/Robots/RobotsUserAgentsConfigOptionTest.php b/test/Config/Option/Robots/RobotsUserAgentsConfigOptionTest.php new file mode 100644 index 0000000..97a7b3c --- /dev/null +++ b/test/Config/Option/Robots/RobotsUserAgentsConfigOptionTest.php @@ -0,0 +1,39 @@ +configOption = new RobotsUserAgentsConfigOption(); + } + + #[Test] + public function returnsExpectedEnvVar(): void + { + self::assertEquals('ROBOTS_USER_AGENTS', $this->configOption->getEnvVar()); + } + + #[Test] + public function expectedQuestionIsAsked(): void + { + $io = $this->createMock(StyleInterface::class); + $io->expects($this->once())->method('ask')->with( + 'Provide a comma-separated list of user agents for your robots.txt file. Defaults to all user agents (*)', + )->willReturn('foo,bar'); + + $answer = $this->configOption->ask($io, []); + + self::assertEquals('foo,bar', $answer); + } +} From 08ac905811855c6588969a59e55c426539ea7989 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 22 Jul 2024 09:55:56 +0200 Subject: [PATCH 06/10] Add support for laminas-servicemanager 4 --- CHANGELOG.md | 1 + composer.json | 6 ++--- src/Config/ConfigOptionsManager.php | 22 ++++++++++++++++++- .../ConfigOptionsManagerFactoryTest.php | 18 +++++++-------- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55fe66b..cb7af2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Added * Add `ROBOTS_ALLOW_ALL_SHORT_URLS` config option. * Add `ROBOTS_USER_AGENTS` config option. +* Add support for `laminas/laminas-servicemanager` v4.x. ### Changed * Update to PHPUnit 11 diff --git a/composer.json b/composer.json index 7dfec2c..0f986f6 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,9 @@ "php": "^8.2", "laminas/laminas-config": "^3.9", "laminas/laminas-config-aggregator": "^1.15", - "laminas/laminas-servicemanager": "^3.22", + "laminas/laminas-servicemanager": "^4.2 || ^3.22", "laminas/laminas-stdlib": "^3.19", - "shlinkio/shlink-config": "^3.0", + "shlinkio/shlink-config": "^3.1", "symfony/console": "^7.1", "symfony/filesystem": "^7.1", "symfony/process": "^7.1" @@ -26,7 +26,7 @@ "devster/ubench": "^2.1", "phpstan/phpstan": "^1.11", "phpstan/phpstan-phpunit": "^1.4", - "phpunit/phpunit": "^11.1", + "phpunit/phpunit": "^11.2", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", "symfony/var-dumper": "^7.1" diff --git a/src/Config/ConfigOptionsManager.php b/src/Config/ConfigOptionsManager.php index 10f1aeb..8d4b6eb 100644 --- a/src/Config/ConfigOptionsManager.php +++ b/src/Config/ConfigOptionsManager.php @@ -5,11 +5,31 @@ namespace Shlinkio\Shlink\Installer\Config; use Laminas\ServiceManager\AbstractPluginManager; +use Laminas\ServiceManager\Exception\InvalidServiceException; + +use function get_debug_type; +use function sprintf; /** - * @extends AbstractPluginManager + * @extends AbstractPluginManager+ + * @todo Extend from AbstractSingleInstancePluginManager once servicemanager 3 is no longer supported */ class ConfigOptionsManager extends AbstractPluginManager implements ConfigOptionsManagerInterface { + /** @var class-string */ protected $instanceOf = Option\ConfigOptionInterface::class; // phpcs:ignore + + public function validate(mixed $instance): void + { + if ($instance instanceof $this->instanceOf) { + return; + } + + throw new InvalidServiceException(sprintf( + 'Plugin manager "%s" expected an instance of type "%s", but "%s" was received', + static::class, + $this->instanceOf, + get_debug_type($instance), + )); + } } diff --git a/test/Config/ConfigOptionsManagerFactoryTest.php b/test/Config/ConfigOptionsManagerFactoryTest.php index df563c6..03f360a 100644 --- a/test/Config/ConfigOptionsManagerFactoryTest.php +++ b/test/Config/ConfigOptionsManagerFactoryTest.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -use ReflectionObject; use Shlinkio\Shlink\Installer\Config\ConfigOptionsManagerFactory; use Shlinkio\Shlink\Installer\Config\Option\ConfigOptionInterface; @@ -25,23 +24,22 @@ public function setUp(): void } #[Test, DataProvider('provideConfigs')] - public function createsServiceWithExpectedPlugins(callable $configCreator, int $expectedSize): void + public function createsServiceWithExpectedPlugins(callable $configCreator, bool $servicesExist): void { $config = $configCreator($this); $this->container->expects($this->once())->method('get')->with('config')->willReturn($config); - $service = ($this->factory)($this->container); - $ref = new ReflectionObject($service); - $servicesProp = $ref->getProperty('services'); - $servicesProp->setAccessible(true); + $manager = ($this->factory)($this->container); - self::assertCount($expectedSize, $servicesProp->getValue($service)); + self::assertEquals($servicesExist, $manager->has('a')); + self::assertEquals($servicesExist, $manager->has('b')); + self::assertEquals($servicesExist, $manager->has('c')); } public static function provideConfigs(): iterable { - yield 'config_options not defined' => [static fn (TestCase $test) => [], 0]; - yield 'config_options empty' => [static fn (TestCase $test) => ['config_options' => []], 0]; + yield 'config_options not defined' => [static fn (TestCase $test) => [], false]; + yield 'config_options empty' => [static fn (TestCase $test) => ['config_options' => []], false]; yield 'config_options with values' => [ static fn (TestCase $test) => [ 'config_options' => [ @@ -52,7 +50,7 @@ public static function provideConfigs(): iterable ], ], ], - 3, + true, ]; } } From 326c798fca957aa72bb7ce15335a580b0d2b4a8f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 29 Jul 2024 08:52:44 +0200 Subject: [PATCH 07/10] Fix typo --- src/Config/ConfigOptionsManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/ConfigOptionsManager.php b/src/Config/ConfigOptionsManager.php index 8d4b6eb..91082fd 100644 --- a/src/Config/ConfigOptionsManager.php +++ b/src/Config/ConfigOptionsManager.php @@ -11,7 +11,7 @@ use function sprintf; /** - * @extends AbstractPluginManager+ + * @extends AbstractPluginManager * @todo Extend from AbstractSingleInstancePluginManager once servicemanager 3 is no longer supported */ class ConfigOptionsManager extends AbstractPluginManager implements ConfigOptionsManagerInterface From f070e4ae614db3e209173e1353ea918961a6b807 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 31 Jul 2024 19:53:24 +0200 Subject: [PATCH 08/10] Improve PHPStan config --- composer.json | 2 +- phpstan.neon | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 0f986f6..a8f638b 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ ], "cs": "phpcs", "cs:fix": "phpcbf", - "stan": "phpstan analyse src test test-resources config --level=8", + "stan": "phpstan analyse", "test": "phpunit --order-by=random --testdox --colors=always", "test:ci": "@test --coverage-clover=build/clover.xml", "test:pretty": "@test --coverage-html=build/coverage-html" diff --git a/phpstan.neon b/phpstan.neon index ce86abc..920bb1a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,12 @@ includes: - - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-phpunit/rules.neon + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-phpunit/rules.neon parameters: - ignoreErrors: - - identifier: missingType.iterableValue + level: 8 + paths: + - config + - src + - test + - test-resources + ignoreErrors: + - identifier: missingType.iterableValue From 76e56241ce8127970b97be4c1b8f54f8b1d79153 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 4 Aug 2024 13:27:45 +0200 Subject: [PATCH 09/10] Add --testdox-summary flag to phpunit executions --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a8f638b..62b003d 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "devster/ubench": "^2.1", "phpstan/phpstan": "^1.11", "phpstan/phpstan-phpunit": "^1.4", - "phpunit/phpunit": "^11.2", + "phpunit/phpunit": "^11.3", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", "symfony/var-dumper": "^7.1" @@ -50,7 +50,7 @@ "cs": "phpcs", "cs:fix": "phpcbf", "stan": "phpstan analyse", - "test": "phpunit --order-by=random --testdox --colors=always", + "test": "phpunit --order-by=random --testdox --testdox-summary", "test:ci": "@test --coverage-clover=build/clover.xml", "test:pretty": "@test --coverage-html=build/coverage-html" }, From c1afdd68110fcf2b66c78b24c258c83e051de2ef Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 11 Aug 2024 18:20:50 +0200 Subject: [PATCH 10/10] Add v9.2.0 to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb7af2c..c8d22ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [9.2.0] - 2024-08-11 ### Added * Add `ROBOTS_ALLOW_ALL_SHORT_URLS` config option. * Add `ROBOTS_USER_AGENTS` config option.