1 | <?php |
||
8 | trait XMLAssertsTrait |
||
9 | { |
||
10 | /** |
||
11 | * @param string|\DOMDocument $xml |
||
12 | * @param string $version |
||
13 | * @param string $encoding |
||
14 | * @param string $message |
||
15 | */ |
||
16 | public function assertXmlHasProlog($xml, $version = '1.0', $encoding = 'UTF-8', string $message = ''): void |
||
20 | |||
21 | /** |
||
22 | * @param string|\DOMDocument $xml |
||
23 | * @param string $query |
||
24 | * @param int|null $count |
||
25 | * @param string $message |
||
26 | */ |
||
27 | public function assertXmlHasElements($xml, string $query, int $count = null, string $message = '') |
||
42 | |||
43 | /** |
||
44 | * @param string|\DOMDocument $xml |
||
45 | * @throws \InvalidArgumentException |
||
46 | * @return \DOMXPath |
||
47 | */ |
||
48 | private function toXPath($xml): \DOMXPath |
||
63 | } |
||
64 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.