Skip to content

Commit ebcba54

Browse files
committed
Add support for Symfony 8
1 parent 2c5b338 commit ebcba54

11 files changed

Lines changed: 25 additions & 92 deletions

File tree

composer.json

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,45 @@
99
"Audit"
1010
],
1111
"require": {
12-
"php": "^8.1",
12+
"php": "^8.2",
1313
"doctrine/collections": "^1.8 || ^2.0",
1414
"doctrine/dbal": "^3.6 || ^4.0",
1515
"doctrine/event-manager": "^1.2 || ^2.0",
1616
"doctrine/orm": "^2.14 || ^3.0",
1717
"doctrine/persistence": "^3.0 || ^4.0",
1818
"psr/clock": "^1.0",
19-
"symfony/config": "^6.4 || ^7.1",
20-
"symfony/dependency-injection": "^6.4 || ^7.1",
21-
"symfony/http-kernel": "^6.4 || ^7.1",
22-
"symfony/security-core": "^6.4 || ^7.1",
19+
"symfony/config": "^6.4 || ^7.3 || ^8.0",
20+
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
21+
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
22+
"symfony/security-core": "^6.4 || ^7.3 || ^8.0",
2323
"twig/twig": "^3.0"
2424
},
2525
"require-dev": {
2626
"doctrine/doctrine-bundle": "^2.17 || ^3.0",
2727
"doctrine/doctrine-fixtures-bundle": "^4.2",
2828
"friendsofphp/php-cs-fixer": "^3.4",
2929
"gedmo/doctrine-extensions": "^3.15",
30-
"matthiasnoback/symfony-dependency-injection-test": "^6.1",
30+
"matthiasnoback/symfony-dependency-injection-test": "^6.2",
3131
"phpstan/extension-installer": "^1.1",
3232
"phpstan/phpstan": "^1.0 || ^2.0",
3333
"phpstan/phpstan-doctrine": "^1.3.12 || ^2.0",
3434
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
3535
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
3636
"phpstan/phpstan-symfony": "^1.0 || ^2.0",
37-
"phpunit/phpunit": "^10.5.54 || ^11.5.38 || ^12.3.10",
38-
"psalm/plugin-phpunit": "^0.18 || ^0.19",
39-
"psalm/plugin-symfony": "^5.0",
37+
"phpunit/phpunit": "^11.5.38 || ^12.3.10",
4038
"rector/rector": "^1.1 || ^2.0",
41-
"symfony/browser-kit": "^6.4 || ^7.1",
42-
"symfony/cache": "^6.4 || ^7.1",
43-
"symfony/filesystem": "^6.4 || ^7.1",
44-
"symfony/framework-bundle": "^6.4 || ^7.1",
45-
"symfony/http-foundation": "^6.4 || ^7.1",
46-
"symfony/security-bundle": "^6.4 || ^7.1",
47-
"symfony/twig-bundle": "^6.4 || ^7.1",
48-
"symfony/var-dumper": "^6.4 || ^7.1",
49-
"vimeo/psalm": "^5.7 || ^6.10"
39+
"symfony/browser-kit": "^6.4 || ^7.3 || ^8.0",
40+
"symfony/cache": "^6.4 || ^7.3 || ^8.0",
41+
"symfony/filesystem": "^6.4 || ^7.3 || ^8.0",
42+
"symfony/framework-bundle": "^6.4 || ^7.3 || ^8.0",
43+
"symfony/http-foundation": "^6.4 || ^7.3 || ^8.0",
44+
"symfony/security-bundle": "^6.4 || ^7.3 || ^8.0",
45+
"symfony/twig-bundle": "^6.4 || ^7.3 || ^8.0",
46+
"symfony/var-dumper": "^6.4 || ^7.3 || ^8.0"
5047
},
5148
"conflict": {
5249
"doctrine/doctrine-bundle": "<2.7",
5350
"gedmo/doctrine-extensions": "<3.7",
54-
"symfony/framework-bundle": "<5.4",
5551
"symfony/string": "5.4.0-BETA1 || 5.4.0-RC1"
5652
},
5753
"minimum-stability": "dev",

psalm-baseline.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

