diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46e9201..8ee0dd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: php-version: ['8.1', '8.4', '8.5'] - symfony-version: ['5.4.*', '6.4.*', '7.0.*'] + symfony-version: ['5.4.*', '6.4.*', '7.0.*', '8.0.*'] doctrine-orm-version: ['2.20.*', '3.0.*'] exclude: # Symfony 5.4 is not compatible with PHP 8.3 @@ -26,6 +26,9 @@ jobs: symfony-version: '7.0.*' - php-version: '8.2' symfony-version: '7.0.*' + # Symfony 8.0 requires PHP 8.2+ + - php-version: '8.1' + symfony-version: '8.0.*' # Doctrine 3.0 requires PHP 8.4 or higher - php-version: '8.1' doctrine-orm-version: '3.0.*' @@ -40,7 +43,7 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, sqlite3 - coverage: ${{ matrix.php-version == '8.5' && matrix.symfony-version == '7.0.*' && matrix.doctrine-orm-version == '3.0.*' && 'pcov' || 'none' }} + coverage: ${{ matrix.php-version == '8.5' && (matrix.symfony-version == '7.0.*' || matrix.symfony-version == '8.0.*') && matrix.doctrine-orm-version == '3.0.*' && 'pcov' || 'none' }} - name: Install Composer dependencies uses: ramsey/composer-install@v3 @@ -48,18 +51,18 @@ jobs: composer-options: "--prefer-dist --no-progress --no-interaction --optimize-autoloader" - name: Run PHP-CS-Fixer - if: matrix.php-version == '8.5' && matrix.symfony-version == '7.0.*' + if: matrix.php-version == '8.1' run: vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --using-cache=no - name: Run PHPStan - if: matrix.php-version == '8.5' && matrix.symfony-version == '7.0.*' + if: matrix.php-version == '8.5' && (matrix.symfony-version == '7.0.*' || matrix.symfony-version == '8.0.*') && matrix.doctrine-orm-version == '3.0.*' run: vendor/bin/phpstan analyse src tests --configuration=phpstan-8.5-plus.neon --memory-limit=1G - name: Run PHPUnit tests - run: vendor/bin/phpunit ${{ matrix.php-version == '8.5' && matrix.symfony-version == '7.0.*' && matrix.doctrine-orm-version == '3.0.*' && '--coverage-clover coverage.xml' || '' }} + run: vendor/bin/phpunit ${{ matrix.php-version == '8.5' && (matrix.symfony-version == '7.0.*' || matrix.symfony-version == '8.0.*') && matrix.doctrine-orm-version == '3.0.*' && '--coverage-clover coverage.xml' || '' }} - name: Upload coverage to Codecov - if: matrix.php-version == '8.5' && matrix.symfony-version == '7.0.*' && matrix.doctrine-orm-version == '3.0.*' + if: matrix.php-version == '8.5' && (matrix.symfony-version == '7.0.*' || matrix.symfony-version == '8.0.*') && matrix.doctrine-orm-version == '3.0.*' uses: codecov/codecov-action@v4 with: files: ./coverage.xml diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 308c17a..5b5d39e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -19,6 +19,7 @@ 'phpdoc_to_comment' => false, 'phpdoc_var_without_name' => false, '@Symfony' => true, + 'no_useless_else' => false, ]; $config = new PhpCsFixer\Config(); diff --git a/README.md b/README.md index fc4ca68..2c856ea 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Latest Version](https://img.shields.io/github/release/andanteproject/nullable-embeddable-bundle.svg)](https://github.com/andanteproject/nullable-embeddable-bundle/releases) ![Github actions](https://github.com/andanteproject/nullable-embeddable-bundle/actions/workflows/ci.yml/badge.svg?branch=main) [![codecov](https://codecov.io/gh/andanteproject/nullable-embeddable-bundle/branch/main/graph/badge.svg)](https://codecov.io/gh/andanteproject/nullable-embeddable-bundle) -![Framework](https://img.shields.io/badge/Symfony-5.x|6.x|7.x-informational?Style=flat&logo=symfony) +![Framework](https://img.shields.io/badge/Symfony-5.x|6.x|7.x|8.x-informational?style=flat&logo=symfony) ![Php8](https://img.shields.io/badge/PHP-8.1|8.5%2B-informational?style=flat&logo=php) ![PhpStan](https://img.shields.io/badge/PHPStan-Level%209-success?style=flat&logo=php) @@ -47,7 +47,7 @@ class Country ``` ## Requirements -* Symfony 5.x-7.x +* Symfony 5.x–8.x * PHP 8.1+ (PHP 8.5+ for anonymous function processors) * [Doctrine ORM](https://www.doctrine-project.org/projects/doctrine-orm/en/3.5/tutorials/embeddables.html) @@ -265,7 +265,7 @@ The `PropertyAccessor` provided to your processor (or anonymous function) is a s The `analyze` method of your processor must return one of two values from the `Result` enum: -* `Result::SHOULD_BE_NULL`: Indicates that the embeddable object should be treated as null. Note that "should" is used because the parent entity might have the embeddable class defined as not nullable. There is no guarantee the parent class accepts `null` as a value; this depends on database consistency and the user's data model. +* `Result::SHOULD_BE_NULL`: Indicates that the embeddable object should be treated as null. Note that "should" is used because the parent entity might have the embeddable class defined as not nullable. There is no guarantee the parent entity accepts `null` as a value; this depends on database consistency and the user's data model. * `Result::KEEP_INITIALIZED`: Indicates that the embeddable object should remain initialized. ## PHPStan Extension @@ -287,7 +287,7 @@ When Doctrine determines that an entire embeddable object should be null (which ) {} ``` -2. **Nullable Columns**: All properties mapped to database columns must be nullable. This can be achieved either by using a PHP nullable type (`?string`) which Doctrine automatically infers as `nullable: true`, or by explicitly setting `nullable: true` in the `#[Column]` attribute. This is required because when the embeddable object is null, Doctrine will set all its database columns to `NULL`. +2. **Nullable Columns**: All properties mapped to database columns must be nullable. This can be achieved either by using a PHP nullable type (`?string`), which Doctrine automatically infers as `nullable: true`, or by explicitly setting `nullable: true` in the `#[Column]` attribute. This is required because when the embeddable object is null, Doctrine will set all its database columns to `NULL`. 3. **Nested Embeddables with Defaults**: Embedded objects that have explicit non-null default values must be typed as nullable. Uninitialized embedded properties are fine since they remain uninitialized when the parent is null. @@ -338,7 +338,7 @@ class Address #[ORM\Column(type: Types::STRING, nullable: true)] private string $city; - // CORRECT: Uninitialized embedded property (will remain uninitialized when parent is null) + // CORRECT: Uninitialized embedded property (will remain uninitialized when the parent is null) #[ORM\Embedded(class: Country::class)] private Country $country; diff --git a/composer.json b/composer.json index f15b63a..070fc54 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,10 @@ ], "require": { "php": "^8.1", - "symfony/config": "^5.0 || ^6.0 || ^7.0", - "symfony/http-kernel": "^5.0 || ^6.0 || ^7.0", - "symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0", - "symfony/property-access": "^5.0 || ^6.0 || ^7.0", + "symfony/config": "^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/http-kernel": "^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/property-access": "^5.0 || ^6.0 || ^7.0 || ^8.0", "doctrine/orm": "^2.0 | ^3.0" }, "autoload": { @@ -39,16 +39,17 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "symfony/cache": "^5.0 || ^6.0 || ^7.0", + "symfony/cache": "^5.0 || ^6.0 || ^7.0 || ^8.0", "friendsofphp/php-cs-fixer": "^3.0", "phpstan/phpstan": "^1.0", "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-symfony": "^1.0", "phpstan/phpstan-webmozart-assert": "^1.0", "phpstan/extension-installer": "^1.0", - "symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0 || ^8.0", "doctrine/doctrine-bundle": "^2.0", - "symfony/test-pack": "^1.0" + "symfony/test-pack": "^1.0", + "symfony/var-exporter": "^6.4 || ^7" }, "config": { "allow-plugins": { diff --git a/phpstan-8.5-plus.neon b/phpstan-8.5-plus.neon index e15c1d0..80b27d8 100644 --- a/phpstan-8.5-plus.neon +++ b/phpstan-8.5-plus.neon @@ -11,5 +11,7 @@ parameters: - phpstan-stubs - tests/Fixtures/ValidClosureProcessorEntity excludePaths: + - src/DependencyInjection/Configuration.php - tests/PHPStan + - tests/Fixtures/ValidClosureProcessorEntity - tests/Functional/PHPStanRulesIssuesTests/Fixtures diff --git a/phpstan-lt-8.5.neon b/phpstan-lt-8.5.neon index 0b18006..4a4ad05 100644 --- a/phpstan-lt-8.5.neon +++ b/phpstan-lt-8.5.neon @@ -10,6 +10,6 @@ parameters: - tests - phpstan-stubs excludePaths: + - src/DependencyInjection/Configuration.php - tests/Fixtures/ValidClosureProcessorEntity - tests/PHPStan - - tests/Functional/PHPStanRulesIssuesTests/Fixtures