‪TYPO3CMS  9.5
PhpErrorCodeViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
20 
26 class ‪PhpErrorCodeViewHelper extends AbstractViewHelper
27 {
28  use CompileWithRenderStatic;
29 
33  protected static ‪$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 
54  public function ‪initializeArguments()
55  {
56  $this->registerArgument('phpErrorCode', 'int', '', true);
57  }
58 
68  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
69  {
70  $phpErrorCode = (int)$arguments['phpErrorCode'];
71  $levels = [];
72  if (($phpErrorCode & E_ALL) == E_ALL) {
73  $levels[] = 'E_ALL';
74  $phpErrorCode &= ~E_ALL;
75  }
76  foreach (self::$levelNames as $level => $name) {
77  if (($phpErrorCode & $level) == $level) {
78  $levels[] = $name;
79  }
80  }
81 
82  ‪$output = '';
83  if (!empty($levels)) {
84  ‪$output = implode(' | ', $levels);
85  }
86 
87  return ‪$output;
88  }
89 }
‪TYPO3\CMS\Install\ViewHelpers\Format
Definition: NoSpaceViewHelper.php:2
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PhpErrorCodeViewHelper.php:66
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper
Definition: PhpErrorCodeViewHelper.php:27
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\$levelNames
‪static array $levelNames
Definition: PhpErrorCodeViewHelper.php:31
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\initializeArguments
‪initializeArguments()
Definition: PhpErrorCodeViewHelper.php:52
‪$output
‪$output
Definition: annotationChecker.php:113