From fb47db2ec8b601f64f382926fea7630b14617147 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:08:11 -0300 Subject: [PATCH 1/8] chore: update dependencies and php version --- composer.json | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 7b1bdc7..4f64319 100644 --- a/composer.json +++ b/composer.json @@ -5,13 +5,50 @@ "type": "library", "license": "BSD-3-Clause", "require": { - "php": ">=7.2", - "ramsey/uuid": "^3.8|^4.0", + "php": "^8.1", + "ramsey/uuid": "^4.5", "doctrine/inflector": "^2.0" }, "require-dev": { - "phpunit/phpunit": ">=6.0", - "friendsofphp/php-cs-fixer": "^2.4" + "friendsofphp/php-cs-fixer": "^3.11", + "michaelmoussa/php-coverage-checker": "^1.1", + "phpunit/phpunit": "^9.5", + "phpspec/prophecy": "^1.15", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/phpstan": "^0.12" + }, + "scripts": { + "lint": [ + "php-cs-fixer fix --ansi --verbose --show-progress=dots" + ], + "lint:check": [ + "@lint --dry-run" + ], + "test:base": [ + "php -d pcov.enabled=1 vendor/bin/phpunit --color=always" + ], + "test": [ + "@test:base --log-junit build/junit.xml --coverage-xml build/coverage-xml --coverage-clover build/coverage-clover.xml" + ], + "test:with-html-coverage": [ + "@test:base --coverage-html build/coverage-html" + ], + "test:coverage-checker": [ + "php-coverage-checker build/coverage-clover.xml 92;" + ], + "test:check": [ + "if [ -f build/coverage-clover.xml ]; then rm build/coverage-clover.xml; echo '>>> REMOVED OLD CLOVER.XML BUILD FILE!'; fi; # comment trick to allow composer params :D", + "@test", + "@test:coverage-checker" + ], + "check": [ + "@lint:check", + "@test:check", + "@static-analysis" + ], + "static-analysis": [ + "phpstan analyse --ansi --memory-limit=-1" + ] }, "autoload": { "psr-4": { From 72df759d5216caeca0190a57a3a392da02a4544c Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:08:25 -0300 Subject: [PATCH 2/8] chore: update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 633b317..7b0e735 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ composer.phar composer.lock phpunit.xml cache.properties -.php_cs.cache +.php-cs-fixer.cache .phpunit.result.cache .idea/ +/data/cache/* From dc08549a99763a9e1965b0bcd8e06c116cf94ffd Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:08:42 -0300 Subject: [PATCH 3/8] test: update phpunit config --- phpunit.xml.dist | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4c1a2fe..135528d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,6 @@ - - - - ./tests - - - - - ./src - - src/Input/Constraint/ConstraintInterface.php - src/Input/Transformer/TransformerInterface.php - src/Input/InputTrait.php - - - + + + ./src + + + src/Input/Constraint/ConstraintInterface.php + src/Input/Transformer/TransformerInterface.php + src/Input/InputTrait.php + + + + + ./tests + + From 572422d02dbb46cabce52bc5a83d9c5a6040d7b3 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:09:33 -0300 Subject: [PATCH 4/8] style: update php-cs-fixer config --- .php_cs => .php-cs-fixer.dist.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename .php_cs => .php-cs-fixer.dist.php (85%) diff --git a/.php_cs b/.php-cs-fixer.dist.php similarity index 85% rename from .php_cs rename to .php-cs-fixer.dist.php index 9dc5b29..3a865f0 100644 --- a/.php_cs +++ b/.php-cs-fixer.dist.php @@ -4,7 +4,7 @@ ->in(__DIR__ . '/src') ->in(__DIR__ . '/tests'); -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setRules([ '@Symfony' => true, '@PHP71Migration:risky' => true, @@ -15,12 +15,12 @@ 'concat_space' => ['spacing' => 'one'], 'declare_strict_types' => true, 'increment_style' => ['style' => 'post'], - 'is_null' => ['use_yoda_style' => false], + 'is_null' => true, 'list_syntax' => ['syntax' => 'short'], - 'method_argument_space' => ['ensure_fully_multiline' => true], + 'method_argument_space' => true, 'method_chaining_indentation' => true, 'modernize_types_casting' => true, - 'no_multiline_whitespace_before_semicolons' => true, + 'multiline_whitespace_before_semicolons' => false, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => true, 'no_useless_else' => true, From 901fc9b794b8e66368f021bbe82cb94cc9c693fe Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:10:22 -0300 Subject: [PATCH 5/8] style: fix lints --- src/Constraint/GuidValue.php | 2 +- src/Constraint/UuidValue.php | 2 +- src/Transformer/UuidTransformer.php | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Constraint/GuidValue.php b/src/Constraint/GuidValue.php index 838e49d..543d7fe 100644 --- a/src/Constraint/GuidValue.php +++ b/src/Constraint/GuidValue.php @@ -6,7 +6,7 @@ class GuidValue extends Constraint { - const ERROR_MESSAGE = 'Invalid GUID format'; + public const ERROR_MESSAGE = 'Invalid GUID format'; public function __construct(string $errorMessage = null) { diff --git a/src/Constraint/UuidValue.php b/src/Constraint/UuidValue.php index 5c6dddd..6916d34 100644 --- a/src/Constraint/UuidValue.php +++ b/src/Constraint/UuidValue.php @@ -6,5 +6,5 @@ class UuidValue extends GuidValue { - const ERROR_MESSAGE = 'Invalid UUID format'; + public const ERROR_MESSAGE = 'Invalid UUID format'; } diff --git a/src/Transformer/UuidTransformer.php b/src/Transformer/UuidTransformer.php index 399e9bb..761a5de 100644 --- a/src/Transformer/UuidTransformer.php +++ b/src/Transformer/UuidTransformer.php @@ -4,7 +4,6 @@ namespace Linio\Component\Input\Transformer; -use Exception; use Linio\Component\Input\Exception\TransformationException; use Ramsey\Uuid\Uuid; @@ -14,7 +13,7 @@ public function transform($value) { try { return Uuid::fromString($value); - } catch (Exception $exception) { + } catch (\Exception $exception) { throw new TransformationException($exception->getMessage()); } } From 19699df788bdbbb8d04afa942fa040fd69d61a4e Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:10:46 -0300 Subject: [PATCH 6/8] feat: add phpstan config --- phpstan.neon.dist | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 phpstan.neon.dist diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..cf37992 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +parameters: + level: 0 # start increasing the level + paths: + - src + - tests + tmpDir: data/cache/phpstan + reportUnmatchedIgnoredErrors: false From 54a8bb99a0b322dd5c869f17201c7d2b48d7cfff Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 29 Nov 2022 17:11:02 -0300 Subject: [PATCH 7/8] test: add TestCase class --- tests/Constraint/DateRangeTest.php | 2 +- tests/Constraint/DateTimeTest.php | 2 +- tests/Constraint/EmailTest.php | 2 +- tests/Constraint/EnumTest.php | 2 +- tests/Constraint/GuidValueTest.php | 2 +- tests/Constraint/NotNullTest.php | 2 +- tests/Constraint/PatternTest.php | 2 +- tests/Constraint/RangeTest.php | 2 +- tests/Constraint/StringSizeTest.php | 2 +- tests/Constraint/TypeTest.php | 2 +- tests/Constraint/UrlTest.php | 2 +- tests/Constraint/UuidValueTest.php | 2 +- tests/InputHandlerTest.php | 1 - tests/Instantiator/ConstructInstantiatorTest.php | 2 +- tests/Instantiator/PropertyInstantiatorTest.php | 2 +- tests/Instantiator/ReflectionInstantiatorTest.php | 2 +- tests/Instantiator/SetInstantiatorTest.php | 2 +- tests/Node/BaseNodeTest.php | 2 +- tests/Node/CollectionNodeTest.php | 2 +- tests/Node/IntNodeTest.php | 2 +- tests/Node/ObjectNodeTest.php | 2 +- tests/Node/ScalarCollectionNodeTest.php | 2 +- tests/SchemaBuilderTest.php | 2 -- tests/TestCase.php | 13 +++++++++++++ tests/Transformer/DateTimeTransformerTest.php | 2 +- tests/Transformer/UuidTransformerTest.php | 2 +- tests/TypeHandlerTest.php | 1 - 27 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 tests/TestCase.php diff --git a/tests/Constraint/DateRangeTest.php b/tests/Constraint/DateRangeTest.php index faaddad..8a7639f 100644 --- a/tests/Constraint/DateRangeTest.php +++ b/tests/Constraint/DateRangeTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class DateRangeTest extends TestCase { diff --git a/tests/Constraint/DateTimeTest.php b/tests/Constraint/DateTimeTest.php index 2f0ab87..4c4fa97 100644 --- a/tests/Constraint/DateTimeTest.php +++ b/tests/Constraint/DateTimeTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class DateTimeTest extends TestCase { diff --git a/tests/Constraint/EmailTest.php b/tests/Constraint/EmailTest.php index 24868c1..32692da 100644 --- a/tests/Constraint/EmailTest.php +++ b/tests/Constraint/EmailTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class EmailTest extends TestCase { diff --git a/tests/Constraint/EnumTest.php b/tests/Constraint/EnumTest.php index 62562f7..3571810 100644 --- a/tests/Constraint/EnumTest.php +++ b/tests/Constraint/EnumTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class EnumTest extends TestCase { diff --git a/tests/Constraint/GuidValueTest.php b/tests/Constraint/GuidValueTest.php index 1320354..94c2c63 100644 --- a/tests/Constraint/GuidValueTest.php +++ b/tests/Constraint/GuidValueTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class GuidValueTest extends TestCase { diff --git a/tests/Constraint/NotNullTest.php b/tests/Constraint/NotNullTest.php index 908108d..1cbc1b8 100644 --- a/tests/Constraint/NotNullTest.php +++ b/tests/Constraint/NotNullTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class NotNullTest extends TestCase { diff --git a/tests/Constraint/PatternTest.php b/tests/Constraint/PatternTest.php index 0900bd3..a84375d 100644 --- a/tests/Constraint/PatternTest.php +++ b/tests/Constraint/PatternTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class PatternTest extends TestCase { diff --git a/tests/Constraint/RangeTest.php b/tests/Constraint/RangeTest.php index 6fb20f9..1122d04 100644 --- a/tests/Constraint/RangeTest.php +++ b/tests/Constraint/RangeTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class RangeTest extends TestCase { diff --git a/tests/Constraint/StringSizeTest.php b/tests/Constraint/StringSizeTest.php index e9f3128..08a5317 100644 --- a/tests/Constraint/StringSizeTest.php +++ b/tests/Constraint/StringSizeTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class StringSizeTest extends TestCase { diff --git a/tests/Constraint/TypeTest.php b/tests/Constraint/TypeTest.php index cbba134..0b6dba7 100644 --- a/tests/Constraint/TypeTest.php +++ b/tests/Constraint/TypeTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class TypeTest extends TestCase { diff --git a/tests/Constraint/UrlTest.php b/tests/Constraint/UrlTest.php index 75294a6..639dc6b 100644 --- a/tests/Constraint/UrlTest.php +++ b/tests/Constraint/UrlTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class UrlTest extends TestCase { diff --git a/tests/Constraint/UuidValueTest.php b/tests/Constraint/UuidValueTest.php index 50b325c..f74a5d9 100644 --- a/tests/Constraint/UuidValueTest.php +++ b/tests/Constraint/UuidValueTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Constraint; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class UuidValueTest extends TestCase { diff --git a/tests/InputHandlerTest.php b/tests/InputHandlerTest.php index 8c1f1fb..68ae395 100644 --- a/tests/InputHandlerTest.php +++ b/tests/InputHandlerTest.php @@ -10,7 +10,6 @@ use Linio\Component\Input\Constraint\StringSize; use Linio\Component\Input\Instantiator\InstantiatorInterface; use Linio\Component\Input\Instantiator\PropertyInstantiator; -use PHPUnit\Framework\TestCase; class TestUser { diff --git a/tests/Instantiator/ConstructInstantiatorTest.php b/tests/Instantiator/ConstructInstantiatorTest.php index 764eb0c..7e2a3fe 100644 --- a/tests/Instantiator/ConstructInstantiatorTest.php +++ b/tests/Instantiator/ConstructInstantiatorTest.php @@ -5,7 +5,7 @@ namespace Linio\Component\Input\Instantiator; use Linio\Component\Input\Constraint\Enum; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class ConstructInstantiatorTest extends TestCase { diff --git a/tests/Instantiator/PropertyInstantiatorTest.php b/tests/Instantiator/PropertyInstantiatorTest.php index 79ed538..2f83e35 100644 --- a/tests/Instantiator/PropertyInstantiatorTest.php +++ b/tests/Instantiator/PropertyInstantiatorTest.php @@ -4,8 +4,8 @@ namespace Linio\Component\Input\Instantiator; +use Linio\Component\Input\TestCase; use Linio\Component\Input\TestUser; -use PHPUnit\Framework\TestCase; class PropertyInstantiatorTest extends TestCase { diff --git a/tests/Instantiator/ReflectionInstantiatorTest.php b/tests/Instantiator/ReflectionInstantiatorTest.php index 600217f..0949fd7 100644 --- a/tests/Instantiator/ReflectionInstantiatorTest.php +++ b/tests/Instantiator/ReflectionInstantiatorTest.php @@ -4,8 +4,8 @@ namespace Linio\Component\Input\Instantiator; +use Linio\Component\Input\TestCase; use Linio\Component\Input\TestUser; -use PHPUnit\Framework\TestCase; class ReflectionInstantiatorTest extends TestCase { diff --git a/tests/Instantiator/SetInstantiatorTest.php b/tests/Instantiator/SetInstantiatorTest.php index 8a8ff61..78d3541 100644 --- a/tests/Instantiator/SetInstantiatorTest.php +++ b/tests/Instantiator/SetInstantiatorTest.php @@ -4,8 +4,8 @@ namespace Linio\Component\Input\Instantiator; +use Linio\Component\Input\TestCase; use Linio\Component\Input\TestUser; -use PHPUnit\Framework\TestCase; class SetInstantiatorTest extends TestCase { diff --git a/tests/Node/BaseNodeTest.php b/tests/Node/BaseNodeTest.php index b238e4e..be0c537 100644 --- a/tests/Node/BaseNodeTest.php +++ b/tests/Node/BaseNodeTest.php @@ -8,9 +8,9 @@ use Linio\Component\Input\Constraint\Range; use Linio\Component\Input\Constraint\StringSize; use Linio\Component\Input\Exception\InvalidConstraintException; +use Linio\Component\Input\TestCase; use Linio\Component\Input\Transformer\DateTimeTransformer; use Linio\Component\Input\TypeHandler; -use PHPUnit\Framework\TestCase; class BaseNodeTest extends TestCase { diff --git a/tests/Node/CollectionNodeTest.php b/tests/Node/CollectionNodeTest.php index 911e255..25871d2 100644 --- a/tests/Node/CollectionNodeTest.php +++ b/tests/Node/CollectionNodeTest.php @@ -7,8 +7,8 @@ use Linio\Component\Input\Constraint\ConstraintInterface; use Linio\Component\Input\Exception\InvalidConstraintException; use Linio\Component\Input\Instantiator\InstantiatorInterface; +use Linio\Component\Input\TestCase; use Linio\Component\Input\TypeHandler; -use PHPUnit\Framework\TestCase; class CollectionNodeTest extends TestCase { diff --git a/tests/Node/IntNodeTest.php b/tests/Node/IntNodeTest.php index 83fd9ad..76ca92d 100644 --- a/tests/Node/IntNodeTest.php +++ b/tests/Node/IntNodeTest.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Node; -use PHPUnit\Framework\TestCase; +use Linio\Component\Input\TestCase; class IntNodeTest extends TestCase { diff --git a/tests/Node/ObjectNodeTest.php b/tests/Node/ObjectNodeTest.php index f8b6542..eaa2f94 100644 --- a/tests/Node/ObjectNodeTest.php +++ b/tests/Node/ObjectNodeTest.php @@ -7,8 +7,8 @@ use Linio\Component\Input\Constraint\ConstraintInterface; use Linio\Component\Input\Exception\InvalidConstraintException; use Linio\Component\Input\Instantiator\InstantiatorInterface; +use Linio\Component\Input\TestCase; use Linio\Component\Input\TypeHandler; -use PHPUnit\Framework\TestCase; class ObjectNodeTest extends TestCase { diff --git a/tests/Node/ScalarCollectionNodeTest.php b/tests/Node/ScalarCollectionNodeTest.php index 5cef234..d42034d 100644 --- a/tests/Node/ScalarCollectionNodeTest.php +++ b/tests/Node/ScalarCollectionNodeTest.php @@ -6,8 +6,8 @@ use Linio\Component\Input\Constraint\ConstraintInterface; use Linio\Component\Input\Exception\InvalidConstraintException; +use Linio\Component\Input\TestCase; use Linio\Component\Input\TypeHandler; -use PHPUnit\Framework\TestCase; class ScalarCollectionNodeTest extends TestCase { diff --git a/tests/SchemaBuilderTest.php b/tests/SchemaBuilderTest.php index 6c616e0..85061dc 100644 --- a/tests/SchemaBuilderTest.php +++ b/tests/SchemaBuilderTest.php @@ -4,8 +4,6 @@ namespace Linio\Component\Input; -use PHPUnit\Framework\TestCase; - class SchemaTestInputHandler extends InputHandler { public function define(): void diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..73d00ba --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,13 @@ + Date: Wed, 30 Nov 2022 09:23:47 -0300 Subject: [PATCH 8/8] ci: update php version --- .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 e3e0ecb..7599daa 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,7 +17,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.2' + php-version: '8.1' - name: Validate composer.json and composer.lock run: composer validate --strict