| Conditions | 6 |
| Paths | 4 |
| Total Lines | 64 |
| Code Lines | 38 |
| 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 |
||
| 55 | public function setUp() |
||
| 56 | { |
||
| 57 | $root = __DIR__ . '/-app-/'; |
||
| 58 | $this->app = TestApplication::init( |
||
|
|
|||
| 59 | [ |
||
| 60 | 'root' => $root, |
||
| 61 | 'libraries' => dirname(__DIR__) . '/vendor/', |
||
| 62 | 'application' => $root, |
||
| 63 | 'framework' => dirname(__DIR__) . '/source/', |
||
| 64 | 'runtime' => $root . 'runtime/', |
||
| 65 | 'cache' => $root . 'runtime/cache/', |
||
| 66 | ], |
||
| 67 | null, |
||
| 68 | null, |
||
| 69 | false |
||
| 70 | ); |
||
| 71 | |||
| 72 | //Monolog love to write to CLI when no handler set |
||
| 73 | $this->app->logs->debugHandler(new NullHandler()); |
||
| 74 | $this->app->container->bind('factory', $this->app->container); |
||
| 75 | |||
| 76 | $files = $this->app->files; |
||
| 77 | |||
| 78 | //Ensure runtime is clean |
||
| 79 | foreach ($files->getFiles($this->app->directory('runtime')) as $filename) { |
||
| 80 | //If exception is thrown here this will mean that application wasn't correctly |
||
| 81 | //destructed and there is open resources kept |
||
| 82 | $files->delete($filename); |
||
| 83 | } |
||
| 84 | |||
| 85 | $builder = $this->orm->schemaBuilder(true); |
||
| 86 | $builder->renderSchema(); |
||
| 87 | $builder->pushSchema(); |
||
| 88 | $this->orm->setSchema($builder); |
||
| 89 | |||
| 90 | if ($this->app->getEnvironment()->get('DEBUG')) { |
||
| 91 | $this->app->db->getDriver()->setLogger(new class implements LoggerInterface |
||
| 92 | { |
||
| 93 | use LoggerTrait; |
||
| 94 | |||
| 95 | public function log($level, $message, array $context = []) |
||
| 96 | { |
||
| 97 | if ($level == LogLevel::ERROR) { |
||
| 98 | echo " \n! \033[31m" . $message . "\033[0m"; |
||
| 99 | } elseif ($level == LogLevel::ALERT) { |
||
| 100 | echo " \n! \033[35m" . $message . "\033[0m"; |
||
| 101 | } elseif (strpos($message, 'PRAGMA') === 0) { |
||
| 102 | echo " \n> \033[34m" . $message . "\033[0m"; |
||
| 103 | } else { |
||
| 104 | if (strpos($message, 'SELECT') === 0) { |
||
| 105 | echo " \n> \033[32m" . $message . "\033[0m"; |
||
| 106 | } else { |
||
| 107 | echo " \n> \033[33m" . $message . "\033[0m"; |
||
| 108 | } |
||
| 109 | } |
||
| 110 | } |
||
| 111 | }); |
||
| 112 | } |
||
| 113 | |||
| 114 | clearstatcache(); |
||
| 115 | |||
| 116 | //Open application scope |
||
| 117 | TestApplication::shareContainer($this->app->container); |
||
| 118 | } |
||
| 119 | |||
| 175 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..