diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index d264168..408e66b 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -12,6 +12,8 @@ jobs: matrix: php-version: - "7.4" + - "8.0" + - "8.1" deps: - "normal" include: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index eb26563..8b0c53e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -12,6 +12,8 @@ jobs: matrix: php-version: - "7.4" + - "8.0" + - "8.1" steps: - name: "Checkout" diff --git a/.gitignore b/.gitignore index 4d30792..da6a067 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /vendor/ -\.php_cs\.cache +*.cache .phpunit.result.cache composer.lock /.idea diff --git a/.php_cs b/.php-cs-fixer.php similarity index 53% rename from .php_cs rename to .php-cs-fixer.php index 3362983..c51474e 100755 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -1,6 +1,10 @@ getFinder() ->exclude( [ 'vendor', @@ -8,7 +12,8 @@ ) ->in(__DIR__); -return PhpCsFixer\Config::create() +return $config + ->registerCustomFixers([]) ->setRules( [ '@Symfony' => true, @@ -21,6 +26,15 @@ 'phpdoc_var_without_name' => false, 'phpdoc_to_comment' => false, 'single_line_throw' => false, + 'modernize_types_casting' => true, + 'function_declaration' => false, + 'ordered_imports' => [ + 'imports_order' => [ + 'class', + 'function', + 'const', + ], + 'sort_algorithm' => 'alpha', + ], ] - ) - ->setFinder($finder); + ); diff --git a/composer.json b/composer.json index 6031cb4..823f1d6 100755 --- a/composer.json +++ b/composer.json @@ -1,48 +1,51 @@ { - "name": "answear/wide-eyes-bundle", - "description": "API Client for WideEyes.", - "type": "symfony-bundle", - "license": "MIT", - "require": { - "php": ">=7.4", - "ext-json": "*", - "webmozart/assert": "^1.3", - "guzzlehttp/guzzle": "^6.0", - "symfony/http-kernel": "^4.4|^5.0" - }, - "require-dev": { - "roave/security-advisories": "dev-master", - "phpunit/phpunit": "^8.4", - "symfony/phpunit-bridge": "^5.0", - "phpro/grumphp": "^0.20", - "friendsofphp/php-cs-fixer": "^2.16", - "phpstan/phpstan": "^0.12.32", - "phpstan/phpstan-webmozart-assert": "^0.12.2" - }, - "autoload": { - "psr-4": { - "Answear\\WideEyesBundle\\": "src/" + "name": "answear/wide-eyes-bundle", + "description": "API Client for WideEyes.", + "type": "symfony-bundle", + "license": "MIT", + "require": { + "php": ">=7.4|^8.0", + "ext-json": "*", + "webmozart/assert": "^1.3", + "guzzlehttp/guzzle": "^6.0|^7.0", + "symfony/http-kernel": "^5.4|^6.0" + }, + "require-dev": { + "roave/security-advisories": "dev-master", + "phpunit/phpunit": "^9.5", + "symfony/phpunit-bridge": "6.1.*", + "phpro/grumphp": "^1.5.0", + "friendsofphp/php-cs-fixer": "^3.4", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-webmozart-assert": "^1.0" + }, + "autoload": { + "psr-4": { + "Answear\\WideEyesBundle\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Answear\\WideEyesBundle\\Tests\\": "tests/" + } + }, + "scripts": { + "post-install-cmd": [ + "GrumPHP\\Composer\\DevelopmentIntegrator::integrate" + ], + "post-update-cmd": [ + "GrumPHP\\Composer\\DevelopmentIntegrator::integrate" + ] + }, + "extra": { + "grumphp": { + "config-default-path": "grumphp.yaml" + } + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "phpro/grumphp": true + } } - }, - "autoload-dev": { - "psr-4": { - "Answear\\WideEyesBundle\\Tests\\": "tests/" - } - }, - "scripts": { - "post-install-cmd": [ - "GrumPHP\\Composer\\DevelopmentIntegrator::integrate" - ], - "post-update-cmd": [ - "GrumPHP\\Composer\\DevelopmentIntegrator::integrate" - ] - }, - "extra": { - "grumphp": { - "config-default-path": "grumphp.yaml" - } - }, - "config": { - "sort-packages": true - } } diff --git a/grumphp.yaml b/grumphp.yaml index 759f2b3..3808677 100755 --- a/grumphp.yaml +++ b/grumphp.yaml @@ -18,7 +18,7 @@ grumphp: phpcsfixer: allow_risky: true cache_file: ~ - config: './.php_cs' + config: './.php-cs-fixer.php' using_cache: true verbose: true phpstan: diff --git a/tests/Unit/Response/DetectAndFeaturesResponseTest.php b/tests/Unit/Response/DetectAndFeaturesResponseTest.php index 34688d2..893affe 100644 --- a/tests/Unit/Response/DetectAndFeaturesResponseTest.php +++ b/tests/Unit/Response/DetectAndFeaturesResponseTest.php @@ -114,7 +114,7 @@ public function malformedResponseWithNotCompleteDetections(): void ]; $this->expectException(MalformedResponse::class); - $this->expectExceptionMessage('Undefined index: y1'); + $this->expectErrorMessageMatches('#^Undefined#'); DetectAndFeaturesResponse::fromArray($responseData); } diff --git a/tests/Unit/Service/SearchByImageClientDetectAndFeatureTest.php b/tests/Unit/Service/SearchByImageClientDetectAndFeatureTest.php index d5c54f5..5e21f38 100644 --- a/tests/Unit/Service/SearchByImageClientDetectAndFeatureTest.php +++ b/tests/Unit/Service/SearchByImageClientDetectAndFeatureTest.php @@ -63,7 +63,7 @@ public function responseWithWrongPropertiesInDetections(): void $this->guzzleHandler->append(new Response(200, [], $this->prepareNotProperResponse())); $this->expectException(MalformedResponse::class); - $this->expectExceptionMessage('Undefined index: featureId'); + $this->expectErrorMessageMatches('#^Undefined#'); $this->client->detectAndFeatures(self::IMAGE_PATH); } diff --git a/tests/Unit/ValueObject/BoundingBoxTest.php b/tests/Unit/ValueObject/BoundingBoxTest.php index 65cd116..61dc19f 100644 --- a/tests/Unit/ValueObject/BoundingBoxTest.php +++ b/tests/Unit/ValueObject/BoundingBoxTest.php @@ -40,7 +40,7 @@ public function throwsErrorWhenCreatingFromArrayNotFindProperties(): void ]; $this->expectError(); - $this->expectErrorMessageMatches('#^Undefined index#'); + $this->expectErrorMessageMatches('#^Undefined#'); BoundingBox::fromArray($bbox); } diff --git a/tests/Unit/ValueObject/DetectionTest.php b/tests/Unit/ValueObject/DetectionTest.php index 68b15e5..609e290 100644 --- a/tests/Unit/ValueObject/DetectionTest.php +++ b/tests/Unit/ValueObject/DetectionTest.php @@ -97,7 +97,7 @@ public function throwsErrorWhenCreatingFromArrayNotFindProperties(): void ]; $this->expectError(); - $this->expectErrorMessageMatches('#^Undefined index#'); + $this->expectErrorMessageMatches('#^Undefined#'); Detection::fromArray($detection); } diff --git a/tests/Unit/ValueObject/PointTest.php b/tests/Unit/ValueObject/PointTest.php index 273c18f..6f8f63e 100644 --- a/tests/Unit/ValueObject/PointTest.php +++ b/tests/Unit/ValueObject/PointTest.php @@ -35,7 +35,7 @@ public function throwsErrorWhenCreatingFromArrayNotFindProperties(): void ]; $this->expectError(); - $this->expectErrorMessageMatches('#^Undefined index#'); + $this->expectErrorMessageMatches('#^Undefined#'); Point::fromArray($point); }