| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 39 |
| 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 |
||
| 22 | public function testFullConfig() : void |
||
| 23 | { |
||
| 24 | $container = $this->getContainer(); |
||
| 25 | $extension = new DoctrineMigrationsExtension(); |
||
| 26 | |||
| 27 | $config = [ |
||
| 28 | 'name' => 'Doctrine Sandbox Migrations', |
||
| 29 | 'storage' => [ |
||
| 30 | 'table_storage' => [ |
||
| 31 | 'table_name' => 'doctrine_migration_versions_test', |
||
| 32 | 'version_column_name' => 'doctrine_migration_column_test', |
||
| 33 | 'version_column_length' => 2000, |
||
| 34 | 'executed_at_column_name' => 'doctrine_migration_executed_at_column_test', |
||
| 35 | 'execution_time_column_name' => 'doctrine_migration_execution_time_column_test', |
||
| 36 | ], |
||
| 37 | ], |
||
| 38 | |||
| 39 | 'migrations_paths' => [ |
||
| 40 | 'DoctrineMigrationsTest' => 'a', |
||
| 41 | 'DoctrineMigrationsTest2' => 'b', |
||
| 42 | ], |
||
| 43 | |||
| 44 | 'migrations' => ['Foo', 'Bar'], |
||
| 45 | |||
| 46 | 'organize_migrations' => 'BY_YEAR_AND_MONTH', |
||
| 47 | |||
| 48 | 'all_or_nothing' => true, |
||
| 49 | 'check_database_platform' => true, |
||
| 50 | ]; |
||
| 51 | |||
| 52 | $extension->load(['doctrine_migrations' => $config], $container); |
||
| 53 | |||
| 54 | $container->getDefinition('doctrine.migrations.configuration')->setPublic(true); |
||
| 55 | $container->compile(); |
||
| 56 | /** |
||
| 57 | * @var $config Configuration |
||
| 58 | */ |
||
| 59 | $config = $container->get('doctrine.migrations.configuration'); |
||
| 60 | |||
| 61 | self::isInstanceOf(Configuration::class, $config); |
||
|
|
|||
| 62 | self::assertSame('Doctrine Sandbox Migrations', $config->getName()); |
||
| 63 | self::assertSame([ |
||
| 64 | 'DoctrineMigrationsTest' => 'a', |
||
| 65 | 'DoctrineMigrationsTest2' => 'b', |
||
| 66 | |||
| 67 | ], $config->getMigrationDirectories()); |
||
| 68 | |||
| 69 | self::assertSame(['Foo', 'Bar'], $config->getMigrationClasses()); |
||
| 70 | self::assertSame(true, $config->isAllOrNothing()); |
||
| 71 | self::assertSame(true, $config->isDatabasePlatformChecked()); |
||
| 72 | self::assertSame(true, $config->areMigrationsOrganizedByYearAndMonth()); |
||
| 73 | |||
| 74 | $storage = $config->getMetadataStorageConfiguration(); |
||
| 75 | self::assertInstanceOf(TableMetadataStorageConfiguration::class, $storage); |
||
| 76 | |||
| 77 | self::assertSame('doctrine_migration_versions_test', $storage->getTableName()); |
||
| 78 | self::assertSame('doctrine_migration_column_test', $storage->getVersionColumnName()); |
||
| 79 | self::assertSame(2000, $storage->getVersionColumnLength()); |
||
| 80 | self::assertSame('doctrine_migration_execution_time_column_test', $storage->getExecutionTimeColumnName()); |
||
| 81 | self::assertSame('doctrine_migration_executed_at_column_test', $storage->getExecutedAtColumnName()); |
||
| 82 | } |
||
| 208 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.