diff --git a/.github/workflows/build-and-publish-ci-image.yml b/.github/workflows/build-and-publish-ci-image.yml index aadc5112..374e4738 100644 --- a/.github/workflows/build-and-publish-ci-image.yml +++ b/.github/workflows/build-and-publish-ci-image.yml @@ -1,5 +1,9 @@ name: Build Docker CI image +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: diff --git a/.github/workflows/build-and-publish-franken-image.yml b/.github/workflows/build-and-publish-franken-image.yml index a9adeaa0..64b6b0e1 100644 --- a/.github/workflows/build-and-publish-franken-image.yml +++ b/.github/workflows/build-and-publish-franken-image.yml @@ -1,5 +1,9 @@ name: Build Docker FrankenPHP image +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: tags: diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index de871c80..2397eff9 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -1,5 +1,9 @@ name: "Coding standards" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: pull_request: paths: @@ -28,6 +32,9 @@ jobs: matrix: php-version: - "8.2" + - "8.3" + - "8.4" + - "8.5" steps: - name: "Checkout code" @@ -41,7 +48,7 @@ jobs: tools: cs2pr - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" - name: "Run a Code style analysis with friendsofphp/php-cs-fixer" run: "vendor/bin/php-cs-fixer fix --format=checkstyle --allow-risky=yes --dry-run | cs2pr" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9c77ab89..ee9a631d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,5 +1,9 @@ name: "Continuous Integration" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: pull_request: paths: @@ -29,10 +33,10 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" - "8.3" - "8.4" + - "8.5" postgres-version: - "16" extension: @@ -64,6 +68,7 @@ jobs: with: php-version: "${{ matrix.php-version }}" extensions: "pgsql pdo_pgsql" + cache: composer ini-values: "zend.assertions=1" - name: "Install dependencies with Composer" @@ -95,7 +100,10 @@ jobs: strategy: matrix: php-version: - - "8.1" + - "8.2" + - "8.3" + - "8.4" + - "8.5" postgres-version: - "10" - "15" @@ -158,7 +166,10 @@ jobs: strategy: matrix: php-version: - - "8.1" + - "8.2" + - "8.3" + - "8.4" + - "8.5" mariadb-version: - "10.11.6" # LTS (Feb 2028) - "11.4.5" # LTS (May 2029) @@ -166,7 +177,16 @@ jobs: extension: - "mysqli" include: - - php-version: "8.1" + - php-version: "8.2" + mariadb-version: "11.4.5" + extension: "pdo_mysql" + - php-version: "8.3" + mariadb-version: "11.4.5" + extension: "pdo_mysql" + - php-version: "8.4" + mariadb-version: "11.4.5" + extension: "pdo_mysql" + - php-version: "8.5" mariadb-version: "11.4.5" extension: "pdo_mysql" @@ -224,7 +244,10 @@ jobs: strategy: matrix: php-version: - - "8.1" + - "8.2" + - "8.3" + - "8.4" + - "8.5" mysql-version: - "5.7" - "8.0" @@ -289,7 +312,7 @@ jobs: # strategy: # matrix: # php-version: - # - "8.1" + # - "8.2" # mssql-version: # - "2019" # - "2022" @@ -354,7 +377,7 @@ jobs: os: - "ubuntu-22.04" php-version: - - "8.1" + - "8.2" extension: - "pdo_sqlite" - "sqlite3" @@ -375,6 +398,7 @@ jobs: - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v3" with: + dependency-versions: 'locked' composer-options: "--ignore-platform-req=php+" - name: "Run PHPUnit" diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index ca54b7a8..947ea636 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -1,5 +1,9 @@ name: Documentation build +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: pull_request: paths: @@ -19,9 +23,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js 18.12 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18.12 cache: 'npm' diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f2d4c65a..3827a5c4 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,5 +1,9 @@ name: "Static Analysis" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: pull_request: paths: @@ -20,13 +24,16 @@ on: jobs: phpstan: - name: "Static Analysis" + name: "Static Analysis (PHP ${{ matrix.php-version }})" runs-on: "ubuntu-22.04" strategy: matrix: php-version: - "8.2" + - "8.3" + - "8.4" + - "8.5" steps: - name: Checkout code @@ -40,7 +47,7 @@ jobs: tools: cs2pr - name: Install dependencies with Composer - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 - name: Run static analysis with phpstan/phpstan run: vendor/bin/phpstan --error-format=checkstyle | cs2pr diff --git a/composer.json b/composer.json index 43bd14a9..aba97e40 100644 --- a/composer.json +++ b/composer.json @@ -27,9 +27,11 @@ "doctrine/doctrine-bundle": "^2.10.0", "doctrine/orm": "^2.15|^3.0", "friendsofphp/php-cs-fixer": "^3.34", + "larastan/larastan": "^3.0", "laravel/framework": "^10.0|^11.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.1.33", "phpunit/phpunit": "^10.4", + "seld/phar-utils": "^1.2", "symfony/dependency-injection": "^6.0|^7.0", "symfony/framework-bundle": "^6.0|^7.0", "symfony/password-hasher": "^6.0|^7.0", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b7263d0a..1e30eef7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -3,9 +3,6 @@ parameters: paths: - src - tests - excludePaths: - - src/DependencyInjection/DbToolsConfiguration.php checkMissingOverrideMethodAttribute: true + treatPhpDocTypesAsCertain: false ignoreErrors: - - '#Instantiated class Seld\\PharUtils\\Timestamps not found.#' - - '#on an unknown class Seld\\PharUtils\\Timestamps.#' diff --git a/src/Anonymization/Anonymizer/Core/DateAnonymizer.php b/src/Anonymization/Anonymizer/Core/DateAnonymizer.php index 59ec3149..96267f9a 100644 --- a/src/Anonymization/Anonymizer/Core/DateAnonymizer.php +++ b/src/Anonymization/Anonymizer/Core/DateAnonymizer.php @@ -38,7 +38,6 @@ protected function validateOptions(): void throw new \InvalidArgumentException("You must specify both 'min' and 'max' boundaries."); } - // @phpstan-ignore-next-line False positive detected. if ($min && $max) { if ($max <= $min) { throw new \InvalidArgumentException("'min' value must be less than 'max' value."); diff --git a/src/Anonymization/Config/Loader/AttributesLoader.php b/src/Anonymization/Config/Loader/AttributesLoader.php index 1f5ce070..7da1004c 100644 --- a/src/Anonymization/Config/Loader/AttributesLoader.php +++ b/src/Anonymization/Config/Loader/AttributesLoader.php @@ -32,7 +32,7 @@ public function load(AnonymizationConfig $config): void $metadatas = $metadataFactory->getAllMetadata(); foreach ($metadatas as $metadata) { - \assert($metadata instanceof ClassMetadata); + /** @var ClassMetadata $metadata */ if ($metadata->isMappedSuperclass || $metadata->isEmbeddedClass) { continue; } @@ -87,7 +87,6 @@ public function load(AnonymizationConfig $config): void $columnName = $metadata->getColumnName($fieldName); if ($metadata->isInheritedField($fieldName)) { $fieldMapping = $metadata->getFieldMapping($fieldName); - // @phpstan-ignore-next-line if (\is_array($fieldMapping)) { // Code for doctrine/orm:^2.0. $ownerClass = $fieldMapping['inherited']; @@ -96,7 +95,7 @@ public function load(AnonymizationConfig $config): void $ownerClass = $fieldMapping->inherited; } $parentMetadata = $metadataFactory->getMetadataFor($ownerClass); - \assert($parentMetadata instanceof ClassMetadata); + /** @var ClassMetadata $parentMetadata */ $tableName = $parentMetadata->getTableName(); } else { $tableName = $metadata->getTableName(); diff --git a/src/Backupper/BackupperFactory.php b/src/Backupper/BackupperFactory.php index fe9e8dd2..fb1152bb 100644 --- a/src/Backupper/BackupperFactory.php +++ b/src/Backupper/BackupperFactory.php @@ -47,8 +47,6 @@ public function create(?string $connectionName = null): AbstractBackupper $this->configRegistry->getConnectionConfig($connectionName), ); - \assert($backupper instanceof AbstractBackupper); - if (isset($this->excludedTables[$connectionName])) { $backupper->setExcludedTables($this->excludedTables[$connectionName]); } diff --git a/src/Bridge/Standalone/PharCompiler.php b/src/Bridge/Standalone/PharCompiler.php index faa8df58..2e9f894e 100644 --- a/src/Bridge/Standalone/PharCompiler.php +++ b/src/Bridge/Standalone/PharCompiler.php @@ -157,6 +157,7 @@ public function compile(?string $pharFile = null): void unset($phar); // re-sign the phar with reproducible timestamp / signature + $util = new Timestamps($pharFile); $util->updateTimestamps($this->versionDate); $util->save($pharFile, \Phar::SHA512); diff --git a/src/Bridge/Symfony/DependencyInjection/DbToolsConfiguration.php b/src/Bridge/Symfony/DependencyInjection/DbToolsConfiguration.php index 9a17d16d..ccaf21fe 100644 --- a/src/Bridge/Symfony/DependencyInjection/DbToolsConfiguration.php +++ b/src/Bridge/Symfony/DependencyInjection/DbToolsConfiguration.php @@ -87,7 +87,6 @@ public function getConfigTreeBuilder(): TreeBuilder // For PHPStan. \assert($rootNode instanceof ArrayNodeDefinition); - // @phpstan-ignore-next-line $rootNode ->children() ->arrayNode('anonymization') @@ -112,7 +111,6 @@ public function getConfigTreeBuilder(): TreeBuilder $this->addConnectionConfigTreeBuilder($rootNode); // Add "connections" children definition. - // @phpstan-ignore-next-line $connectionsNode = $rootNode ->children() ->arrayNode('connections') @@ -132,7 +130,6 @@ public function getConfigTreeBuilder(): TreeBuilder if ($this->standalone) { // Add extra options for standalone CLI app. - // @phpstan-ignore-next-line $rootNode ->children() ->scalarNode('workdir') @@ -149,7 +146,6 @@ public function getConfigTreeBuilder(): TreeBuilder if ($this->withDeprecated) { // Add deprecated options. - // @phpstan-ignore-next-line $rootNode ->children() ->arrayNode('storage') @@ -190,7 +186,6 @@ protected function addConnectionConfigTreeBuilder(ArrayNodeDefinition $node): vo { $intervalToInt = $this->getIntervalToInt(); - // @phpstan-ignore-next-line $node ->children() ->scalarNode('backup_binary') diff --git a/src/Bridge/Symfony/DependencyInjection/DbToolsExtension.php b/src/Bridge/Symfony/DependencyInjection/DbToolsExtension.php index 01c42401..edbc59ef 100644 --- a/src/Bridge/Symfony/DependencyInjection/DbToolsExtension.php +++ b/src/Bridge/Symfony/DependencyInjection/DbToolsExtension.php @@ -111,7 +111,7 @@ public function load(array $configs, ContainerBuilder $container): void } #[\Override] - public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface + public function getConfiguration(array $configs, ?ContainerBuilder $container = null): ConfigurationInterface { return new DbToolsConfiguration(true, false); } diff --git a/src/Helper/Iban.php b/src/Helper/Iban.php index 32a8bd96..0a490a06 100644 --- a/src/Helper/Iban.php +++ b/src/Helper/Iban.php @@ -121,7 +121,7 @@ private static function mod97(string $number): int $parts = \str_split($number, 7); $rest = 0; foreach ($parts as $part) { - $rest = (int)($rest . $part) % 97; + $rest = \intval($rest . $part) % 97; } return (int)$rest; } diff --git a/src/Helper/LoremIpsum.php b/src/Helper/LoremIpsum.php index f1cf093c..58dc3970 100644 --- a/src/Helper/LoremIpsum.php +++ b/src/Helper/LoremIpsum.php @@ -287,7 +287,7 @@ private function punctuate(array $words): string $commas = $this->gauss($mean, $std_dev); for ($i = 1; $i <= $commas; $i++) { - $word = \round($i * $word_count / ($commas + 1)); + $word = (int) \round($i * $word_count / ($commas + 1)); if ($word < ($word_count - 1) && $word > 0) { $words[$word] .= ','; diff --git a/src/Restorer/RestorerFactory.php b/src/Restorer/RestorerFactory.php index e887bb69..69cd4036 100644 --- a/src/Restorer/RestorerFactory.php +++ b/src/Restorer/RestorerFactory.php @@ -47,8 +47,6 @@ public function create(?string $connectionName = null): AbstractRestorer $this->configRegistry->getConnectionConfig($connectionName), ); - \assert($restorer instanceof AbstractRestorer); - if ($this->logger) { $restorer->setLogger($this->logger); } diff --git a/src/Storage/Storage.php b/src/Storage/Storage.php index 206a0745..8be21f3e 100644 --- a/src/Storage/Storage.php +++ b/src/Storage/Storage.php @@ -54,7 +54,7 @@ public function listBackups( $age = $lastModified->diff(new \DateTimeImmutable('')); if (!$onlyExpired || ($lastModified < $expirationDate)) { - if ($file !== $preserveFile) { + if ($preserveFile === null || $file->getFilename() !== $preserveFile) { $list[] = [$age->format('%a days'), $file]; } } diff --git a/tests/Functional/Anonymizer/Core/AddressAnonymizerTest.php b/tests/Functional/Anonymizer/Core/AddressAnonymizerTest.php index 4e4389e9..80c71f15 100644 --- a/tests/Functional/Anonymizer/Core/AddressAnonymizerTest.php +++ b/tests/Functional/Anonymizer/Core/AddressAnonymizerTest.php @@ -74,13 +74,11 @@ public function testAnonymize(): void $anonymizator->anonymize(); $datas = $this->getDatabaseSession()->executeQuery('select * from table_test order by id asc')->fetchAllAssociative(); - $this->assertNotNull($datas[0]); $this->assertNotSame('Rue Aristide Briand', $datas[0]['my_street_address']); $this->assertNotSame('La maison aux volets bleus', $datas[0]['my_secondary_address']); $this->assertNotSame('44400', $datas[0]['my_postal_code']); $this->assertNotSame('REZE', $datas[0]['my_locality']); $this->assertNotSame('Pays de loire', $datas[0]['my_region']); - $this->assertNotNull($datas[1]); $this->assertNotSame('Rue Jean Jaures', $datas[1]['my_street_address']); $this->assertNotSame('Au dernier étage', $datas[1]['my_secondary_address']); $this->assertNotSame('44000', $datas[1]['my_postal_code']); diff --git a/tests/Functional/Anonymizer/Core/FloatAnonymizerTest.php b/tests/Functional/Anonymizer/Core/FloatAnonymizerTest.php index 782eaacd..1dc49d5f 100644 --- a/tests/Functional/Anonymizer/Core/FloatAnonymizerTest.php +++ b/tests/Functional/Anonymizer/Core/FloatAnonymizerTest.php @@ -59,7 +59,6 @@ public function testAnonymizeWithMinAndMax(): void $datas = $this->getDatabaseSession()->executeQuery('select data from table_test order by id asc')->fetchFirstColumn(); $data = (float) $datas[0]; - $this->assertNotNull($data); $this->assertNotSame(10.5, $data); $this->assertGreaterThanOrEqual(2, $data); $this->assertLessThanOrEqual(5.5, $data); @@ -67,7 +66,6 @@ public function testAnonymizeWithMinAndMax(): void $this->assertSame(\number_format($data, 6), \number_format(\round($data, 6), 6)); $data = (float) $datas[1]; - $this->assertNotNull($data); $this->assertNotSame(20.5, $data); $this->assertGreaterThanOrEqual(2, $data); $this->assertLessThanOrEqual(5.5, $data); @@ -75,7 +73,6 @@ public function testAnonymizeWithMinAndMax(): void $this->assertSame(\number_format($data, 6), \number_format(\round($data, 6), 6)); $data = (float) $datas[2]; - $this->assertNotNull($data); $this->assertNotSame(30.5, $data); $this->assertGreaterThanOrEqual(2, $data); $this->assertLessThanOrEqual(5.5, $data); @@ -106,7 +103,6 @@ public function testAnonymizeWithDelta(): void $datas = $this->getDatabaseSession()->executeQuery('select data from table_test order by id asc')->fetchFirstColumn(); $data = (float) $datas[0]; - $this->assertNotNull($data); // Initial value is 10.5, we added a value in [-5.2, 5.2] // so current value should be in [10.5-5.2, 10.5+5.2] $this->assertGreaterThanOrEqual(5.3, $data); @@ -115,7 +111,6 @@ public function testAnonymizeWithDelta(): void $this->assertSame(\number_format($data, 6), \number_format(\round($data, 6), 6)); $data = (float) $datas[1]; - $this->assertNotNull($data); // Initial value is 20.5, we added a value in [-5.2, 5.2] // so current value should be in [20.5-5.2, 20.5+5.2] $this->assertGreaterThanOrEqual(15.3, $data); @@ -124,7 +119,6 @@ public function testAnonymizeWithDelta(): void $this->assertSame(\number_format($data, 6), \number_format(\round($data, 6), 6)); $data = (float) $datas[2]; - $this->assertNotNull($data); // Initial value is 30.5, we added a value in [-5.2, 5.2] // so current value should be in [30.5-5.2, 30.5+5.2] $this->assertGreaterThanOrEqual(25.3, $data); @@ -157,7 +151,6 @@ public function testAnonymizeWithPercent(): void $datas = $this->getDatabaseSession()->executeQuery('select data from table_test order by id asc')->fetchFirstColumn(); $data = (float) $datas[0]; - $this->assertNotNull($data); // Initial value is 10.5, we added a random percent of // this value in [-5%, 5%], // so current value should be in [10.5*0.95, 10.5*1.05] @@ -165,7 +158,6 @@ public function testAnonymizeWithPercent(): void $this->assertLessThanOrEqual(11.025, \round($data, 3)); $data = (float) $datas[1]; - $this->assertNotNull($data); // Initial value is 20.5, we added a random percent of // this value in [-5%, 5%], // so current value should be in [20.5*0.95, 20.5*1.05] @@ -173,7 +165,6 @@ public function testAnonymizeWithPercent(): void $this->assertLessThanOrEqual(21.525, \round($data, 3)); $data = (float) $datas[2]; - $this->assertNotNull($data); // Initial value is 30.5, we added a random percent of // this value in [-5%, 5%], // so current value should be in [30.5*0.95, 30.5*1.05] diff --git a/tests/Functional/Anonymizer/Core/IntegerAnonymizerTest.php b/tests/Functional/Anonymizer/Core/IntegerAnonymizerTest.php index e38a7f25..95cd34f4 100644 --- a/tests/Functional/Anonymizer/Core/IntegerAnonymizerTest.php +++ b/tests/Functional/Anonymizer/Core/IntegerAnonymizerTest.php @@ -58,19 +58,16 @@ public function testAnonymizeWithMinAndMax(): void $datas = $this->getDatabaseSession()->executeQuery('select data from table_test order by id asc')->fetchFirstColumn(); $data = (int) $datas[0]; - $this->assertNotNull($data); $this->assertNotSame(10, $data); $this->assertGreaterThanOrEqual(200, $data); $this->assertLessThanOrEqual(10000, $data); $data = (int) $datas[1]; - $this->assertNotNull($data); $this->assertNotSame(20, $data); $this->assertGreaterThanOrEqual(200, $data); $this->assertLessThanOrEqual(10000, $data); $data = (int) $datas[2]; - $this->assertNotNull($data); $this->assertNotSame(30, $data); $this->assertGreaterThanOrEqual(200, $data); $this->assertLessThanOrEqual(10000, $data); @@ -99,21 +96,18 @@ public function testAnonymizeWithDelta(): void $datas = $this->getDatabaseSession()->executeQuery('select data from table_test order by id asc')->fetchFirstColumn(); $data = (int) $datas[0]; - $this->assertNotNull($data); // Initial value is 10, we added a value in [-10, 10] // so current value should be in [10-10, 10+10] $this->assertGreaterThanOrEqual(0, $data); $this->assertLessThanOrEqual(20, $data); $data = (int) $datas[1]; - $this->assertNotNull($data); // Initial value is 20, we added a value in [-10, 10] // so current value should be in [20-10, 20+10] $this->assertGreaterThanOrEqual(10, $data); $this->assertLessThanOrEqual(30, $data); $data = (int) $datas[2]; - $this->assertNotNull($data); // Initial value is 30, we added a value in [-10, 10] // so current value should be in [30-10, 30+10] $this->assertGreaterThanOrEqual(20, $data); @@ -141,7 +135,6 @@ public function testAnonymizeWithPercent(): void $datas = $this->getDatabaseSession()->executeQuery('select data from table_test order by id asc')->fetchFirstColumn(); $data = (int) $datas[0]; - $this->assertNotNull($data); // Initial value is 10, we added a random percent of // this value in [-50%, 50%], // so current value should be in [10*0.5, 10*1.5] @@ -149,7 +142,6 @@ public function testAnonymizeWithPercent(): void $this->assertLessThanOrEqual(15, $data); $data = (int) $datas[1]; - $this->assertNotNull($data); // Initial value is 20, we added a random percent of // this value in [-50%, 50%], // so current value should be in [20*0.5, 20*1.5] @@ -157,7 +149,6 @@ public function testAnonymizeWithPercent(): void $this->assertLessThanOrEqual(30, $data); $data = (int) $datas[2]; - $this->assertNotNull($data); // Initial value is 30, we added a random percent of // this value in [-50%, 50%], // so current value should be in [30*0.5, 30*1.5] diff --git a/tests/Functional/Anonymizer/Core/StringPatternAnonymizerTest.php b/tests/Functional/Anonymizer/Core/StringPatternAnonymizerTest.php index cc7ec864..6f03f35c 100644 --- a/tests/Functional/Anonymizer/Core/StringPatternAnonymizerTest.php +++ b/tests/Functional/Anonymizer/Core/StringPatternAnonymizerTest.php @@ -62,17 +62,14 @@ public function testAnonymize(): void $checkRegex = '/^Range \d+ for [a-z0-9-]+@example\.com and .+ in [\sa-z-]+$/i'; $data = (string) $datas[0]; - self::assertNotNull($data); self::assertNotSame("Foo value", $data); self::assertMatchesRegularExpression($checkRegex, $data); $data = (string) $datas[1]; - self::assertNotNull($data); self::assertNotSame("Baz value", $data); self::assertMatchesRegularExpression($checkRegex, $data); $data = (string) $datas[2]; - self::assertNotNull($data); self::assertNotSame("Fizz value", $data); self::assertMatchesRegularExpression($checkRegex, $data); diff --git a/tests/Mock/TestingExecutionContext.php b/tests/Mock/TestingExecutionContext.php index 87c43adf..5542aebe 100644 --- a/tests/Mock/TestingExecutionContext.php +++ b/tests/Mock/TestingExecutionContext.php @@ -71,7 +71,7 @@ public function getObject(): ?object } #[\Override] - public function setNode(mixed $value, ?object $object, ?MetadataInterface $metadata, string $propertyPath): void {} + public function setNode(mixed $value, ?object $object, ?MetadataInterface $metadata = null, ?string $propertyPath = null): void {} #[\Override] public function setGroup(?string $group): void {} diff --git a/tests/Resources/Loader/TestEntity.php b/tests/Resources/Loader/TestEntity.php index 6ef754a0..9c690e5e 100644 --- a/tests/Resources/Loader/TestEntity.php +++ b/tests/Resources/Loader/TestEntity.php @@ -22,7 +22,7 @@ class TestEntity #[ORM\Id] #[ORM\GeneratedValue(strategy: "NONE")] #[ORM\Column] - private ?int $id = null; + private int|null $id = null; #[ORM\Column(length: 180, unique: true)] #[Anonymize(type:'email', options: ['domain' => 'toto.com'])] @@ -49,12 +49,19 @@ public function getId(): ?int return $this->id; } + public function setId(?int $id): static + { + $this->id = $id; + + return $this; + } + public function getEmail(): ?string { return $this->email; } - public function setEmail(string $email): static + public function setEmail(?string $email): static { $this->email = $email; @@ -66,7 +73,7 @@ public function getAge(): ?int return $this->age; } - public function setAge(int $age): static + public function setAge(?int $age): static { $this->age = $age; @@ -78,7 +85,7 @@ public function getStreet(): ?string return $this->street; } - public function setStreet(string $street): static + public function setStreet(?string $street): static { $this->street = $street; @@ -90,7 +97,7 @@ public function getZipCode(): ?string return $this->zipCode; } - public function setZipCode(string $zipCode): static + public function setZipCode(?string $zipCode): static { $this->zipCode = $zipCode; @@ -102,7 +109,7 @@ public function getCity(): ?string return $this->city; } - public function setCity(string $city): static + public function setCity(?string $city): static { $this->city = $city; @@ -114,7 +121,7 @@ public function getCountry(): ?string return $this->country; } - public function setCountry(string $country): static + public function setCountry(?string $country): static { $this->country = $country; diff --git a/tests/Resources/Loader/TestEntityWithEmbedded.php b/tests/Resources/Loader/TestEntityWithEmbedded.php index e242dadc..4c4f7b21 100644 --- a/tests/Resources/Loader/TestEntityWithEmbedded.php +++ b/tests/Resources/Loader/TestEntityWithEmbedded.php @@ -14,7 +14,7 @@ class TestEntityWithEmbedded #[ORM\Id] #[ORM\GeneratedValue(strategy: "NONE")] #[ORM\Column] - private ?int $id = null; + private int|null $id = null; #[ORM\Column(length: 180, unique: true)] #[Anonymize(type:'email', options: ['domain' => 'toto.com'])] @@ -33,13 +33,20 @@ public function getEmail(): ?string return $this->email; } - public function setEmail(string $email): static + public function setEmail(?string $email): static { $this->email = $email; return $this; } + public function setId(?int $id): static + { + $this->id = $id; + + return $this; + } + public function getEmbeddableEntity(): ?TestEmbeddableEntity { return $this->embeddableEntity; diff --git a/tests/Resources/Loader/TestJoinedChild.php b/tests/Resources/Loader/TestJoinedChild.php index 37ff0436..7b96695e 100644 --- a/tests/Resources/Loader/TestJoinedChild.php +++ b/tests/Resources/Loader/TestJoinedChild.php @@ -13,11 +13,11 @@ class TestJoinedChild extends TestJoinedParent { #[Anonymize(type: 'constant', options: ['value' => 'https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal#/media/Fichier:Myotis_crypticus_-_Manuel_Ruedi.jpg'])] #[ORM\Column(length: 255, nullable: true)] - private ?string $url = null; + private string|null $url = null; #[Anonymize(type: 'constant', options: ['value' => 'https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal#/media/Fichier:Myotis_crypticus_-_Manuel_Ruedi.jpg'])] #[ORM\Column(length: 255, nullable: true)] - private ?string $thumbnail_url = null; + private string|null $thumbnail_url = null; public function getUrl(): ?string { @@ -28,4 +28,18 @@ public function getThumbnailUrl(): ?string { return $this->thumbnail_url; } + + public function setUrl(?string $url): static + { + $this->url = $url; + + return $this; + } + + public function setThumbnailUrl(?string $thumbnailUrl): static + { + $this->thumbnail_url = $thumbnailUrl; + + return $this; + } } diff --git a/tests/Resources/Loader/TestJoinedParent.php b/tests/Resources/Loader/TestJoinedParent.php index 5a89471a..0c497883 100644 --- a/tests/Resources/Loader/TestJoinedParent.php +++ b/tests/Resources/Loader/TestJoinedParent.php @@ -19,11 +19,11 @@ class TestJoinedParent #[ORM\Id] #[ORM\GeneratedValue(strategy: "NONE")] #[ORM\Column] - private ?int $id = null; + private int|null $id = null; #[ORM\Column(length: 180, unique: true)] #[Anonymize(type:'email', options: ['domain' => 'toto.com'])] - private ?string $email = null; + private string|null $email = null; public function getId(): ?int { @@ -34,4 +34,18 @@ public function getEmail(): ?string { return $this->email; } + + public function setId(?int $id): static + { + $this->id = $id; + + return $this; + } + + public function setEmail(?string $email): static + { + $this->email = $email; + + return $this; + } } diff --git a/tests/Unit/Anonymization/Configuration/AttributeLoaderTest.php b/tests/Unit/Anonymization/Configuration/AttributeLoaderTest.php index 7625f9c7..f13ecc6e 100644 --- a/tests/Unit/Anonymization/Configuration/AttributeLoaderTest.php +++ b/tests/Unit/Anonymization/Configuration/AttributeLoaderTest.php @@ -16,6 +16,7 @@ use MakinaCorpus\DbToolsBundle\Tests\Resources\Loader\TestEntity; use MakinaCorpus\DbToolsBundle\Tests\Resources\Loader\TestEntityWithEmbedded; use MakinaCorpus\DbToolsBundle\Tests\Resources\Loader\TestJoinedChild; +use MakinaCorpus\DbToolsBundle\Tests\Resources\Loader\TestJoinedParent; class AttributeLoaderTest extends UnitTestCase { diff --git a/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php b/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php index c57d0122..85b3e49c 100644 --- a/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php +++ b/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php @@ -32,7 +32,7 @@ private function getContainer(array $parameters = [], array $bundles = []): Cont return $container; } - private function testExtension(array $config, ContainerBuilder $container = null): void + private function testExtension(array $config, ?ContainerBuilder $container = null): void { $container ??= $this->getContainer(); $extension = new DbToolsExtension();