@@ -16,13 +16,15 @@ class OnlyOrmTablesFilter
1616 /** @var string[]|null */
1717 private ?array $ allowPrefixes = null ;
1818
19- public function __construct (private readonly EntityManagerInterface $ entityManager ) {}
19+ public function __construct (private readonly EntityManagerInterface $ entityManager )
20+ {
21+ }
2022
2123 public function __invoke (string |AbstractAsset $ asset ): bool
2224 {
2325 $ name = \is_string ($ asset ) ? $ asset : $ asset ->getName ();
24-
25- if (false !== ( $ pos = strrpos ( $ name , ' . ' )) ) {
26+ $ pos = strrpos ( $ name , ' . ' );
27+ if (false !== $ pos ) {
2628 $ name = substr ($ name , $ pos + 1 );
2729 }
2830 $ nameLower = strtolower ($ name );
@@ -56,12 +58,13 @@ private function buildAllowOnce(): array
5658 }
5759
5860 $ tables = [];
59- foreach ($ this ->entityManager ->getMetadataFactory ()->getAllMetadata () as $ m ) {
60- if ($ t = $ m ->getTableName ()) {
61- $ tables [] = strtolower ($ t );
61+ foreach ($ this ->entityManager ->getMetadataFactory ()->getAllMetadata () as $ metadatum ) {
62+ $ tableName = $ metadatum ->getTableName ();
63+ if ($ tableName ) {
64+ $ tables [] = strtolower ($ tableName );
6265 }
6366 // many-to-many join tables
64- foreach ($ m ->getAssociationMappings () as $ assoc ) {
67+ foreach ($ metadatum ->getAssociationMappings () as $ assoc ) {
6568 if (!empty ($ assoc ['joinTable ' ]['name ' ])) {
6669 $ tables [] = strtolower ($ assoc ['joinTable ' ]['name ' ]);
6770 }
@@ -71,7 +74,7 @@ private function buildAllowOnce(): array
7174 $ tables [] = 'doctrine_migration_versions ' ;
7275
7376 $ tables = array_values (array_unique ($ tables ));
74- $ prefixes = array_map (static fn ($ t ) => $ t . '_ ' , $ tables );
77+ $ prefixes = array_map (static fn ($ table ) => $ table . '_ ' , $ tables );
7578
7679 $ this ->allow = $ tables ;
7780 $ this ->allowPrefixes = $ prefixes ;
0 commit comments