|
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
|
3 |
|
protected function removeInvalidChildren(LoggerInterface $logger) |
|
22
|
|
|
{ |
|
23
|
|
|
// No "header", "footer", sectioning content, or heading content descendants. |
|
24
|
3 |
|
foreach ($this->children as $child) { |
|
25
|
3 |
|
if ($child instanceof Header || |
|
26
|
3 |
|
$child instanceof Footer || |
|
27
|
3 |
|
$child instanceof SectioningContent || |
|
28
|
3 |
|
$child instanceof HeadingContent) { |
|
29
|
1 |
|
$logger->debug('Removing ' . $child . '. No "header", "footer", and sectioning content, or heading content elements allowed as children of "dt" element.'); |
|
30
|
1 |
|
$this->removeChild($child); |
|
|
|
|
|
|
31
|
1 |
|
} |
|
32
|
3 |
|
} |
|
33
|
3 |
|
} |
|
34
|
|
|
|
|
35
|
4 |
|
protected function removeInvalidSelf(LoggerInterface $logger) |
|
36
|
|
|
{ |
|
37
|
|
|
// Must be child of "dl" element. |
|
38
|
4 |
|
$parent = $this->getParent(); |
|
39
|
4 |
|
if ($parent !== null && |
|
40
|
4 |
|
!$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
|
3 |
|
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.