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