‪TYPO3CMS  ‪main
PhpErrorCodeViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
23 
29 final class ‪PhpErrorCodeViewHelper extends AbstractViewHelper
30 {
31  use CompileWithRenderStatic;
32 
33  protected static array ‪$levelNames = [
34  E_ERROR => 'E_ERROR',
35  E_WARNING => 'E_WARNING',
36  E_PARSE => 'E_PARSE',
37  E_NOTICE => 'E_NOTICE',
38  E_CORE_ERROR => 'E_CORE_ERROR',
39  E_CORE_WARNING => 'E_CORE_WARNING',
40  E_COMPILE_ERROR => 'E_COMPILE_ERROR',
41  E_COMPILE_WARNING => 'E_COMPILE_WARNING',
42  E_USER_ERROR => 'E_USER_ERROR',
43  E_USER_WARNING => 'E_USER_WARNING',
44  E_USER_NOTICE => 'E_USER_NOTICE',
45  E_STRICT => 'E_STRICT',
46  E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
47  E_DEPRECATED => 'E_DEPRECATED',
48  E_USER_DEPRECATED => 'E_USER_DEPRECATED',
49  ];
50 
51  public function ‪initializeArguments(): void
52  {
53  $this->registerArgument('phpErrorCode', 'int', '', true);
54  }
55 
59  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
60  {
61  $phpErrorCode = (int)$arguments['phpErrorCode'];
62  $levels = [];
63  if (($phpErrorCode & E_ALL) == E_ALL) {
64  $levels[] = 'E_ALL';
65  $phpErrorCode &= ~E_ALL;
66  }
67  foreach (self::$levelNames as $level => ‪$name) {
68  if (($phpErrorCode & $level) == $level) {
69  $levels[] = ‪$name;
70  }
71  }
72 
73  $output = '';
74  if (!empty($levels)) {
75  $output = implode(' | ', $levels);
76  }
77 
78  return $output;
79  }
80 }
‪TYPO3\CMS\Install\ViewHelpers\Format
Definition: NoSpaceViewHelper.php:18
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper
Definition: PhpErrorCodeViewHelper.php:30
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PhpErrorCodeViewHelper.php:58
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\$levelNames
‪static array $levelNames
Definition: PhpErrorCodeViewHelper.php:32
‪$name
‪$name
Definition: phpIntegrityChecker.php:235
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\initializeArguments
‪initializeArguments()
Definition: PhpErrorCodeViewHelper.php:50