From 74c95f4286534645351f6390f0ab0ec57236d170 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Sat, 9 Sep 2023 23:48:41 +0200 Subject: [PATCH] Update requirements --- .cs.php | 21 ++++++- .editorconfig | 22 ++++++++ .gitattributes | 2 - .github/workflows/build.yml | 74 ++++++++++++------------- .gitignore | 1 + .scrutinizer.yml | 69 ++++++++++++----------- README.md | 2 +- composer.json | 24 +++++--- phpcs.xml | 21 +------ phpunit.xml | 20 ++++--- tests/ArrayTransformerTransformTest.php | 6 +- 11 files changed, 143 insertions(+), 119 deletions(-) create mode 100644 .editorconfig diff --git a/.cs.php b/.cs.php index a20a2c9..2bba5e9 100644 --- a/.cs.php +++ b/.cs.php @@ -21,6 +21,12 @@ 'concat_space' => ['spacing' => 'one'], 'compact_nullable_typehint' => true, 'declare_equal_normalize' => ['space' => 'single'], + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', + 'package', + ], + ], 'increment_style' => ['style' => 'post'], 'list_syntax' => ['syntax' => 'short'], 'echo_tag_syntax' => ['format' => 'long'], @@ -34,11 +40,22 @@ 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'ordered_imports' => [ 'sort_algorithm' => 'alpha', - 'imports_order' => ['class', 'const', 'function'] + 'imports_order' => ['class', 'const', 'function'], ], 'single_line_throw' => false, + 'declare_strict_types' => false, + 'blank_line_between_import_groups' => true, 'fully_qualified_strict_types' => true, - 'global_namespace_import' => false, + 'no_null_property_initialization' => false, + 'operator_linebreak' => [ + 'only_booleans' => true, + 'position' => 'beginning', + ], + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => null, + 'import_functions' => null + ] ] ) ->setFinder( diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0a6abee --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +end_of_line = lf + +[composer.json] +indent_size = 4 + +[*.js] +indent_size = 4 + +[*.neon] +indent_size = 4 +indent_style = tab + +[*.xml] +indent_size = 4 + +[*.yml] +indent_size = 4 diff --git a/.gitattributes b/.gitattributes index 0e58fb3..5a3d341 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,10 +19,8 @@ /phpunit.xml export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.travis.* export-ignore /.scrutinizer.* export-ignore /.editorconfig export-ignore -/.coveralls.* export-ignore # Define binary file attributes. # - Do not treat them as text. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc4158c..a4bf3d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,41 +3,39 @@ name: build on: [ push, pull_request ] jobs: - run: - runs-on: ${{ matrix.operating-system }} - strategy: - matrix: - operating-system: [ ubuntu-latest ] - php-versions: [ '8.1', '8.2' ] - name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} - - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, intl, zip - coverage: none - - - name: Check PHP Version - run: php -v - - - name: Check Composer Version - run: composer -V - - - name: Check PHP Extensions - run: php -m - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - - name: Run test suite - run: composer check - env: - PHP_CS_FIXER_IGNORE_ENV: 1 + run: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ ubuntu-latest ] + php-versions: [ '8.1', '8.2' ] + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl, zip + coverage: none + + - name: Check PHP Version + run: php -v + + - name: Check Composer Version + run: composer -V + + - name: Check PHP Extensions + run: php -m + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run test suite + run: composer test:all diff --git a/.gitignore b/.gitignore index 22f5e7f..a4689b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ composer.lock nbproject/ vendor/ build/ +.phpunit.cache/ .phpunit.result.cache \ No newline at end of file diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 9cf2601..3514e2e 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,42 +1,41 @@ filter: - paths: [ "src/*" ] - excluded_paths: [ "vendor/*", "tests/*" ] + paths: [ "src/*" ] + excluded_paths: [ "vendor/*", "tests/*" ] checks: - php: - code_rating: true - duplication: true + php: + code_rating: true + duplication: true tools: - external_code_coverage: false + external_code_coverage: false build: - environment: - php: - version: 8.1.2 - ini: - xdebug.mode: coverage - mysql: false - node: false - postgresql: false - mongodb: false - elasticsearch: false - redis: false - memcached: false - neo4j: false - rabbitmq: false - nodes: - analysis: - tests: - override: - - php-scrutinizer-run - dependencies: - before: - - composer self-update - - composer install --no-interaction --prefer-dist --no-progress - tests: - before: - - command: composer test:coverage - coverage: - file: 'build/logs/clover.xml' - format: 'clover' + environment: + php: + version: 8.1.2 + ini: + xdebug.mode: coverage + mysql: false + node: false + postgresql: false + mongodb: false + elasticsearch: false + redis: false + memcached: false + neo4j: false + rabbitmq: false + nodes: + analysis: + tests: + override: + - php-scrutinizer-run + dependencies: + before: + - composer self-update + tests: + before: + - command: composer test:coverage + coverage: + file: 'build/logs/clover.xml' + format: 'clover' diff --git a/README.md b/README.md index 5c2a750..992f30d 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ responses and many other things. ## Requirements -* PHP 8.0+ +* PHP 8.1+ ## Installation diff --git a/composer.json b/composer.json index f7857f0..76e866f 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,8 @@ { "name": "selective/transformer", - "type": "library", "description": "A strictly typed array transformer with dot-access, fluent interface and filters.", + "license": "MIT", + "type": "library", "keywords": [ "transformer", "mapper", @@ -14,19 +15,15 @@ "json" ], "homepage": "https://github.com/selective-php/transformer", - "license": "MIT", "require": { "php": "^8.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", "phpstan/phpstan": "^1", - "phpunit/phpunit": "^9 || ^10", + "phpunit/phpunit": "^10", "squizlabs/php_codesniffer": "^3" }, - "config": { - "sort-packages": true - }, "autoload": { "psr-4": { "Selective\\Transformer\\": "src/" @@ -37,12 +34,21 @@ "Selective\\Transformer\\Test\\": "tests/" } }, + "config": { + "sort-packages": true + }, "scripts": { - "cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi", - "cs:fix": "php-cs-fixer fix --config=.cs.php --ansi", + "cs:check": [ + "@putenv PHP_CS_FIXER_IGNORE_ENV=1", + "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi" + ], + "cs:fix": [ + "@putenv PHP_CS_FIXER_IGNORE_ENV=1", + "php-cs-fixer fix --config=.cs.php --ansi --verbose" + ], "sniffer:check": "phpcs --standard=phpcs.xml", "sniffer:fix": "phpcbf --standard=phpcs.xml", - "stan": "phpstan analyse -c phpstan.neon --no-progress --ansi --xdebug", + "stan": "phpstan analyse -c phpstan.neon --no-progress --ansi", "test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always", "test:all": [ "@cs:check", diff --git a/phpcs.xml b/phpcs.xml index c825571..f2f42d9 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -9,27 +9,8 @@ ./src ./tests - - + - - - warning - */tests/ - - - warning - - - warning - */config/ - - - warning - - - warning - warning diff --git a/phpunit.xml b/phpunit.xml index f2e36c3..2927473 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,9 +3,16 @@ bootstrap="vendor/autoload.php" colors="true" backupGlobals="false" - backupStaticAttributes="false" - xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" + cacheDirectory=".phpunit.cache" + backupStaticProperties="false"> + + + + tests + + + src @@ -13,10 +20,5 @@ vendor build - - - - tests - - + diff --git a/tests/ArrayTransformerTransformTest.php b/tests/ArrayTransformerTransformTest.php index a0c7c82..ccc4c42 100644 --- a/tests/ArrayTransformerTransformTest.php +++ b/tests/ArrayTransformerTransformTest.php @@ -203,7 +203,7 @@ public function testDateTimeFilterAndTimeZone(): void public function testDateTimParserError(): void { $this->expectException(ArrayTransformerException::class); - $this->expectErrorMessageMatches('/Failed to parse time string/'); + $this->expectExceptionMessageMatches('/Failed to parse time string/'); $transformer = new ArrayTransformer(); $transformer->map('date', 'date', $transformer->rule()->date('Y-m-d')); @@ -221,7 +221,7 @@ public function testDateTimParserError(): void public function testDateTimeDateTimeZoneException(): void { $this->expectException(ArrayTransformerException::class); - $this->expectErrorMessage( + $this->expectExceptionMessage( 'Changing the DateTimeZone of an existing DateTimeImmutable object is not supported.' ); @@ -246,7 +246,7 @@ public function testDateTimeDateTimeZoneException(): void public function testUndefinedFilterException(): void { $this->expectException(ArrayTransformerException::class); - $this->expectErrorMessage('Filter not found: foo'); + $this->expectExceptionMessage('Filter not found: foo'); $transformer = new ArrayTransformer(); $transformer->map('field', 'field', $transformer->rule()->filter('foo'));