psalm.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/AuditConfiguration.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ public static function forEntities(array $classes)
8181
* @return string
8282
*
8383
* @phpstan-return literal-string
84-
*
85-
* @psalm-suppress MoreSpecificReturnType,LessSpecificReturnStatement https://github.com/vimeo/psalm/issues/10910
8684
*/
8785
public function getTableName(ClassMetadata $metadata)
8886
{

src/AuditReader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,8 @@ private function createEntity($className, array $columnMap, array $data, $revisi
842842
&& null !== $classMetadata->discriminatorColumn
843843
) {
844844
$discriminator = $data[self::getMappingNameValue($classMetadata->discriminatorColumn)];
845-
if (!isset($classMetadata->discriminatorMap[$discriminator])) {
846-
throw new \RuntimeException("No mapping found for [{$discriminator}].");
845+
if (null === $discriminator || !isset($classMetadata->discriminatorMap[$discriminator])) {
846+
throw new \RuntimeException("No mapping found for [$discriminator].");
847847
}
848848

849849
if (isset($classMetadata->discriminatorValue)) {

src/Collection/AuditedCollection.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public function contains(mixed $element)
115115
* @return bool
116116
*
117117
* @psalm-mutation-free See https://github.com/psalm/psalm-plugin-doctrine/issues/97
118-
*
119-
* @psalm-suppress ImpureMethodCall
120118
*/
121119
#[\ReturnTypeWillChange]
122120
public function isEmpty()
@@ -442,8 +440,6 @@ public function offsetUnset(mixed $offset): void
442440

443441
/**
444442
* @return int<0, max>
445-
*
446-
* @psalm-suppress LessSpecificReturnStatement, MoreSpecificReturnType, UnusedPsalmSuppress
447443
*/
448444
#[\ReturnTypeWillChange]
449445
public function count()

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class Configuration implements ConfigurationInterface
3333
];
3434

3535
/**
36-
* @psalm-suppress UndefinedInterfaceMethod
37-
*
38-
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
36+
* @return TreeBuilder<'array'>
3937
*/
4038
public function getConfigTreeBuilder(): TreeBuilder
4139
{

src/EventListener/CreateSchemaListener.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ public function getSubscribedEvents()
7373
];
7474
}
7575

76-
/**
77-
* @psalm-suppress TypeDoesNotContainType, NoValue
78-
*/
7976
public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs): void
8077
{
8178
$cm = $eventArgs->getClassMetadata();
@@ -104,7 +101,6 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs)
104101
if ($this->isDbal4_3()) {
105102
$tableName = $this->config->getTablePrefix().$entityTable->getObjectName()->toString().$this->config->getTableSuffix();
106103
} else {
107-
/** @psalm-suppress InternalMethod */
108104
$tableName = $this->config->getTablePrefix().$entityTable->getName().$this->config->getTableSuffix(); // @phpstan-ignore-line
109105
}
110106
$revisionTable = $schema->createTable($tableName);
@@ -122,24 +118,19 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs)
122118
$primaryKey = $entityTable->getPrimaryKeyConstraint();
123119
\assert(null !== $primaryKey);
124120
$pkColumns = $primaryKey->getColumnNames();
125-
/** @psalm-suppress ArgumentTypeCoercion */
126121
$pkColumns[] = new UnqualifiedName(Identifier::unquoted($this->config->getRevisionFieldName())); // @phpstan-ignore-line
127122
$editor = PrimaryKeyConstraint::editor()->setColumnNames(...$pkColumns)->setIsClustered($primaryKey->isClustered());
128123
$revisionTable->addPrimaryKeyConstraint($editor->create());
129124
} else {
130-
/** @psalm-suppress DeprecatedMethod */
131125
$primaryKey = $entityTable->getPrimaryKey();
132126
\assert(null !== $primaryKey);
133-
/** @psalm-suppress DeprecatedMethod */
134127
$pkColumns = $primaryKey->getColumns();
135128
$pkColumns[] = $this->config->getRevisionFieldName();
136-
/** @psalm-suppress DeprecatedMethod */
137129
$revisionTable->setPrimaryKey($pkColumns);
138130
}
139131
if ($this->isDbal4_3()) {
140132
$revIndexName = $this->config->getRevisionFieldName().'_'.md5($revisionTable->getObjectName()->toString()).'_idx';
141133
} else {
142-
/** @psalm-suppress InternalMethod */
143134
$revIndexName = $this->config->getRevisionFieldName().'_'.md5($revisionTable->getName()).'_idx'; // @phpstan-ignore-line
144135
}
145136
$revisionTable->addIndex([$this->config->getRevisionFieldName()], $revIndexName);
@@ -183,13 +174,9 @@ private function createForeignKeys(Table $relatedTable, Table $revisionsTable):
183174
$revisionForeignKeyName
184175
);
185176
} elseif ($this->isDbal4()) {
186-
/** @psalm-suppress InternalMethod */
187177
$revisionForeignKeyName = $this->config->getRevisionFieldName().'_'.md5($relatedTable->getName()).'_fk'; // @phpstan-ignore-line
188-
/** @psalm-suppress DeprecatedMethod */
189178
$primaryKey = $revisionsTable->getPrimaryKey();
190179
\assert(null !== $primaryKey);
191-
/** @psalm-suppress InternalMethod */
192-
/** @psalm-suppress DeprecatedMethod */
193180
$relatedTable->addForeignKeyConstraint(
194181
$revisionsTable->getName(), // @phpstan-ignore-line
195182
[$this->config->getRevisionFieldName()],
@@ -198,13 +185,9 @@ private function createForeignKeys(Table $relatedTable, Table $revisionsTable):
198185
$revisionForeignKeyName
199186
);
200187
} else {
201-
/** @psalm-suppress InternalMethod */
202188
$revisionForeignKeyName = $this->config->getRevisionFieldName().'_'.md5($relatedTable->getName()).'_fk'; // @phpstan-ignore-line
203-
/** @psalm-suppress DeprecatedMethod */
204189
$primaryKey = $revisionsTable->getPrimaryKey();
205190
\assert(null !== $primaryKey);
206-
/** @psalm-suppress DeprecatedMethod */
207-
/** @psalm-suppress InvalidArgument */
208191
$relatedTable->addForeignKeyConstraint(
209192
$revisionsTable, // @phpstan-ignore-line doctrine/dbal 3 support for old addForeignKeyConstraint() signature
210193
[$this->config->getRevisionFieldName()],
@@ -223,7 +206,6 @@ private function addColumnToTable(Column $column, Table $targetTable): void
223206
if ($this->isDbal4_3()) {
224207
$columnName = $column->getObjectName()->toString();
225208
} else {
226-
/** @psalm-suppress InternalMethod */
227209
$columnName = $column->getName(); // @phpstan-ignore-line
228210
}
229211

@@ -246,7 +228,6 @@ private function addColumnToTable(Column $column, Table $targetTable): void
246228
if ($this->isDbal4_3()) {
247229
$targetColumn->setPlatformOptions(['charset' => $column->getCharset(), 'collation' => $column->getCollation()]);
248230
} else {
249-
/** @psalm-suppress DeprecatedMethod */
250231
$targetColumn->setPlatformOptions($column->getPlatformOptions());
251232
}
252233

@@ -273,7 +254,6 @@ private function createRevisionsTable(Schema $schema): Table
273254
$editor = PrimaryKeyConstraint::editor()->setColumnNames($id)->setIsClustered(true);
274255
$revisionsTable->addPrimaryKeyConstraint($editor->create());
275256
} else {
276-
/** @psalm-suppress DeprecatedMethod */
277257
$revisionsTable->setPrimaryKey(['id']);
278258
}
279259

@@ -286,7 +266,6 @@ private function createRevisionJoinTableForJoinTable(Schema $schema, string $joi
286266
if ($this->isDbal4_3()) {
287267
$revisionJoinTableName = $this->config->getTablePrefix().$joinTable->getObjectName()->toString().$this->config->getTableSuffix();
288268
} else {
289-
/** @psalm-suppress InternalMethod */
290269
$revisionJoinTableName = $this->config->getTablePrefix().$joinTable->getName().$this->config->getTableSuffix(); // @phpstan-ignore-line
291270
}
292271

@@ -298,7 +277,6 @@ private function createRevisionJoinTableForJoinTable(Schema $schema, string $joi
298277
if ($this->isDbal4_3()) {
299278
$tableName = $this->config->getTablePrefix().$joinTable->getObjectName()->toString().$this->config->getTableSuffix();
300279
} else {
301-
/** @psalm-suppress InternalMethod */
302280
$tableName = $this->config->getTablePrefix().$joinTable->getName().$this->config->getTableSuffix(); // @phpstan-ignore-line
303281
}
304282
$revisionJoinTable = $schema->createTable($tableName);
@@ -311,7 +289,6 @@ private function createRevisionJoinTableForJoinTable(Schema $schema, string $joi
311289
if ($this->isDbal4_3()) {
312290
$revisionJoinTable->addColumn($column->getObjectName()->toString(), $typeRegistry->lookupName($column->getType()), $options);
313291
} else {
314-
/** @psalm-suppress InternalMethod */
315292
$revisionJoinTable->addColumn($column->getName(), $typeRegistry->lookupName($column->getType()), $options); // @phpstan-ignore-line
316293
}
317294
}
@@ -321,23 +298,18 @@ private function createRevisionJoinTableForJoinTable(Schema $schema, string $joi
321298
if ($this->isDbal4_3()) {
322299
$pk = $joinTable->getPrimaryKeyConstraint();
323300
$pkColumns = null !== $pk ? $pk->getColumnNames() : [];
324-
/** @psalm-suppress ArgumentTypeCoercion */
325301
$pkColumns[] = new UnqualifiedName(Identifier::unquoted($this->config->getRevisionFieldName())); // @phpstan-ignore-line
326302
$editor = PrimaryKeyConstraint::editor()->setColumnNames(...$pkColumns)->setIsClustered(!(null !== $pk) || $pk->isClustered());
327303
$revisionJoinTable->addPrimaryKeyConstraint($editor->create());
328304
} else {
329-
/** @psalm-suppress DeprecatedMethod */
330305
$pk = $joinTable->getPrimaryKey();
331-
/** @psalm-suppress DeprecatedMethod */
332306
$pkColumns = null !== $pk ? $pk->getColumns() : [];
333307
$pkColumns[] = $this->config->getRevisionFieldName();
334-
/** @psalm-suppress DeprecatedMethod */
335308
$revisionJoinTable->setPrimaryKey($pkColumns);
336309
}
337310
if ($this->isDbal4_3()) {
338311
$revIndexName = $this->config->getRevisionFieldName().'_'.md5($revisionJoinTable->getObjectName()->toString()).'_idx';
339312
} else {
340-
/** @psalm-suppress InternalMethod */
341313
$revIndexName = $this->config->getRevisionFieldName().'_'.md5($revisionJoinTable->getName()).'_idx'; // @phpstan-ignore-line
342314
}
343315
$revisionJoinTable->addIndex([$this->config->getRevisionFieldName()], $revIndexName);

src/EventListener/LogRevisionsListener.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ public function postFlush(PostFlushEventArgs $eventArgs): void
203203
$sql .= ' AND '.$columnName.' = ?';
204204
}
205205

206-
/** @psalm-suppress InvalidArgument for doctrine/dbal 3 type can be integer */
207206
$em->getConnection()->executeQuery($sql, $params, $types);
208207
}
209208

@@ -388,7 +387,6 @@ private function getRevisionId(Connection $conn)
388387
/*
389388
* NEXT_MAJOR: Remove this `if` block, because lastInsertId throws an exception in DBAL 4
390389
*/
391-
/** @psalm-suppress TypeDoesNotContainType */
392390
if (false === $revisionId) { // @phpstan-ignore-line doctrine/dbal 3 lastInsertId() can return false
393391
throw new \RuntimeException('Unable to retrieve the last revision id.');
394392
}
@@ -636,7 +634,6 @@ private function saveRevisionEntityData(EntityManagerInterface $em, ClassMetadat
636634
}
637635
}
638636

639-
/** @psalm-suppress InvalidArgument for doctrine/dbal 3 type can be integer */
640637
$conn->executeStatement($this->getInsertRevisionSQL($em, $class), $params, $types);
641638
}
642639

@@ -672,7 +669,6 @@ private function recordRevisionForManyToManyEntity(
672669
$joinTableParams[] = $targetClass->getFieldValue($relatedEntity, $targetClass->fieldNames[$targetColumn]);
673670
$joinTableTypes[] = PersisterHelper::getTypeOfColumn($targetColumn, $targetClass, $em);
674671
}
675-
/** @psalm-suppress InvalidArgument for doctrine/dbal 3 type can be integer */
676672
$conn->executeStatement(
677673
$this->getInsertJoinTableRevisionSQL($class, $targetClass, $assoc),
678674
$joinTableParams,

src/Resources/config/routing/audit.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
return static function (RoutingConfigurator $routes) {
2323
foreach (debug_backtrace() as $trace) {
2424
if (isset($trace['object'], $trace['args'])
25+
/* @phpstan-ignore class.notFound */
2526
&& $trace['object'] instanceof XmlFileLoader
2627
&& $trace['args'][0] === __DIR__.'/audit.php'
2728
&& $trace['args'][3] === __DIR__.'/audit.xml'

0 commit comments

Comments
 (0)