diff --git a/.github/workflows/ci-code-style.yml b/.github/workflows/ci-code-style.yml deleted file mode 100644 index 321cbe7..0000000 --- a/.github/workflows/ci-code-style.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Code Style - -on: - - push - - fork - - pull_request - -jobs: - code-style: - runs-on: ubuntu-latest - name: "Check code style" - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - tools: composer:v2 - - run: composer install --dev --ignore-platform-req=php - shell: bash - - run: composer cs:list - shell: bash diff --git a/.github/workflows/ci-leak-test.yml b/.github/workflows/ci-leak-test.yml deleted file mode 100644 index 7395abc..0000000 --- a/.github/workflows/ci-leak-test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Leak Tests - -on: - - push - - fork - - pull_request - -jobs: - tests: - runs-on: ubuntu-latest - name: "Running unit tests for PHP ${{ matrix.php-version }}" - strategy: - fail-fast: false - matrix: - php-version: ['8.1', '8.2', '8.3'] - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - tools: composer:v2 - - run: composer install --ignore-platform-req=php - shell: bash - - run: composer test:leak - shell: bash diff --git a/.github/workflows/ci-markdown-lint.yml b/.github/workflows/ci-markdown-lint.yml deleted file mode 100644 index f849445..0000000 --- a/.github/workflows/ci-markdown-lint.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Markdown lint - -on: - - push - - fork - - pull_request - -jobs: - yml-lint: - runs-on: ubuntu-latest - name: "Markdown lint" - steps: - - uses: actions/checkout@v2 - - run: docker pull tmknom/markdownlint - - run: docker run --rm -v $(pwd):/work tmknom/markdownlint '**/*.md' --ignore vendor - shell: bash diff --git a/.github/workflows/ci-mutant-test.yml b/.github/workflows/ci-mutant-test.yml deleted file mode 100644 index 850b691..0000000 --- a/.github/workflows/ci-mutant-test.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Mutant Test - -on: - - push - - fork - - pull_request - -jobs: - tests: - runs-on: ubuntu-latest - name: "Running mutant tests" - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - tools: composer:v2 - - run: composer install --ignore-platform-req=php - shell: bash - - run: composer test:mutant - shell: bash diff --git a/.github/workflows/ci-phpstan.yml b/.github/workflows/ci-phpstan.yml deleted file mode 100644 index d55f97e..0000000 --- a/.github/workflows/ci-phpstan.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: PHPStan - -on: - - push - - fork - - pull_request - -jobs: - tests: - runs-on: ubuntu-latest - name: "Check PHPStan" - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - tools: composer:v2 - - run: composer install --ignore-platform-req=php - shell: bash - - run: composer phpstan - shell: bash diff --git a/.github/workflows/ci-psalm.yml b/.github/workflows/ci-psalm.yml deleted file mode 100644 index 43e6648..0000000 --- a/.github/workflows/ci-psalm.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Psalm - -on: - - push - - fork - - pull_request - -jobs: - tests: - runs-on: ubuntu-latest - name: "Check Psalm" - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - tools: composer:v2 - - run: composer install --ignore-platform-req=php - shell: bash - - run: composer psalm - shell: bash diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..c4ca59d --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,131 @@ +name: Test + +on: + - push + - pull_request + +jobs: + + yml-lint: + runs-on: ubuntu-latest + name: 'YML lint' + timeout-minutes: 3 + steps: + - uses: actions/checkout@v4 + - run: docker pull cytopia/yamllint + - run: docker run --rm -t -v $(pwd):/data cytopia/yamllint --config-file=tests/.yamllint . + + markdown-lint: + runs-on: ubuntu-latest + name: 'Markdown lint' + timeout-minutes: 3 + steps: + - uses: actions/checkout@v4 + - run: docker pull tmknom/markdownlint + - run: docker run --rm -v $(pwd):/work tmknom/markdownlint '**/*.md' --config tests/.markdownlintrc --ignore vendor --ignore CHANGELOG.md --ignore var --ignore tmp + + cs-lint: + runs-on: ubuntu-latest + name: 'CS Lint' + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + - run: composer install --dev --ignore-platform-req=php --quiet + shell: bash + - run: PHP_CS_FIXER_IGNORE_ENV=1 composer cs:list + shell: bash + + psalm: + runs-on: ubuntu-latest + name: 'Psalm' + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + - run: composer install --ignore-platform-req=php --quiet + shell: bash + - run: composer psalm + shell: bash + + phpstan: + runs-on: ubuntu-latest + name: 'Phpstan' + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + - run: composer install --ignore-platform-req=php --quiet + shell: bash + - run: composer phpstan + shell: bash + + test-unit: + runs-on: ubuntu-latest + name: "Running unit tests for PHP ${{ matrix.php-version }}" + strategy: + fail-fast: false + matrix: + php-version: ['8.2', '8.3', '8.4'] + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + - run: composer install --ignore-platform-req=php --quiet + shell: bash + - run: composer test + shell: bash + + test-unit-coverage: + runs-on: ubuntu-latest + name: "Running unit test coverage" + timeout-minutes: 5 + needs: + - test-unit + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + - run: composer install --ignore-platform-req=php --quiet + shell: bash + - run: composer test:coverage:xml + shell: bash + - uses: paambaati/codeclimate-action@v9.0.0 + env: + CC_TEST_REPORTER_ID: 203d856fbc3ebebe66cc94cccde4429973298c7fb919df64a1557850cc9c8345 + with: + coverageLocations: coverage.xml:clover + - uses: actions/upload-artifact@v4 + with: + name: coverage.xml + path: coverage.xml + + test-mutant: + runs-on: ubuntu-latest + name: 'Mutant Test' + timeout-minutes: 5 + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + - run: composer install --ignore-platform-req=php --quiet + shell: bash + - run: composer test:mutant + shell: bash diff --git a/.github/workflows/ci-unit-test-coverage.yml b/.github/workflows/ci-unit-test-coverage.yml deleted file mode 100644 index 9ec974b..0000000 --- a/.github/workflows/ci-unit-test-coverage.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Unit Test Coverage Report - -on: - - push - - fork - - pull_request - -jobs: - coverage: - runs-on: ubuntu-latest - name: "Generate unit test coverage report for PHP ${{ matrix.php-version }}" - env: - XDEBUG_MODE: coverage - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: xdebug - tools: composer:v2 - - run: composer install --ignore-platform-req=php - shell: bash - - run: composer test:coverage:xml - shell: bash - - uses: paambaati/codeclimate-action@v3.0.0 - env: - CC_TEST_REPORTER_ID: 203d856fbc3ebebe66cc94cccde4429973298c7fb919df64a1557850cc9c8345 - with: - coverageLocations: coverage.xml:clover - - uses: actions/upload-artifact@v2 - with: - name: coverage.xml - path: coverage.xml diff --git a/.github/workflows/ci-unit-test.yml b/.github/workflows/ci-unit-test.yml deleted file mode 100644 index aadd168..0000000 --- a/.github/workflows/ci-unit-test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Unit Tests - -on: - - push - - fork - - pull_request - -jobs: - tests: - runs-on: ubuntu-latest - name: "Running unit tests for PHP ${{ matrix.php-version }}" - strategy: - fail-fast: false - matrix: - php-version: ['8.1', '8.2', '8.3'] - steps: - - uses: actions/checkout@v2 - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - tools: composer:v2 - - run: composer install --ignore-platform-req=php - shell: bash - - run: composer test - shell: bash diff --git a/.github/workflows/ci-yml-lint.yml b/.github/workflows/ci-yml-lint.yml deleted file mode 100644 index dc948fd..0000000 --- a/.github/workflows/ci-yml-lint.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: YML lint - -on: - - push - - fork - - pull_request - -jobs: - yml-lint: - runs-on: ubuntu-latest - name: "YML lint" - steps: - - uses: actions/checkout@v2 - - run: docker pull cytopia/yamllint - - run: docker run --rm -t -v $(pwd):/data cytopia/yamllint . - shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..6468acb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased +### Changed +- Made library compatible with PHP 8.4, closes #8. +- Update dev dependencies, related to #8. +- Remove dev dependencies `roave/no-leaks` and `boesing/psalm-plugin-stringf` due to conflict with newer PHP versions, + related to #8. diff --git a/Readme.md b/Readme.md index 9b0dd4b..578da81 100755 --- a/Readme.md +++ b/Readme.md @@ -3,14 +3,6 @@ ![Packagist Version](https://img.shields.io/packagist/v/syndesi/cypher-data-structures) ![Packagist Downloads](https://img.shields.io/packagist/dm/syndesi/cypher-data-structures) -[![Unit Tests](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-unit-test.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-unit-test.yml) -[![Mutant Test](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-mutant-test.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-mutant-test.yml) -[![Leak Tests](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-leak-test.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-leak-test.yml) -[![PHPStan](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-phpstan.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-phpstan.yml) -[![Psalm](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-psalm.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-psalm.yml) -[![Code Style](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-code-style.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-code-style.yml) -[![YML lint](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-yml-lint.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-yml-lint.yml) -[![Markdown lint](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-markdown-lint.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-markdown-lint.yml) [![Test Coverage](https://api.codeclimate.com/v1/badges/3a6aef038839e5bb5b59/test_coverage)](https://codeclimate.com/github/Syndesi/cypher-data-structures/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/3a6aef038839e5bb5b59/maintainability)](https://codeclimate.com/github/Syndesi/cypher-data-structures/maintainability) diff --git a/composer.json b/composer.json index 988263c..b3439ee 100755 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "type": "library", "homepage": "https://neo4j-php.github.io/cypher-data-structures/#/", "license": "MIT", + "minimum-stability": "dev", "authors": [ { "name": "Syndesi (Sören Klein)", @@ -30,32 +31,30 @@ } }, "require-dev": { - "vimeo/psalm": "^5.0", - "boesing/psalm-plugin-stringf": "^1.1", - "phpstan/phpstan": "^1.6", - "phpunit/php-code-coverage": "^9.2", - "infection/infection": "^0.27.0", - "friendsofphp/php-cs-fixer": "^3.8", - "phpunit/phpunit": "^9.5", - "roave/no-leaks": "^1.3", + "vimeo/psalm": "^6.2", + "phpstan/phpstan": "^2.1", + "phpunit/php-code-coverage": "^11", + "infection/infection": "^0.29.8", + "friendsofphp/php-cs-fixer": "^3.48", + "phpunit/phpunit": "^11", "phpbench/phpbench": "^1.2", - "infection/codeception-adapter": "^0.4.2" + "infection/codeception-adapter": "^0.4.2", + "thecodingmachine/safe": "v3.0.0 as v2.6" }, "scripts": { - "test": "php vendor/phpunit/phpunit/phpunit", + "test": "php vendor/phpunit/phpunit/phpunit --display-phpunit-deprecations", "test:coverage:xml": "export XDEBUG_MODE=coverage && php ./vendor/phpunit/phpunit/phpunit --coverage-clover coverage.xml", "test:coverage:html": "export XDEBUG_MODE=coverage && php ./vendor/phpunit/phpunit/phpunit --coverage-html ./tmp", "test:mutant": "export XDEBUG_MODE=coverage && php vendor/infection/infection/bin/infection --threads=4", - "test:leak": "export LEAK=true && php vendor/bin/roave-no-leaks", - "cs:list": "php vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --allow-risky=yes --dry-run ./src", - "cs:fix": "php vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --allow-risky=yes", + "cs:list": "PHP_CS_FIXER_IGNORE_ENV=1 php vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --allow-risky=yes --dry-run ./src", + "cs:fix": "PHP_CS_FIXER_IGNORE_ENV=1 php vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --allow-risky=yes", "psalm": "php vendor/bin/psalm --show-info=true --no-cache", "psalm:fix": "php vendor/bin/psalm --alter --issues=MissingReturnType,InvalidReturnType,InvalidNullableReturnType,MismatchingDocblockParamType", "phpstan": "vendor/bin/phpstan", "benchmark": "vendor/bin/phpbench run --report=aggregate --progress dots", "benchmark:csv": "vendor/bin/phpbench run --report=bare --output=csv-file", "benchmark:plot": "python benchmark/plot/plot.py", - "yml:lint": "docker run --rm -it -v $(pwd):/data cytopia/yamllint .", + "yml:lint": "docker run --rm -it -v $(pwd):/data cytopia/yamllint --config-file=tests/.yamllint .", "markdown:lint": "docker run --rm -v $(pwd):/work tmknom/markdownlint '**/*.md' --ignore vendor", "docs:serve": "docker run --rm -d -p 3000:3000 -v $(pwd)/docs:/docs sujaykumarh/docsify serve" }, diff --git a/docs/README.md b/docs/README.md index 9b0dd4b..578da81 100755 --- a/docs/README.md +++ b/docs/README.md @@ -3,14 +3,6 @@ ![Packagist Version](https://img.shields.io/packagist/v/syndesi/cypher-data-structures) ![Packagist Downloads](https://img.shields.io/packagist/dm/syndesi/cypher-data-structures) -[![Unit Tests](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-unit-test.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-unit-test.yml) -[![Mutant Test](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-mutant-test.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-mutant-test.yml) -[![Leak Tests](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-leak-test.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-leak-test.yml) -[![PHPStan](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-phpstan.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-phpstan.yml) -[![Psalm](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-psalm.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-psalm.yml) -[![Code Style](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-code-style.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-code-style.yml) -[![YML lint](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-yml-lint.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-yml-lint.yml) -[![Markdown lint](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-markdown-lint.yml/badge.svg)](https://github.com/neo4j-php/cypher-data-structures/actions/workflows/ci-markdown-lint.yml) [![Test Coverage](https://api.codeclimate.com/v1/badges/3a6aef038839e5bb5b59/test_coverage)](https://codeclimate.com/github/Syndesi/cypher-data-structures/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/3a6aef038839e5bb5b59/maintainability)](https://codeclimate.com/github/Syndesi/cypher-data-structures/maintainability) diff --git a/phpstan.neon b/phpstan.neon index 53e07ef..c60224f 100755 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,6 @@ parameters: level: 8 paths: - src - checkGenericClassInNonGenericObjectType: false ignoreErrors: # - '#Method [a-zA-Z0-9\\_:()]+ should return static\([a-zA-Z0-9\\_]+\) but returns [a-zA-Z0-9\\_]+\.#' # - '#Method [a-zA-Z0-9\\_]+::current\(\) should return [a-zA-Z0-9\\_]+ but returns object\.#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ee83a6f..c8cb578 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,20 +1,20 @@ - - - - ./src - - + - + ./tests + + + ./src + + diff --git a/psalm.xml b/psalm.xml index 9e6b2d3..fe8927b 100755 --- a/psalm.xml +++ b/psalm.xml @@ -12,4 +12,10 @@ - + + + + + + + diff --git a/src/Helper/ToStringHelper.php b/src/Helper/ToStringHelper.php index 3e5fd95..f9810ef 100644 --- a/src/Helper/ToStringHelper.php +++ b/src/Helper/ToStringHelper.php @@ -233,7 +233,8 @@ public static function relationToString(RelationInterface $relation, bool $ident } $relationParts = []; - if ($type = $relation->getType()) { + $type = $relation->getType(); + if (null !== $type) { $relationParts[] = sprintf(':%s', $type); } $properties = $relation->getProperties(); @@ -271,14 +272,15 @@ public static function nodeConstraintToString(NodeConstraintInterface $nodeConst $parts[] = 'CONSTRAINT'; - if ($name = $nodeConstraint->getName()) { + $name = $nodeConstraint->getName(); + if (null !== $name) { $parts[] = $name; } $parts[] = 'FOR'; $for = $nodeConstraint->getFor(); - if (!$for) { + if (null === $for) { throw new InvalidArgumentException('For can not be null'); } $parts[] = sprintf("(node:%s)", $for); @@ -292,6 +294,9 @@ public static function nodeConstraintToString(NodeConstraintInterface $nodeConst throw new InvalidArgumentException('At least one property is required'); } if (1 === $propertyCount) { + /** + * @psalm-suppress PossiblyNullArgument + */ $parts[] = sprintf("node.%s", array_shift($properties)); } if ($propertyCount > 1) { @@ -305,7 +310,7 @@ public static function nodeConstraintToString(NodeConstraintInterface $nodeConst $parts[] = 'IS'; $type = $nodeConstraint->getType(); - if (!$type) { + if (null === $type) { throw new InvalidArgumentException('Type can not be null'); } $parts[] = $type; @@ -325,14 +330,15 @@ public static function relationConstraintToString(RelationConstraintInterface $r $parts[] = 'CONSTRAINT'; - if ($name = $relationConstraint->getName()) { + $name = $relationConstraint->getName(); + if (null !== $name) { $parts[] = $name; } $parts[] = 'FOR'; $for = $relationConstraint->getFor(); - if (!$for) { + if (null === $for) { throw new InvalidArgumentException('For can not be null'); } $parts[] = sprintf("()-[relation:%s]-()", $for); @@ -346,6 +352,9 @@ public static function relationConstraintToString(RelationConstraintInterface $r throw new InvalidArgumentException('At least one property is required'); } if (1 === $propertyCount) { + /** + * @psalm-suppress PossiblyNullArgument + */ $parts[] = sprintf("relation.%s", array_shift($properties)); } if ($propertyCount > 1) { @@ -359,7 +368,7 @@ public static function relationConstraintToString(RelationConstraintInterface $r $parts[] = 'IS'; $type = $relationConstraint->getType(); - if (!$type) { + if (null === $type) { throw new InvalidArgumentException('Type can not be null'); } $parts[] = $type; @@ -378,20 +387,21 @@ public static function nodeIndexToString(NodeIndexInterface $nodeIndex): string $parts = []; $type = $nodeIndex->getType(); - if ($type) { + if (null !== $type) { $parts[] = $type; } $parts[] = 'INDEX'; - if ($name = $nodeIndex->getName()) { + $name = $nodeIndex->getName(); + if (null !== $name) { $parts[] = $name; } $parts[] = 'FOR'; $for = $nodeIndex->getFor(); - if (!$for) { + if (null === $for) { throw new InvalidArgumentException('For can not be null'); } $parts[] = sprintf("(node:%s)", $for); @@ -424,20 +434,21 @@ public static function relationIndexToString(RelationIndexInterface $relationInd $parts = []; $type = $relationIndex->getType(); - if ($type) { + if (null !== $type) { $parts[] = $type; } $parts[] = 'INDEX'; - if ($name = $relationIndex->getName()) { + $name = $relationIndex->getName(); + if (null !== $name) { $parts[] = $name; } $parts[] = 'FOR'; $for = $relationIndex->getFor(); - if (!$for) { + if (null === $for) { throw new InvalidArgumentException('For can not be null'); } $parts[] = sprintf("()-[relation:%s]-()", $for); diff --git a/src/Trait/IdentifiersTrait.php b/src/Trait/IdentifiersTrait.php index db8f7e9..2c76975 100644 --- a/src/Trait/IdentifiersTrait.php +++ b/src/Trait/IdentifiersTrait.php @@ -56,7 +56,7 @@ public function getIdentifier(string $identifier): mixed public function getIdentifiers(): array { $result = []; - foreach ($this->identifiers as $name => $value) { + foreach ($this->identifiers as $name => $_) { $result[$name] = $this->properties[$name]; } diff --git a/.markdownlintrc b/tests/.markdownlintrc similarity index 100% rename from .markdownlintrc rename to tests/.markdownlintrc diff --git a/.yamllint b/tests/.yamllint similarity index 53% rename from .yamllint rename to tests/.yamllint index 4f38fcc..99c5461 100644 --- a/.yamllint +++ b/tests/.yamllint @@ -1,6 +1,5 @@ extends: default - ignore: | vendor/ @@ -9,10 +8,10 @@ rules: document-start: present: false - line-length: - max: 120 -# allow-non-breakable-words: true -# allow-non-breakable-inline-mappings: false + line-length: false comments-indentation: false truthy: false + + indentation: + spaces: 2 diff --git a/tests/Helper/ToStringHelperTest.php b/tests/Helper/ToStringHelperTest.php index 81e654c..f8b346c 100644 --- a/tests/Helper/ToStringHelperTest.php +++ b/tests/Helper/ToStringHelperTest.php @@ -4,6 +4,7 @@ namespace Syndesi\CypherDataStructures\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Syndesi\CypherDataStructures\Exception\InvalidArgumentException; use Syndesi\CypherDataStructures\Helper\ToStringHelper; @@ -28,7 +29,7 @@ public function testMustNameBeEscaped(): void $this->assertTrue(ToStringHelper::mustNameBeEscaped('abc abc')); } - public function escapeStringProvider(): array + public static function escapeStringProvider(): array { return [ ['hello world', 'hello world'], @@ -44,9 +45,7 @@ public function escapeStringProvider(): array ]; } - /** - * @dataProvider escapeStringProvider - */ + #[DataProvider("escapeStringProvider")] public function testEscapeCharacter(string $string, string $output): void { $result = ToStringHelper::escapeString($string); @@ -63,7 +62,7 @@ public function testInvalidEscapeCharacter(): void ToStringHelper::escapeString('some string', '--'); } - public function valueToStringProvider(): array + public static function valueToStringProvider(): array { return [ [null, 'null'], @@ -83,9 +82,14 @@ public function valueToStringProvider(): array ]; } - /** - * @dataProvider valueToStringProvider - */ + public function testIsArrayAssociate(): void + { + $this->assertFalse(ToStringHelper::isArrayAssociate([])); + $this->assertFalse(ToStringHelper::isArrayAssociate([1, 2, 3])); + $this->assertTrue(ToStringHelper::isArrayAssociate(['a' => 'b', 'c' => 'd'])); + } + + #[DataProvider("valueToStringProvider")] public function testValueToString($value, $string): void { $this->assertSame($string, ToStringHelper::valueToString($value)); diff --git a/tests/Trait/IdentifiersTraitTest.php b/tests/Trait/IdentifiersTraitTest.php index 611ea07..a148f35 100644 --- a/tests/Trait/IdentifiersTraitTest.php +++ b/tests/Trait/IdentifiersTraitTest.php @@ -13,7 +13,7 @@ class IdentifiersTraitTest extends TestCase { private function getTrait(): HasIdentifiersInterface { - return new class() implements HasIdentifiersInterface { + return new class implements HasIdentifiersInterface { use IdentifiersTrait; }; } diff --git a/tests/Trait/OptionsTraitTest.php b/tests/Trait/OptionsTraitTest.php index 7e8e953..0098087 100644 --- a/tests/Trait/OptionsTraitTest.php +++ b/tests/Trait/OptionsTraitTest.php @@ -12,7 +12,7 @@ class OptionsTraitTest extends TestCase { private function getTrait(): HasOptionsInterface { - return new class() implements HasOptionsInterface { + return new class implements HasOptionsInterface { use OptionsTrait; }; } diff --git a/tests/Trait/PropertiesTraitTest.php b/tests/Trait/PropertiesTraitTest.php index ddbc0d4..8a66300 100644 --- a/tests/Trait/PropertiesTraitTest.php +++ b/tests/Trait/PropertiesTraitTest.php @@ -12,7 +12,7 @@ class PropertiesTraitTest extends TestCase { private function getTrait(): HasPropertiesInterface { - return new class() implements HasPropertiesInterface { + return new class implements HasPropertiesInterface { use PropertiesTrait; }; }