Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.*'
Expand All @@ -40,26 +43,26 @@ 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
with:
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
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'phpdoc_to_comment' => false,
'phpdoc_var_without_name' => false,
'@Symfony' => true,
'no_useless_else' => false,
];

$config = new PhpCsFixer\Config();
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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;

Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions phpstan-8.5-plus.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ parameters:
- phpstan-stubs
- tests/Fixtures/ValidClosureProcessorEntity
excludePaths:
- src/DependencyInjection/Configuration.php
- tests/PHPStan
- tests/Fixtures/ValidClosureProcessorEntity
- tests/Functional/PHPStanRulesIssuesTests/Fixtures
2 changes: 1 addition & 1 deletion phpstan-lt-8.5.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ parameters:
- tests
- phpstan-stubs
excludePaths:
- src/DependencyInjection/Configuration.php
- tests/Fixtures/ValidClosureProcessorEntity
- tests/PHPStan
- tests/Functional/PHPStanRulesIssuesTests/Fixtures