Total Complexity | 6 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 94.12% |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
22 | class CronLogHandler extends AbstractProcessingHandler { |
||
23 | |||
24 | protected ?OutputInterface $stdout; |
||
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | 3 | public function __construct(bool $bubble = true) { |
|
30 | 3 | if (!Application::isCli()) { |
|
31 | throw new Exception(__CLASS__ . ' can only be used during CLI'); |
||
32 | } |
||
33 | |||
34 | 3 | $this->stdout = _elgg_services()->cli_output; |
|
35 | |||
36 | 3 | $level = Level::Emergency; |
|
37 | 3 | if ($this->stdout->getVerbosity() !== OutputInterface::VERBOSITY_QUIET) { |
|
38 | 2 | $level = Level::Debug; |
|
39 | } |
||
40 | |||
41 | 3 | parent::__construct($level, $bubble); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 2 | protected function write(LogRecord $record): void { |
|
48 | 2 | $this->stdout->write($record->formatted); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | 2 | public function getDefaultFormatter(): FormatterInterface { |
|
55 | 2 | $formatter = new ElggLogFormatter(); |
|
56 | 2 | $formatter->allowInlineLineBreaks(); |
|
57 | 2 | $formatter->ignoreEmptyContextAndExtra(); |
|
58 | |||
59 | 2 | return $formatter; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 3 | public function close(): void { |
|
67 | } |
||
68 | } |
||
69 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: