From aee714f356e09fb4d692dd61882e22aee07f57a6 Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Tue, 4 Mar 2025 15:07:05 +0100 Subject: [PATCH 01/13] bump versions and CI --- .github/workflows/php.yml | 28 ++++++++++++++++++++++------ composer.json | 18 +++++++++--------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e4514c1..b6f18de 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -14,7 +14,23 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.0', '8.1', '8.2'] + php: + - version: '8.1' + composer_flags: --prefer-lowest + - version: '8.2' + composer_flags: --prefer-lowest + - version: '8.3' + composer_flags: --prefer-lowest + - version: '8.4' + composer_flags: --prefer-lowest + - version: '8.1' + composer_flags: --prefer-stable + - version: '8.2' + composer_flags: --prefer-stable + - version: '8.3' + composer_flags: --prefer-stable + - version: '8.4' + composer_flags: --prefer-stable steps: - uses: actions/checkout@v3 @@ -27,7 +43,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php.version }} extensions: curl, mbstring, intl, libxml, simplexml coverage: xdebug @@ -40,17 +56,17 @@ jobs: uses: actions/cache@v3 with: path: ${{ steps.composer-cache-dir.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-composer-${{ matrix.php.composer_flags }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.php.composer_flags }}- - name: Install dependencies - run: (test -d vendor && echo vendor directory exists) || composer install --prefer-dist --no-progress --no-suggest + run: (test -d vendor && echo vendor directory exists) || composer install --prefer-dist --no-progress --no-suggest ${{ matrix.php.composer_flags }} - name: Run PHPUnit run: ./bin/phpunit --coverage-text --coverage-clover clover.xml - name: Upload Scrutinizer coverage - if: matrix.php-versions == '8.0' + if: matrix.php.version == '8.1' && matrix.php.composer_flags == '--prefer-stable' uses: sudo-bot/action-scrutinizer@latest with: cli-args: "--format=php-clover clover.xml" \ No newline at end of file diff --git a/composer.json b/composer.json index ab253b3..27fbd30 100644 --- a/composer.json +++ b/composer.json @@ -3,19 +3,19 @@ "description": "A library to manage patch requests", "keywords": ["rest", "patch", "api", "symfony", "bundle"], "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", - "symfony/property-access": "^4.0 || ^5.0 || ^6.0", - "symfony/http-foundation": "^4.0 || ^5.0 || ^6.0", - "symfony/options-resolver": "^4.0 || ^5.0 || ^6.0", - "symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0", - "symfony/http-kernel": "^4.0 || ^5.0 || ^6.0", - "symfony/config": "^4.0 || ^5.0 || ^6.0", - "symfony/event-dispatcher": "^4.0 || ^5.0 || ^6.0", + "symfony/property-access": "^6.0 || ^7.0", + "symfony/http-foundation": "^6.0 || ^7.0", + "symfony/options-resolver": "^6.0 || ^7.0", + "symfony/dependency-injection": "^6.0 || ^7.0", + "symfony/http-kernel": "^6.0 || ^7.0", + "symfony/config": "^6.0 || ^7.0", + "symfony/event-dispatcher": "^6.0 || ^7.0", "mattiabasone/phpcollection": "^0.7.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.1", + "friendsofphp/php-cs-fixer": "^3.70", "phpunit/phpunit": "^9.5", "mockery/mockery": "^1.4", "yohang/finite": "^1.2", From d50b165260ee247dfd645d603a4787ba3ae08c6a Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Tue, 4 Mar 2025 15:10:48 +0100 Subject: [PATCH 02/13] bump versions and CI --- .github/workflows/php.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index b6f18de..a072d5d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -10,7 +10,7 @@ on: jobs: test: - name: Test PHP ${{ matrix.php-versions }} + name: Test PHP ${{ matrix.php.version }} ${{ matrix.php.composer_flags }} runs-on: ubuntu-latest strategy: matrix: @@ -60,7 +60,7 @@ jobs: restore-keys: ${{ runner.os }}-composer-${{ matrix.php.composer_flags }}- - name: Install dependencies - run: (test -d vendor && echo vendor directory exists) || composer install --prefer-dist --no-progress --no-suggest ${{ matrix.php.composer_flags }} + run: (test -d vendor && echo vendor directory exists) || composer update ${{ matrix.php.composer_flags }} --no-progress --no-suggest - name: Run PHPUnit run: ./bin/phpunit --coverage-text --coverage-clover clover.xml From 46702f27f24b2e5d0cb533a8c4bb2cf3a13ca4eb Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Tue, 4 Mar 2025 16:19:13 +0100 Subject: [PATCH 03/13] bump prophecy-phpunit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 27fbd30..8c248ac 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "mockery/mockery": "^1.4", "yohang/finite": "^1.2", "doctrine/orm": "^2.9", - "phpspec/prophecy-phpunit": "^2.0", + "phpspec/prophecy-phpunit": "^2.3", "phpstan/phpstan": "^1.0", "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-mockery": "^1.0" From 0a32aeecdb1266ec7792448e7003e09d72d225c1 Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Tue, 4 Mar 2025 16:33:05 +0100 Subject: [PATCH 04/13] update scrutinizer config --- .scrutinizer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c5ea315..965dc90 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,4 +1,5 @@ build: + image: default-bionic nodes: analysis: project_setup: From e21efd91d2fb01d59b36ba9eb8b9f84c124cd135 Mon Sep 17 00:00:00 2001 From: Mattia Basone Date: Tue, 4 Mar 2025 22:36:20 +0100 Subject: [PATCH 05/13] update revision for scrutinizer --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a072d5d..673d64f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -69,4 +69,4 @@ jobs: if: matrix.php.version == '8.1' && matrix.php.composer_flags == '--prefer-stable' uses: sudo-bot/action-scrutinizer@latest with: - cli-args: "--format=php-clover clover.xml" \ No newline at end of file + cli-args: "--format=php-clover clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" \ No newline at end of file From 31c8d5f9f79ab95a1001d82861e09aca491fb554 Mon Sep 17 00:00:00 2001 From: Mattia Basone Date: Tue, 4 Mar 2025 22:45:06 +0100 Subject: [PATCH 06/13] minimum version php 8.2 --- .github/workflows/php.yml | 6 +----- composer.json | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 673d64f..3413f0e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -15,16 +15,12 @@ jobs: strategy: matrix: php: - - version: '8.1' - composer_flags: --prefer-lowest - version: '8.2' composer_flags: --prefer-lowest - version: '8.3' composer_flags: --prefer-lowest - version: '8.4' composer_flags: --prefer-lowest - - version: '8.1' - composer_flags: --prefer-stable - version: '8.2' composer_flags: --prefer-stable - version: '8.3' @@ -66,7 +62,7 @@ jobs: run: ./bin/phpunit --coverage-text --coverage-clover clover.xml - name: Upload Scrutinizer coverage - if: matrix.php.version == '8.1' && matrix.php.composer_flags == '--prefer-stable' + if: matrix.php.version == '8.2' && matrix.php.composer_flags == '--prefer-stable' uses: sudo-bot/action-scrutinizer@latest with: cli-args: "--format=php-clover clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" \ No newline at end of file diff --git a/composer.json b/composer.json index 8c248ac..7f20bf2 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "A library to manage patch requests", "keywords": ["rest", "patch", "api", "symfony", "bundle"], "require": { - "php": "^8.1", + "php": "^8.2", "ext-json": "*", "symfony/property-access": "^6.0 || ^7.0", "symfony/http-foundation": "^6.0 || ^7.0", From b4f034e59923ff892118a3fb14d246c6de21d0f3 Mon Sep 17 00:00:00 2001 From: Mattia Basone Date: Tue, 4 Mar 2025 23:01:07 +0100 Subject: [PATCH 07/13] cleanup code --- .php-cs-fixer.dist.php | 1 - .../DependencyInjection/Configuration.php | 2 ++ .../PatchManagerCompilerPass.php | 4 +-- .../PatchManagerExtension.php | 3 ++ .../Bundle/PatchManagerBundle.php | 2 ++ .../RequestAdapter/RequestStackAdapter.php | 11 ++----- src/PatchManager/Event/PatchManagerEvent.php | 18 ++--------- src/PatchManager/Event/PatchManagerEvents.php | 2 ++ .../Exception/HandlerNotFoundException.php | 2 ++ .../Exception/InvalidJsonRequestContent.php | 5 ++-- .../Exception/MissingOperationNameRequest.php | 2 ++ .../Exception/MissingOperationRequest.php | 2 ++ .../NonExistentOperationException.php | 2 ++ .../Exception/PatchManagerException.php | 2 ++ src/PatchManager/Handler/FiniteHandler.php | 11 ++----- src/PatchManager/MatchedPatchOperation.php | 24 ++------------- src/PatchManager/OperationData.php | 18 ++++------- src/PatchManager/OperationMatcher.php | 2 ++ src/PatchManager/PatchManager.php | 30 ++++--------------- src/PatchManager/PatchOperationHandler.php | 14 ++------- src/PatchManager/Patchable.php | 2 ++ src/PatchManager/Request/Adapter.php | 5 ++-- src/PatchManager/Request/Operations.php | 20 ++++--------- 23 files changed, 57 insertions(+), 127 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 5869849..1c09f81 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -38,7 +38,6 @@ 'phpdoc_types_order' => ['null_adjustment' => 'always_first'], 'protected_to_private' => true, 'single_blank_line_at_eof' => true, - 'single_blank_line_before_namespace' => true, 'single_line_comment_style' => false, 'single_line_throw' => false, 'single_quote' => false, diff --git a/src/PatchManager/Bundle/DependencyInjection/Configuration.php b/src/PatchManager/Bundle/DependencyInjection/Configuration.php index 418d93c..1f51eb3 100644 --- a/src/PatchManager/Bundle/DependencyInjection/Configuration.php +++ b/src/PatchManager/Bundle/DependencyInjection/Configuration.php @@ -1,5 +1,7 @@ requestStack = $requestStack; } - /** - * @return null|string - */ public function getRequestBody(): ?string { $request = $this->requestStack->getCurrentRequest(); diff --git a/src/PatchManager/Event/PatchManagerEvent.php b/src/PatchManager/Event/PatchManagerEvent.php index 42f55df..26b08df 100644 --- a/src/PatchManager/Event/PatchManagerEvent.php +++ b/src/PatchManager/Event/PatchManagerEvent.php @@ -1,5 +1,7 @@ matchedPatchOperation = $matchedPatchOperation; $this->subject = $subject; } - /** - * @return MatchedPatchOperation - */ public function getMatchedPatchOperation(): MatchedPatchOperation { return $this->matchedPatchOperation; } - /** - * @return Patchable - */ public function getSubject(): Patchable { return $this->subject; diff --git a/src/PatchManager/Event/PatchManagerEvents.php b/src/PatchManager/Event/PatchManagerEvents.php index 8fe598e..8670602 100644 --- a/src/PatchManager/Event/PatchManagerEvents.php +++ b/src/PatchManager/Event/PatchManagerEvents.php @@ -1,5 +1,7 @@ factoryInterface = $factoryInterface; } - /** - * @param Patchable $subject - * @param OperationData $operationData - */ public function handle(Patchable $subject, OperationData $operationData): void { $sm = $this->factoryInterface->get($subject); @@ -39,8 +34,6 @@ public function handle(Patchable $subject, OperationData $operationData): void /** * the operation name - * - * @return string */ public function getName(): string { diff --git a/src/PatchManager/MatchedPatchOperation.php b/src/PatchManager/MatchedPatchOperation.php index 66c7bd2..8d9f0d6 100644 --- a/src/PatchManager/MatchedPatchOperation.php +++ b/src/PatchManager/MatchedPatchOperation.php @@ -1,36 +1,23 @@ operationData = $operationData; $this->handler = $handler; } - /** - * @param array $operationData - * @param PatchOperationHandler $handler - * @return MatchedPatchOperation - */ public static function create(array $operationData, PatchOperationHandler $handler): MatchedPatchOperation { return new self($operationData, $handler); @@ -47,8 +34,6 @@ public function matchFor(string $operationName): bool /** * call handle on the handler - * - * @param Patchable $patchable */ public function process(Patchable $patchable): void { @@ -59,10 +44,7 @@ public function process(Patchable $patchable): void $this->handler->handle($patchable, $options); } - /** - * @return string - */ - public function getOpName() + public function getOpName(): string { return $this->handler->getName(); } diff --git a/src/PatchManager/OperationData.php b/src/PatchManager/OperationData.php index aad7c46..d9b7726 100644 --- a/src/PatchManager/OperationData.php +++ b/src/PatchManager/OperationData.php @@ -1,5 +1,7 @@ get(Operations::OP_KEY_NAME); } - /** - * @return Map - */ public function getData(): Map { $operationData = new Map($this->elements); @@ -41,7 +32,10 @@ public function getData(): Map */ public function diffKeys(array $keys): Sequence { - $filtered = array_filter($this->getData()->keys(), fn ($key) => !in_array($key, $keys)); + $filtered = array_filter( + $this->getData()->keys(), + static fn ($key) => !in_array($key, $keys) + ); return new Sequence($filtered); } diff --git a/src/PatchManager/OperationMatcher.php b/src/PatchManager/OperationMatcher.php index 315eede..a961159 100644 --- a/src/PatchManager/OperationMatcher.php +++ b/src/PatchManager/OperationMatcher.php @@ -1,5 +1,7 @@ strictMode = $strictMode; } - /** - * @param EventDispatcherInterface $eventDispatcherInterface - */ public function setEventDispatcherInterface(EventDispatcherInterface $eventDispatcherInterface): void { $this->eventDispatcherInterface = $eventDispatcherInterface; @@ -59,10 +49,6 @@ public function handle($subject): void $this->handleSubject($subject, $matchedOperations); } - /** - * @param MatchedPatchOperation $matchedPatchOperation - * @param Patchable $subject - */ protected function doHandle(MatchedPatchOperation $matchedPatchOperation, Patchable $subject): void { $event = new PatchManagerEvent($matchedPatchOperation, $subject); @@ -74,10 +60,6 @@ protected function doHandle(MatchedPatchOperation $matchedPatchOperation, Patcha /** * dispatch events if the eventDispatcher is present - * - * @param PatchManagerEvent $event - * @param string $opName - * @param string $type */ protected function dispatchEvents(PatchManagerEvent $event, string $opName, string $type): void { @@ -110,14 +92,14 @@ private function getMatchedOperations($subject): Sequence } /** - * @param array|Patchable|\Traversable $subject a Patchable instance or a collection of instances - * @param Sequence $matchedOperations + * @param array|Patchable|\Traversable $subject a Patchable instance or a collection of instances * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest + * @throws Exception\InvalidJsonRequestContent */ private function handleSubject($subject, Sequence $matchedOperations): void { - if (is_array($subject) || $subject instanceof \Traversable) { + if (is_iterable($subject)) { $this->handleMany($subject); return; @@ -129,7 +111,7 @@ private function handleSubject($subject, Sequence $matchedOperations): void } /** - * @param array|\Traversable $subjects + * @param array|\Traversable $subjects * @throws Exception\InvalidJsonRequestContent * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest diff --git a/src/PatchManager/PatchOperationHandler.php b/src/PatchManager/PatchOperationHandler.php index 32fb809..bfaba31 100644 --- a/src/PatchManager/PatchOperationHandler.php +++ b/src/PatchManager/PatchOperationHandler.php @@ -1,5 +1,7 @@ adapter = $adapter; @@ -47,17 +43,15 @@ public function all(): Sequence } /** - * @param string $string * @throws InvalidJsonRequestContent * @throws MissingOperationRequest - * @return array */ private function parseJson(?string $string): array { try { - $json = json_decode($string, true, 512, JSON_THROW_ON_ERROR); + $json = json_decode($string, associative: true, flags: JSON_THROW_ON_ERROR); - //we need this control because json_decode('2', true, 512, JSON_THROW_ON_ERROR) returns a valid result: int(2) + // we need this control because json_decode('2', true, 512, JSON_THROW_ON_ERROR) returns a valid result: int(2) if (!is_array($json)) { throw new MissingOperationRequest(); } @@ -79,11 +73,7 @@ private function toSequence(array $operations): Sequence return new Sequence($operations); } - /** - * @param array $arr - * @return bool - */ - private function isAssociative($arr): bool + private function isAssociative(array $arr): bool { return array_keys($arr) !== range(0, count($arr) - 1); } From 4ebfc06fd6a09553fe1aa29d88ec3e35999a2139 Mon Sep 17 00:00:00 2001 From: Mattia Basone Date: Tue, 4 Mar 2025 23:05:00 +0100 Subject: [PATCH 08/13] properly handle null json --- src/PatchManager/Request/Operations.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PatchManager/Request/Operations.php b/src/PatchManager/Request/Operations.php index 6088023..6b24f1c 100644 --- a/src/PatchManager/Request/Operations.php +++ b/src/PatchManager/Request/Operations.php @@ -48,6 +48,10 @@ public function all(): Sequence */ private function parseJson(?string $string): array { + if (is_null($string)) { + throw new InvalidJsonRequestContent(); + } + try { $json = json_decode($string, associative: true, flags: JSON_THROW_ON_ERROR); From aeae04106ac25120e0da98f751507f3a20393b92 Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Wed, 5 Mar 2025 08:56:57 +0100 Subject: [PATCH 09/13] bump phpunit --- .gitignore | 1 + composer.json | 2 +- phpunit.xml.dist | 27 +++++++++++++----------- tests/PatchManager/OperationDataTest.php | 10 +++++---- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 00d0c60..bbec756 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ composer.lock /.coveralls.yml /clover.xml /coveralls-upload.json +/rector.php diff --git a/composer.json b/composer.json index 7f20bf2..fc52a2b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.70", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^11.5", "mockery/mockery": "^1.4", "yohang/finite": "^1.2", "doctrine/orm": "^2.9", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0b4db54..7118360 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,22 +1,25 @@ - - - + ./src src/*Bundle/Resources - src/DataFixtures diff --git a/tests/PatchManager/OperationDataTest.php b/tests/PatchManager/OperationDataTest.php index 8277bc1..214054c 100644 --- a/tests/PatchManager/OperationDataTest.php +++ b/tests/PatchManager/OperationDataTest.php @@ -1,9 +1,12 @@ 'data', 'test' => 1, 'test2' => '2']); $this->assertFalse($od->getData()->isEmpty()); - $this->assertInstanceOf('PhpCollection\Map', $od->getData()); $this->assertCount(2, $od->getData()); $this->assertContains('test', $od->getData()->keys()); $this->assertContains('test2', $od->getData()->keys()); @@ -44,17 +46,17 @@ public function testGetDataWithData(): void } /** - * @dataProvider diffKeysProvider * @param mixed $expected * @param mixed $requiredKeys */ - public function testDiffKeys($expected, $requiredKeys): void + #[DataProvider("diffKeysProvider")] + public function testDiffKeys(Sequence $expected, array $requiredKeys): void { $od = new OperationData(['op' => 'data', 'test' => 1, 'test2' => '2']); $this->assertEquals($expected, $od->diffKeys($requiredKeys)); } - public function diffKeysProvider(): array + public static function diffKeysProvider(): array { return [ [new Sequence(), ['test', 'test2']], From c96f98edb183383ccc2ff65561bbc5788375dc07 Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Wed, 5 Mar 2025 09:00:08 +0100 Subject: [PATCH 10/13] bump phpunit --- phpunit.xml.dist | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7118360..09f1813 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,7 @@ - + ./src src/*Bundle/Resources - + From 31e329aec7f290c6ac721d8d07729da8a2456f94 Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Wed, 5 Mar 2025 09:10:27 +0100 Subject: [PATCH 11/13] fix phpstan stuff --- phpstan.neon | 5 +---- src/PatchManager/OperationData.php | 3 +++ src/PatchManager/PatchManager.php | 6 +++--- tests/PatchManager/OperationDataTest.php | 4 ---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 04878e7..6c3d58c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,11 +6,8 @@ parameters: level: 6 #https://phpstan.org/user-guide/rule-levels paths: - src - - tests - checkGenericClassInNonGenericObjectType: false ignoreErrors: - '#no value type specified in iterable type#' - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)#' - - '#Call to an undefined method Prophecy\\Prophecy#' - '#Method Cypress\\PatchManager\\OperationMatcher::getUnmatchedOperations\(\) should return PhpCollection\\Sequence but returns PhpCollection\\AbstractSequence#' - - '#Property Cypress\\PatchManager\\Tests\\FakeObjects\\Subject(A|B)::\$a is never read, only written#' \ No newline at end of file + - '#Property Cypress\\PatchManager\\Exception\\InvalidJsonRequestContent::\$message has no type specified#' diff --git a/src/PatchManager/OperationData.php b/src/PatchManager/OperationData.php index d9b7726..f7c4593 100644 --- a/src/PatchManager/OperationData.php +++ b/src/PatchManager/OperationData.php @@ -11,6 +11,9 @@ class OperationData extends Map { + /** + * @return Option + */ public function getOp(): Option { return $this->get(Operations::OP_KEY_NAME); diff --git a/src/PatchManager/PatchManager.php b/src/PatchManager/PatchManager.php index c7cdd98..4a8ebcf 100644 --- a/src/PatchManager/PatchManager.php +++ b/src/PatchManager/PatchManager.php @@ -92,12 +92,12 @@ private function getMatchedOperations($subject): Sequence } /** - * @param array|Patchable|\Traversable $subject a Patchable instance or a collection of instances + * @param iterable|Patchable $subject a Patchable instance or a collection of instances * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest * @throws Exception\InvalidJsonRequestContent */ - private function handleSubject($subject, Sequence $matchedOperations): void + private function handleSubject(Patchable|iterable $subject, Sequence $matchedOperations): void { if (is_iterable($subject)) { $this->handleMany($subject); @@ -116,7 +116,7 @@ private function handleSubject($subject, Sequence $matchedOperations): void * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest */ - private function handleMany($subjects): void + private function handleMany(iterable $subjects): void { foreach ($subjects as $subject) { foreach ($this->operationMatcher->getMatchedOperations($subject) as $matchedPatchOperation) { diff --git a/tests/PatchManager/OperationDataTest.php b/tests/PatchManager/OperationDataTest.php index 214054c..17dd397 100644 --- a/tests/PatchManager/OperationDataTest.php +++ b/tests/PatchManager/OperationDataTest.php @@ -45,10 +45,6 @@ public function testGetDataWithData(): void $this->assertSame('2', $od->getData()->get('test2')->getOrElse(null)); } - /** - * @param mixed $expected - * @param mixed $requiredKeys - */ #[DataProvider("diffKeysProvider")] public function testDiffKeys(Sequence $expected, array $requiredKeys): void { From 3eb1c708ea36c58b5157ffa047265d4465871de9 Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Wed, 5 Mar 2025 09:57:59 +0100 Subject: [PATCH 12/13] update no_superfluous_phpdoc_tags cs fixer rule --- .php-cs-fixer.dist.php | 2 +- .../DependencyInjection/PatchManagerExtension.php | 9 --------- src/PatchManager/Handler/FiniteHandler.php | 8 -------- src/PatchManager/MatchedPatchOperation.php | 4 ---- src/PatchManager/OperationData.php | 4 ---- src/PatchManager/OperationMatcher.php | 14 -------------- src/PatchManager/PatchManager.php | 2 -- src/PatchManager/Request/Operations.php | 5 ----- .../PatchManagerCompilerPassTest.php | 4 ---- .../Handler/FakeObjects/DataDoctrineSubject.php | 1 - .../Handler/FakeObjects/DataSubject.php | 4 ---- .../Handler/FakeObjects/FiniteSubject.php | 5 ----- tests/PatchManager/Handler/FiniteHandlerTest.php | 6 ------ tests/PatchManager/OperationMatcherTest.php | 7 ------- tests/PatchManager/PatchManagerTest.php | 2 -- tests/PatchManager/PatchManagerTestCase.php | 4 ---- 16 files changed, 1 insertion(+), 80 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 1c09f81..a6f5de3 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -22,7 +22,7 @@ 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_after_function_name' => true, 'no_spaces_around_offset' => true, - 'no_superfluous_phpdoc_tags' => false, + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => false, 'allow_unused_params' => true], 'no_unused_imports' => true, 'no_useless_else' => true, 'no_whitespace_before_comma_in_array' => true, diff --git a/src/PatchManager/Bundle/DependencyInjection/PatchManagerExtension.php b/src/PatchManager/Bundle/DependencyInjection/PatchManagerExtension.php index f88c7a2..81ca184 100644 --- a/src/PatchManager/Bundle/DependencyInjection/PatchManagerExtension.php +++ b/src/PatchManager/Bundle/DependencyInjection/PatchManagerExtension.php @@ -37,11 +37,6 @@ public function load(array $configs, ContainerBuilder $container): void $this->handleGenericConfig($config, $container, $loaderHandlers); } - /** - * @param array $config - * @param ContainerBuilder $container - * @param Loader\XmlFileLoader $loaderHandlers - */ private function handleGenericConfig( array $config, ContainerBuilder $container, @@ -63,10 +58,6 @@ private function handleGenericConfig( $container->setParameter('patch_manager.strict_mode', $config['strict_mode']); } - /** - * @param Loader\XmlFileLoader $loaderHandlers - * @param ContainerBuilder $container - */ private function handleStateMachine(Loader\XmlFileLoader $loaderHandlers, ContainerBuilder $container): void { if (!interface_exists('Finite\Factory\FactoryInterface')) { diff --git a/src/PatchManager/Handler/FiniteHandler.php b/src/PatchManager/Handler/FiniteHandler.php index 7de19e9..4f32a82 100644 --- a/src/PatchManager/Handler/FiniteHandler.php +++ b/src/PatchManager/Handler/FiniteHandler.php @@ -14,9 +14,6 @@ class FiniteHandler implements PatchOperationHandler { private FactoryInterface $factoryInterface; - /** - * @param FactoryInterface $factoryInterface - */ public function __construct(FactoryInterface $factoryInterface) { $this->factoryInterface = $factoryInterface; @@ -44,8 +41,6 @@ public function getName(): string * use the OptionResolver instance to configure the required and optional fields that needs to be passed * with the request body. See http://symfony.com/doc/current/components/options_resolver.html to check all * possible options - * - * @param OptionsResolver $optionsResolver */ public function configureOptions(OptionsResolver $optionsResolver): void { @@ -57,9 +52,6 @@ public function configureOptions(OptionsResolver $optionsResolver): void /** * whether the handler is able to handle the given subject - * - * @param Patchable $subject - * @return bool */ public function canHandle(Patchable $subject): bool { diff --git a/src/PatchManager/MatchedPatchOperation.php b/src/PatchManager/MatchedPatchOperation.php index 8d9f0d6..9b029df 100644 --- a/src/PatchManager/MatchedPatchOperation.php +++ b/src/PatchManager/MatchedPatchOperation.php @@ -23,10 +23,6 @@ public static function create(array $operationData, PatchOperationHandler $handl return new self($operationData, $handler); } - /** - * @param string $operationName - * @return bool - */ public function matchFor(string $operationName): bool { return $operationName === $this->handler->getName(); diff --git a/src/PatchManager/OperationData.php b/src/PatchManager/OperationData.php index f7c4593..0778aff 100644 --- a/src/PatchManager/OperationData.php +++ b/src/PatchManager/OperationData.php @@ -29,10 +29,6 @@ public function getData(): Map return $operationData; } - /** - * @param array $keys - * @return Sequence - */ public function diffKeys(array $keys): Sequence { $filtered = array_filter( diff --git a/src/PatchManager/OperationMatcher.php b/src/PatchManager/OperationMatcher.php index a961159..da618ed 100644 --- a/src/PatchManager/OperationMatcher.php +++ b/src/PatchManager/OperationMatcher.php @@ -12,28 +12,16 @@ */ class OperationMatcher { - /** - * @var Sequence - */ private Sequence $handlers; - /** - * @var Operations - */ private Operations $operations; - /** - * @param Operations $operations - */ public function __construct(Operations $operations) { $this->handlers = new Sequence(); $this->operations = $operations; } - /** - * @param PatchOperationHandler $handler - */ public function addHandler(PatchOperationHandler $handler): void { $this->handlers->add($handler); @@ -45,7 +33,6 @@ public function addHandler(PatchOperationHandler $handler): void * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest * @throws Exception\InvalidJsonRequestContent - * @return Sequence */ public function getMatchedOperations($subject): Sequence { @@ -75,7 +62,6 @@ function (Sequence $matchedOperations, array $operationData) use ($handlers, $su * @throws Exception\InvalidJsonRequestContent * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest - * @return Sequence */ public function getUnmatchedOperations($subject): Sequence { diff --git a/src/PatchManager/PatchManager.php b/src/PatchManager/PatchManager.php index 4a8ebcf..507ef1f 100644 --- a/src/PatchManager/PatchManager.php +++ b/src/PatchManager/PatchManager.php @@ -22,7 +22,6 @@ class PatchManager private bool $strictMode; /** - * @param OperationMatcher $operationMatcher * @param bool $strictMode if true throws an error if no handler is found */ public function __construct(OperationMatcher $operationMatcher, bool $strictMode = false) @@ -79,7 +78,6 @@ protected function dispatchEvents(PatchManagerEvent $event, string $opName, stri * @throws Exception\MissingOperationNameRequest * @throws Exception\MissingOperationRequest * @throws HandlerNotFoundException - * @return Sequence */ private function getMatchedOperations($subject): Sequence { diff --git a/src/PatchManager/Request/Operations.php b/src/PatchManager/Request/Operations.php index 6b24f1c..ef1646f 100644 --- a/src/PatchManager/Request/Operations.php +++ b/src/PatchManager/Request/Operations.php @@ -24,7 +24,6 @@ public function __construct(Adapter $adapter) * @throws InvalidJsonRequestContent * @throws MissingOperationNameRequest * @throws MissingOperationRequest - * @return Sequence */ public function all(): Sequence { @@ -66,10 +65,6 @@ private function parseJson(?string $string): array } } - /** - * @param array $operations - * @return Sequence - */ private function toSequence(array $operations): Sequence { $operations = $this->isAssociative($operations) ? [$operations] : $operations; diff --git a/tests/PatchManager/Bundle/DependencyInjection/PatchManagerCompilerPassTest.php b/tests/PatchManager/Bundle/DependencyInjection/PatchManagerCompilerPassTest.php index 3282b49..931b8de 100644 --- a/tests/PatchManager/Bundle/DependencyInjection/PatchManagerCompilerPassTest.php +++ b/tests/PatchManager/Bundle/DependencyInjection/PatchManagerCompilerPassTest.php @@ -10,12 +10,8 @@ class PatchManagerCompilerPassTest extends PatchManagerTestCase { - /** @var ObjectProphecy */ private ObjectProphecy $cb; - /** - * @var PatchManagerCompilerPass - */ private PatchManagerCompilerPass $compilerPass; public function setUp(): void diff --git a/tests/PatchManager/Handler/FakeObjects/DataDoctrineSubject.php b/tests/PatchManager/Handler/FakeObjects/DataDoctrineSubject.php index bee6cfb..d1c2577 100644 --- a/tests/PatchManager/Handler/FakeObjects/DataDoctrineSubject.php +++ b/tests/PatchManager/Handler/FakeObjects/DataDoctrineSubject.php @@ -18,7 +18,6 @@ class DataDoctrineSubject implements Patchable /** * @param string $method - * @param array $args */ public function __call($method, array $args): void { diff --git a/tests/PatchManager/Handler/FakeObjects/DataSubject.php b/tests/PatchManager/Handler/FakeObjects/DataSubject.php index d2ad256..a1677ca 100644 --- a/tests/PatchManager/Handler/FakeObjects/DataSubject.php +++ b/tests/PatchManager/Handler/FakeObjects/DataSubject.php @@ -16,10 +16,6 @@ class DataSubject implements Patchable */ private $b; - /** - * @param string $method - * @param array $args - */ public function __call(string $method, array $args): void { if ('setB' === $method) { diff --git a/tests/PatchManager/Handler/FakeObjects/FiniteSubject.php b/tests/PatchManager/Handler/FakeObjects/FiniteSubject.php index 81200e6..b041ccb 100644 --- a/tests/PatchManager/Handler/FakeObjects/FiniteSubject.php +++ b/tests/PatchManager/Handler/FakeObjects/FiniteSubject.php @@ -7,9 +7,6 @@ class FiniteSubject implements StatefulInterface, Patchable { - /** - * @var string - */ private string $state; public function __construct() @@ -19,8 +16,6 @@ public function __construct() /** * Sets the object state - * - * @return string */ public function getFiniteState(): string { diff --git a/tests/PatchManager/Handler/FiniteHandlerTest.php b/tests/PatchManager/Handler/FiniteHandlerTest.php index d2a1ac8..1f5debd 100644 --- a/tests/PatchManager/Handler/FiniteHandlerTest.php +++ b/tests/PatchManager/Handler/FiniteHandlerTest.php @@ -15,14 +15,8 @@ class FiniteHandlerTest extends PatchManagerTestCase { - /** - * @var FiniteHandler - */ private FiniteHandler $handler; - /** - * @var StateMachine - */ private StateMachine $stateMachine; public function setUp(): void diff --git a/tests/PatchManager/OperationMatcherTest.php b/tests/PatchManager/OperationMatcherTest.php index 94794f2..ab897fd 100644 --- a/tests/PatchManager/OperationMatcherTest.php +++ b/tests/PatchManager/OperationMatcherTest.php @@ -11,14 +11,8 @@ class OperationMatcherTest extends PatchManagerTestCase { - /** - * @var OperationMatcher - */ private OperationMatcher $matcher; - /** - * @var Sequence - */ private Sequence $ops; public function setUp(): void @@ -100,7 +94,6 @@ public function testHandlerThatRespondsFalseToCanHandle(): void /** * @param string $name - * @return \Closure */ private function handlerNameMatcher($name): \Closure { diff --git a/tests/PatchManager/PatchManagerTest.php b/tests/PatchManager/PatchManagerTest.php index fec32de..6680e23 100644 --- a/tests/PatchManager/PatchManagerTest.php +++ b/tests/PatchManager/PatchManagerTest.php @@ -4,7 +4,6 @@ use Cypress\PatchManager\Event\PatchManagerEvent; use Cypress\PatchManager\Exception\HandlerNotFoundException; -use Cypress\PatchManager\Handler\DataHandler; use Cypress\PatchManager\MatchedPatchOperation; use Cypress\PatchManager\OperationMatcher; use Cypress\PatchManager\PatchManager; @@ -12,7 +11,6 @@ use PhpCollection\Sequence; use Prophecy\Argument; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; class PatchManagerTest extends PatchManagerTestCase { diff --git a/tests/PatchManager/PatchManagerTestCase.php b/tests/PatchManager/PatchManagerTestCase.php index 18aaa5a..3a70452 100644 --- a/tests/PatchManager/PatchManagerTestCase.php +++ b/tests/PatchManager/PatchManagerTestCase.php @@ -21,9 +21,6 @@ protected function tearDown(): void } /** - * @param null|string $name - * @param bool $canHandle - * * @return \Prophecy\Prophecy\ObjectProphecy */ protected function mockHandler(?string $name, bool $canHandle = true) @@ -41,7 +38,6 @@ protected function mockHandler(?string $name, bool $canHandle = true) /** * @param null $handlerName - * @return MatchedPatchOperation */ protected function getMatchedPatchOperation($handlerName = null): MatchedPatchOperation { From 418b8015295cb9829d0613df67d8b8cc0c5bf23b Mon Sep 17 00:00:00 2001 From: mattiabasone Date: Wed, 5 Mar 2025 10:16:47 +0100 Subject: [PATCH 13/13] update collection package --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fc52a2b..3fc7382 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "symfony/http-kernel": "^6.0 || ^7.0", "symfony/config": "^6.0 || ^7.0", "symfony/event-dispatcher": "^6.0 || ^7.0", - "mattiabasone/phpcollection": "^0.7.0" + "mattiabasone/phpcollection": "^1.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.70",