| Conditions | 11 |
| Paths | 24 |
| Total Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 21 | public function process(ContainerBuilder $container) |
||
| 22 | { |
||
| 23 | $blacklist = []; |
||
| 24 | |||
| 25 | foreach ($container->getDefinitions() as $definition) { |
||
| 26 | if ($definition->isAbstract() || $definition->isSynthetic()) { |
||
| 27 | continue; |
||
| 28 | } |
||
| 29 | |||
| 30 | switch ($definition->getClass()) { |
||
| 31 | case PdoAdapter::class: |
||
| 32 | $blacklist[] = $definition->getArguments()[3]['db_table'] ?? 'cache_items'; |
||
| 33 | break; |
||
| 34 | |||
| 35 | case PdoSessionHandler::class: |
||
| 36 | $blacklist[] = $definition->getArguments()[1]['db_table'] ?? 'sessions'; |
||
| 37 | break; |
||
| 38 | |||
| 39 | case PdoStore::class: |
||
| 40 | $blacklist[] = $definition->getArguments()[1]['db_table'] ?? 'lock_keys'; |
||
| 41 | break; |
||
| 42 | |||
| 43 | case LegacyConnection::class: |
||
| 44 | case Connection::class: |
||
| 45 | $blacklist[] = $definition->getArguments()[0]['table_name'] ?? 'messenger_messages'; |
||
| 46 | break; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | if (! $blacklist) { |
||
|
|
|||
| 51 | return; |
||
| 52 | } |
||
| 53 | |||
| 54 | $definition = $container->getDefinition('doctrine.dbal.well_known_schema_asset_filter'); |
||
| 55 | $definition->replaceArgument(0, $blacklist); |
||
| 56 | |||
| 57 | foreach (array_keys($container->getParameter('doctrine.connections')) as $name) { |
||
| 58 | $definition->addTag('doctrine.dbal.schema_filter', ['connection' => $name]); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |
||
| 62 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.