1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Groundskeeper\Tokens\Elements; |
4
|
|
|
|
5
|
|
|
use Groundskeeper\Configuration; |
6
|
|
|
use Groundskeeper\Tokens\ElementTypes\HeadingContent; |
7
|
|
|
use Groundskeeper\Tokens\ElementTypes\OpenElement; |
8
|
|
|
use Groundskeeper\Tokens\ElementTypes\SectioningContent; |
9
|
|
|
use Groundskeeper\Tokens\NonParticipating; |
10
|
|
|
use Groundskeeper\Tokens\Text; |
11
|
|
|
use Groundskeeper\Tokens\Token; |
12
|
|
|
use Psr\Log\LoggerInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* "dt" element |
16
|
|
|
* |
17
|
|
|
* https://html.spec.whatwg.org/multipage/semantics.html#the-dt-element |
18
|
|
|
*/ |
19
|
|
|
class Dt extends OpenElement |
20
|
|
|
{ |
21
|
2 |
|
protected function removeInvalidChildren(LoggerInterface $logger) |
22
|
|
|
{ |
23
|
|
|
// No "header", "footer", sectioning content, or heading content descendants. |
24
|
2 |
|
foreach ($this->children as $child) { |
25
|
2 |
|
if ($child instanceof Header || |
26
|
2 |
|
$child instanceof Footer || |
27
|
2 |
|
$child instanceof SectioningContent || |
28
|
2 |
|
$child instanceof HeadingContent) { |
29
|
|
|
$logger->debug('Removing ' . $child . '. No "header", "footer", and sectioning content, or heading content elements allowed as children of "dt" element.'); |
30
|
|
|
$this->removeChild($child); |
|
|
|
|
31
|
|
|
} |
32
|
2 |
|
} |
33
|
2 |
|
} |
34
|
|
|
|
35
|
3 |
|
protected function removeInvalidSelf(LoggerInterface $logger) |
36
|
|
|
{ |
37
|
|
|
// Must be child of "dl" element. |
38
|
3 |
|
$parent = $this->getParent(); |
39
|
3 |
|
if ($parent !== null && |
40
|
3 |
|
!$parent instanceof Dl) { |
41
|
1 |
|
$logger->debug('Removing ' . $this . '. Must be a child of a "dl" element.'); |
42
|
|
|
|
43
|
1 |
|
return true; |
44
|
|
|
} |
45
|
|
|
|
46
|
2 |
|
return false; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.