simplesamlphp /
xml-security
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace SimpleSAML\XMLSecurity\XML; |
||
| 6 | |||
| 7 | use DOMElement; |
||
| 8 | use SimpleSAML\XMLSecurity\Utils\XML; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * A trait implementing the CanonicalizableElementInterface. |
||
| 12 | * |
||
| 13 | * @package simplesamlphp/xml-security |
||
| 14 | */ |
||
| 15 | trait CanonicalizableElementTrait |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * This trait uses the php DOM extension. As such, it requires you to keep track (or produce) the DOMElement |
||
| 19 | * necessary to perform the canonicalisation. |
||
| 20 | * |
||
| 21 | * Implement this method to return the DOMElement with the proper representation of this object. Whatever is |
||
| 22 | * returned here will be used both to perform canonicalisation and to serialize the object, so that it can be |
||
| 23 | * recovered later in its exact original state. |
||
| 24 | * |
||
| 25 | * @return \DOMElement |
||
| 26 | */ |
||
| 27 | abstract protected function getOriginalXML(): DOMElement; |
||
| 28 | |||
| 29 | |||
| 30 | /** |
||
| 31 | * Get the canonical (string) representation of this object. |
||
| 32 | * |
||
| 33 | * Note that if this object was created using fromXML(), it might be necessary to keep the original DOM |
||
| 34 | * representation of the object. |
||
| 35 | * |
||
| 36 | * @param string $method The canonicalization method to use. |
||
| 37 | * @param string[]|null $xpaths An array of XPaths to filter the nodes by. Defaults to null (no filters). |
||
| 38 | * @param string[]|null $prefixes An array of namespace prefixes to filter the nodes by. Defaults to null (no |
||
| 39 | * filters). |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function canonicalize(string $method, ?array $xpaths = null, ?array $prefixes = null): string |
||
| 43 | { |
||
| 44 | return XML::canonicalizeData($this->getOriginalXML(), $method, $xpaths, $prefixes); |
||
| 45 | } |
||
| 46 | |||
| 47 | |||
| 48 | /** |
||
| 49 | * Serialize this canonicalisable element. |
||
| 50 | * |
||
| 51 | * @return array{0: string} The serialized chunk. |
||
| 52 | */ |
||
| 53 | public function __serialize(): array |
||
| 54 | { |
||
| 55 | $xml = $this->getOriginalXML(); |
||
| 56 | return [$xml->ownerDocument->saveXML($xml)]; |
||
|
0 ignored issues
–
show
|
|||
| 57 | } |
||
| 58 | } |
||
| 59 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.