1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | /* |
||||
6 | * This file is part of Biurad opensource projects. |
||||
7 | * |
||||
8 | * PHP version 7.2 and above required |
||||
9 | * |
||||
10 | * @author Divine Niiquaye Ibok <[email protected]> |
||||
11 | * @copyright 2019 Biurad Group (https://biurad.com/) |
||||
12 | * @license https://opensource.org/licenses/BSD-3-Clause License |
||||
13 | * |
||||
14 | * For the full copyright and license information, please view the LICENSE |
||||
15 | * file that was distributed with this source code. |
||||
16 | */ |
||||
17 | |||||
18 | namespace Biurad\UI\Exceptions; |
||||
19 | |||||
20 | class ParserException extends \ParseError |
||||
21 | { |
||||
22 | public static function forTagWithParent(string $tagName, ?string $attrName = null, ?string $parent = null, bool $first = false, bool $void = false, bool $voidAttr = false): self |
||||
23 | { |
||||
24 | $errorMessage = 'Tag "%s" ' . (!empty($parent) ? ('must be inside a tag with attribute "%s"' . ($first ? ' as the first' : '')) : ('' === $parent ? $parent : 'is unexpected here')); |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
25 | $errorArgs = [$tagName]; |
||||
26 | |||||
27 | if (null !== $attrName) { |
||||
28 | $errorMessage = \substr_replace($errorMessage, ' with attribute "%s"' . ($voidAttr ? ' expected no value' . (!empty($parent) ? ', and ' : ' ') : ' '), 8, 1); |
||||
29 | $errorArgs[] = $attrName; |
||||
30 | } |
||||
31 | |||||
32 | if ($void) { |
||||
33 | $errorMessage .= ' and must be self closed.'; |
||||
34 | } |
||||
35 | |||||
36 | if (null !== $parent) { |
||||
37 | $errorArgs[] = $parent; |
||||
38 | } |
||||
39 | |||||
40 | return new self(\vsprintf($errorMessage, $errorArgs)); |
||||
0 ignored issues
–
show
It seems like
$errorMessage can also be of type array ; however, parameter $format of vsprintf() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
41 | } |
||||
42 | } |
||||
43 |