| Conditions | 1 |
| Paths | 1 |
| Total Lines | 81 |
| Code Lines | 48 |
| 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 |
||
| 25 | public function provideGetIncluded(): iterable |
||
| 26 | { |
||
| 27 | yield "no includes" => [__FILE__, [], []]; |
||
| 28 | yield "simple include" => [__FILE__, ['anywhere/here.php'], [__DIR__ . '/anywhere/here.php']]; |
||
| 29 | yield "simple absolute include" => [__FILE__, ['/anywhere/here.php'], ['/anywhere/here.php']]; |
||
| 30 | yield "simple String_ include" => [ |
||
| 31 | __FILE__, |
||
| 32 | [new String_('anywhere/here.php')], |
||
| 33 | [__DIR__ . '/anywhere/here.php'] |
||
| 34 | ]; |
||
| 35 | yield "absolute include by DIR" => [ |
||
| 36 | __FILE__, |
||
| 37 | [ |
||
| 38 | new Concat( |
||
| 39 | new Dir(), |
||
| 40 | new String_('anywhere/here.php') |
||
| 41 | ) |
||
| 42 | ], |
||
| 43 | [__DIR__ . 'anywhere/here.php'] |
||
| 44 | ]; |
||
| 45 | yield "absolute include by FILE" => [ |
||
| 46 | __FILE__, |
||
| 47 | [ |
||
| 48 | new Concat( |
||
| 49 | new File(), |
||
| 50 | new String_('anywhere/here.php') |
||
| 51 | ) |
||
| 52 | ], |
||
| 53 | [__FILE__ . 'anywhere/here.php'] |
||
| 54 | ]; |
||
| 55 | yield "includes with variables" => [ |
||
| 56 | __FILE__, |
||
| 57 | [ |
||
| 58 | new Concat( |
||
| 59 | new ConstFetch(new Name("NAME")), |
||
| 60 | new String_('.php') |
||
| 61 | ) |
||
| 62 | ], |
||
| 63 | [ |
||
| 64 | __DIR__ . DIRECTORY_SEPARATOR . 'DefinedSymbolCollectorFunctionalTest.php', |
||
| 65 | __DIR__ . DIRECTORY_SEPARATOR . 'DefinedSymbolCollectorTest.php', |
||
| 66 | __DIR__ . DIRECTORY_SEPARATOR . 'UsedSymbolCollectorFunctionalTest.php', |
||
| 67 | __DIR__ . DIRECTORY_SEPARATOR . 'UsedSymbolCollectorTest.php' |
||
| 68 | ] |
||
| 69 | ]; |
||
| 70 | yield "includes with constants" => [ |
||
| 71 | __FILE__, |
||
| 72 | [ |
||
| 73 | new Concat( |
||
| 74 | new Variable(new Name('name')), |
||
| 75 | new String_('.php') |
||
| 76 | ) |
||
| 77 | ], |
||
| 78 | [ |
||
| 79 | __DIR__ . DIRECTORY_SEPARATOR . 'DefinedSymbolCollectorFunctionalTest.php', |
||
| 80 | __DIR__ . DIRECTORY_SEPARATOR . 'DefinedSymbolCollectorTest.php', |
||
| 81 | __DIR__ . DIRECTORY_SEPARATOR . 'UsedSymbolCollectorFunctionalTest.php', |
||
| 82 | __DIR__ . DIRECTORY_SEPARATOR . 'UsedSymbolCollectorTest.php' |
||
| 83 | ] |
||
| 84 | ]; |
||
| 85 | yield "includes with DIRECTORY_SEPARATOR" => [ |
||
| 86 | __FILE__, |
||
| 87 | [ |
||
| 88 | new Concat( |
||
| 89 | new Dir(), |
||
| 90 | new Concat( |
||
| 91 | new ConstFetch(new Name('DIRECTORY_SEPARATOR')), |
||
| 92 | new String_('Example.php') |
||
| 93 | ) |
||
| 94 | ) |
||
| 95 | ], |
||
| 96 | [ |
||
| 97 | __DIR__ . DIRECTORY_SEPARATOR . 'Example.php' |
||
| 98 | ] |
||
| 99 | ]; |
||
| 100 | yield "includes with invalid node" => [ |
||
| 101 | __FILE__, |
||
| 102 | [ |
||
| 103 | new Expression(new String_('')) |
||
| 104 | ], |
||
| 105 | [] |
||
| 106 | ]; |
||
| 173 |