diff --git a/composer.json b/composer.json index 533c35ba..6e432f75 100755 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "require" : { "xp-framework/core": "^12.0 | ^11.0 | ^10.0", "xp-framework/collections": "^10.0 | ^9.0 | ^8.0", + "xp-framework/reflection": "^3.0 | ^2.0", "php" : ">=7.0.0" }, "require-dev" : { diff --git a/src/main/php/xml/DomXSLProcessor.class.php b/src/main/php/xml/DomXSLProcessor.class.php index 30e9c16b..1fa8a02c 100755 --- a/src/main/php/xml/DomXSLProcessor.class.php +++ b/src/main/php/xml/DomXSLProcessor.class.php @@ -250,7 +250,7 @@ public function getMessages() { * @param string name * @param object instance */ - function registerInstance($name, $instance) { + public function registerInstance($name, $instance) { $this->_instances[$name]= $instance; } diff --git a/src/main/php/xml/XSLCallback.class.php b/src/main/php/xml/XSLCallback.class.php index 1921b07a..d6c30bc2 100755 --- a/src/main/php/xml/XSLCallback.class.php +++ b/src/main/php/xml/XSLCallback.class.php @@ -1,11 +1,11 @@ instances[$name]= $instance; + $methods= []; + foreach (Reflection::type($instance)->methods()->annotated(Xslmethod::class) as $method => $_) { + $methods[$method]= true; + } + $this->instances[$name]= [$instance, $methods]; } /** * Remove all registered instances * + * @return void */ public function clearInstances() { $this->instances= []; @@ -47,24 +52,22 @@ public function clearInstances() { /** * Invoke method on a registered instance. * - * @param string instancename - * @param string methodname - * @param var* method arguments + * @param string $name + * @param string $method + * @param var... $arguments * @return var * @throws lang.IllegalArgumentException if the instance is not known * @throws lang.ElementNotFoundException if the given method does not exist or is not xsl-accessible */ public static function invoke($name, $method, ...$args) { - if (!isset(self::$instance->instances[$name])) throw new \lang\IllegalArgumentException( - 'No such registered XSL callback instance: "'.$name.'"' - ); + if (null === ($instance= self::$instance->instances[$name] ?? null)) { + throw new IllegalArgumentException('No such registered XSL callback instance: "'.$name.'"'); + } - $instance= self::$instance->instances[$name]; - if (!(typeof($instance)->getMethod($method)->hasAnnotation('xslmethod'))) { + if (!isset($instance[1][$method])) { throw new ElementNotFoundException('Instance "'.$name.'" does not have method "'.$method.'"'); } - // Call callback method - return $instance->{$method}(...$args); + return $instance[0]->{$method}(...$args); } } \ No newline at end of file diff --git a/src/main/php/xml/meta/Marshaller.class.php b/src/main/php/xml/meta/Marshaller.class.php index e9a40991..91886610 100755 --- a/src/main/php/xml/meta/Marshaller.class.php +++ b/src/main/php/xml/meta/Marshaller.class.php @@ -1,6 +1,8 @@ getName()) { - if ($class->hasAnnotation('xmlfactory', 'element')) { - $node->setName($class->getAnnotation('xmlfactory', 'element')); + if (null === $node->getName()) { + if (($factory= $type->annotation(Xmlfactory::class)) && ($element= $factory->argument('element'))) { + $node->setName($element); } else { - $node->setName(strtolower($class->getSimpleName())); + $node->setName(strtolower($type->class()->getSimpleName())); } } // Namespace handling - if ($class->hasAnnotation('xmlns')) { - $node->setName(key($class->getAnnotation('xmlns')).':'.$node->getName()); - foreach ($class->getAnnotation('xmlns') as $prefix => $url) { + if ($xmlns= $type->annotation(Xmlns::class)) { + $map= $xmlns->arguments(); + $node->setName(key($map).':'.$node->getName()); + foreach ($map as $prefix => $url) { $node->setAttribute('xmlns:'.$prefix, $url); } } - foreach ($class->getMethods() as $method) { - if (!$method->hasAnnotation('xmlfactory', 'element')) continue; - - $element= $method->getAnnotation('xmlfactory', 'element'); + foreach ($type->methods()->annotated(Xmlfactory::class) as $method) { + $annotation= $method->annotation(Xmlfactory::class); + if (null === ($element= $annotation->argument('element'))) continue; // Pass injection parameters at end of list $arguments= []; - if ($method->hasAnnotation('xmlfactory', 'inject')) { - foreach ($method->getAnnotation('xmlfactory', 'inject') as $name) { - if (!isset($inject[$name])) throw new \lang\IllegalArgumentException( + if ($injection= $annotation->argument('inject')) { + foreach ($injection as $name) { + if (!isset($inject[$name])) throw new IllegalArgumentException( 'Injection parameter "'.$name.'" not found for '.$method->toString() ); $arguments[]= $inject[$name]; @@ -64,14 +66,13 @@ protected static function recurse($instance, $class, $node, $inject) { $result= $method->invoke($instance, $arguments); // Cast result if specified - if ($method->hasAnnotation('xmlfactory', 'cast')) { - $cast= $method->getAnnotation('xmlfactory', 'cast'); + if ($cast= $annotation->argument('cast')) { switch (sscanf($cast, '%[^:]::%s', $c, $m)) { case 1: $target= [$instance, $c]; break; case 2: $target= [$c, $m]; break; - default: throw new \lang\IllegalArgumentException('Unparseable cast "'.$cast.'"'); + default: throw new IllegalArgumentException('Unparseable cast "'.$cast.'"'); } - $result= call_user_func([$instance, $method->getAnnotation('xmlfactory', 'cast')], $result); + $result= $target($result); } // Attributes = "@", Node content= ".", Name = "name()" @@ -100,22 +101,22 @@ protected static function recurse($instance, $class, $node, $inject) { // - For objects, add a new node and invoke the recurse() method // on it. if (is_scalar($result) || null === $result) { - $node->addChild(new \xml\Node($element, $result)); + $node->addChild(new Node($element, $result)); } else if (is_array($result)) { - $child= $node->addChild(new \xml\Node($element)); + $child= $node->addChild(new Node($element)); foreach ($result as $key => $val) { - $child->addChild(new \xml\Node($key, $val)); + $child->addChild(new Node($key, $val)); } - } else if ($result instanceof \Traversable) { + } else if ($result instanceof Traversable) { foreach ($result as $value) { if (is_object($value)) { - self::recurse($value, typeof($value), $node->addChild(new \xml\Node($element)), $inject); + self::recurse($value, Reflection::type($value), $node->addChild(new Node($element)), $inject); } else { - $node->addChild(new \xml\Node($element, $value)); + $node->addChild(new Node($element, $value)); } } } else if (is_object($result)) { - self::recurse($result, typeof($result), $node->addChild(new \xml\Node($element)), $inject); + self::recurse($result, Reflection::type($result), $node->addChild(new Node($element)), $inject); } } } @@ -129,7 +130,7 @@ protected static function recurse($instance, $class, $node, $inject) { * @deprecated Use marshalTo() instead */ public static function marshal($instance, $qname= null) { - $class= typeof($instance); + $type= Reflection::type($instance); // Create XML tree and root node. Use the information provided by the // qname argument if existant, use the class` non-qualified (and @@ -139,31 +140,31 @@ public static function marshal($instance, $qname= null) { $prefix= $qname->prefix ? $qname->prefix : $qname->localpart[0]; $tree->root()->setName($prefix.':'.$qname->localpart); $tree->root()->setAttribute('xmlns:'.$prefix, $qname->namespace); - } else if ($class->hasAnnotation('xmlns')) { - $tree->root()->setName($class->getSimpleName()); + } else if ($type->annotation(Xmlns::class)) { + $tree->root()->setName($type->class()->getSimpleName()); } else { - $tree->root()->setName(strtolower($class->getSimpleName())); + $tree->root()->setName(strtolower($type->class()->getSimpleName())); } - self::recurse($instance, $class, $tree->root(), []); + self::recurse($instance, $type, $tree->root(), []); return $tree->getSource(INDENT_DEFAULT); } /** * Marshal an object to xml * - * @param xml.Node target + * @param ?xml.Node target * @param object $instance * @param [:var] inject * @return xml.Node the given target */ - public function marshalTo(\xml\Node $target= null, $instance, $inject= []) { - $class= typeof($instance); + public function marshalTo($target= null, $instance, $inject= []) { + $type= Reflection::type($instance); // Create node if not existant - if (null === $target) $target= new \xml\Node(null); + $target ?? $target= new Node(null); - self::recurse($instance, $class, $target, $inject); + self::recurse($instance, $type, $target, $inject); return $target; } } \ No newline at end of file diff --git a/src/main/php/xml/meta/Unmarshaller.class.php b/src/main/php/xml/meta/Unmarshaller.class.php index a5c77d3c..0066b55f 100755 --- a/src/main/php/xml/meta/Unmarshaller.class.php +++ b/src/main/php/xml/meta/Unmarshaller.class.php @@ -1,8 +1,10 @@ length ? iconv('utf-8', \xp::ENCODING, $element->item(0)->textContent) : null; - + if ($element instanceof DOMNodeList) { + return $element->length ? $element->item(0)->textContent : null; } else if (is_scalar($element)) { return $element; - - } else if ($element instanceof \DOMNode) { + } else if ($element instanceof DOMNode) { switch ($element->nodeType) { case 1: // DOMElement - return iconv('utf-8', \xp::ENCODING, $element->textContent); + return $element->textContent; case 2: // DOMAttr - return iconv('utf-8', \xp::ENCODING, $element->value); + return $element->value; case 3: // DOMText case 4: // DOMCharacterData - return iconv('utf-8', \xp::ENCODING, $element->data); + return $element->data; } - } else return null; + } + return null; } /** * Recursively unmarshal * - * @param xml.XPath xpath - * @param php.DomElement element - * @param lang.XPClass classname - * @param [:var] inject + * @param xml.XPath $xpath + * @param php.DomElement $element + * @param lang.reflection.Type $type + * @param [:var] $inject * @return object * @throws lang.ClassNotFoundException * @throws xml.XPathException */ - protected static function recurse($xpath, $element, $class, $inject) { + protected static function recurse($xpath, $element, $type, $inject) { // Namespace handling - if ($class->hasAnnotation('xmlns')) { - foreach ($class->getAnnotation('xmlns') as $prefix => $url) { + if ($xmlns= $type->annotation(Xmlns::class)) { + foreach ($xmlns->arguments() as $prefix => $url) { $xpath->context->registerNamespace($prefix, $url); } } - $instance= $class->newInstance(); - foreach ($class->getMethods() as $method) { - if (!$method->hasAnnotation('xmlmapping', 'element')) continue; + $instance= $type->newInstance(); + foreach ($type->methods()->annotated(Xmlmapping::class) as $method) { + $annotation= $method->annotation(Xmlmapping::class); + if (null === ($select= $annotation->argument('element'))) continue; // Perform XPath query - $result= $xpath->query($method->getAnnotation('xmlmapping', 'element'), $element); + $result= $xpath->query($select, $element); // Iterate over results, invoking the method for each node. foreach ($result as $node) { - if ($method->hasAnnotation('xmlmapping', 'class')) { + if ($class= $annotation->argument('class')) { // * If the xmlmapping annotation has a key "class", call recurse() // with the given XPath, the node as context and the key's value // as classname - $arguments= [self::recurse( - $xpath, - $node, - \lang\XPClass::forName($method->getAnnotation('xmlmapping', 'class')), - $inject - )]; - } else if ($method->hasAnnotation('xmlmapping', 'factory')) { + $arguments= [self::recurse($xpath, $node, Reflection::type($class), $inject)]; + } else if ($factory= $annotation->argument('factory')) { // * If the xmlmapping annotation has a key "factory", call recurse() // with the given XPath, the node as context and the results from @@ -100,60 +97,56 @@ protected static function recurse($xpath, $element, $class, $inject) { // is passed the node's tag name if no "pass" key is available. // In case it is, call the factory method with the arguments // constructed from the "pass" key. - if ($method->hasAnnotation('xmlmapping', 'pass')) { - $factoryArgs= []; - foreach ($method->getAnnotation('xmlmapping', 'pass') as $pass) { - $factoryArgs[]= self::contentOf($xpath->query($pass, $node)); + if ($pass= $annotation->argument('pass')) { + $args= []; + foreach ($pass as $path) { + $args[]= self::contentOf($xpath->query($path, $node)); } } else { - $factoryArgs= [$node->nodeName]; + $args= [$node->nodeName]; } $arguments= [self::recurse( $xpath, $node, - \lang\XPClass::forName(call_user_func_array( - [$instance, $method->getAnnotation('xmlmapping', 'factory')], - $factoryArgs - )), + Reflection::type($instance->method($factory)->invoke($args)), $inject )]; - } else if ($method->hasAnnotation('xmlmapping', 'pass')) { + } else if ($pass= $annotation->argument('pass')) { // * If the xmlmapping annotation has a key "pass" (expected to be an // array of XPaths relative to the node), construct the method's // argument list from the XPaths' results. $arguments= []; - foreach ($method->getAnnotation('xmlmapping', 'pass') as $pass) { - $arguments[]= self::contentOf($xpath->query($pass, $node)); + foreach ($pass as $path) { + $arguments[]= self::contentOf($xpath->query($path, $node)); } - } else if ($method->hasAnnotation('xmlmapping', 'cast')) { - $cast= $method->getAnnotation('xmlmapping', 'cast'); + } else if ($cast= $annotation->argument('cast')) { switch (sscanf($cast, '%[^:]::%s', $c, $m)) { case 1: $target= [$instance, $c]; break; case 2: $target= [$c, $m]; break; - default: throw new \lang\IllegalArgumentException('Unparseable cast "'.$cast.'"'); + default: throw new IllegalArgumentException('Unparseable cast "'.$cast.'"'); } - // * If the xmlmapping annotation contains a key "convert", cast the node's + // * If the xmlmapping annotation contains a key "cast", cast the node's // contents using the given callback method before passing it to the method. - $arguments= call_user_func($target, iconv('utf-8', \xp::ENCODING, $node->textContent)); - } else if ($method->hasAnnotation('xmlmapping', 'type')) { + $arguments= [$target($node->textContent)]; + } else if ($type= $annotation->argument('type')) { // * If the xmlmapping annotation contains a key "type", cast the node's // contents to the specified type before passing it to the method. - $value= iconv('utf-8', \xp::ENCODING, $node->textContent); - settype($value, $method->getAnnotation('xmlmapping', 'type')); + $value= $node->textContent; + settype($value, $type); $arguments= [$value]; } else { // * Otherwise, pass the node's content to the method - $arguments= [iconv('utf-8', \xp::ENCODING, $node->textContent)]; + $arguments= [$node->textContent]; } // Pass injection parameters at end of list - if ($method->hasAnnotation('xmlmapping', 'inject')) { - foreach ($method->getAnnotation('xmlmapping', 'inject') as $name) { - if (!isset($inject[$name])) throw new \lang\IllegalArgumentException( + if ($injection= $annotation->argument('inject')) { + foreach ($injection as $name) { + if (!isset($inject[$name])) throw new IllegalArgumentException( 'Injection parameter "'.$name.'" not found for '.$method->toString() ); $arguments[]= $inject[$name]; @@ -179,7 +172,7 @@ protected static function recurse($xpath, $element, $class, $inject) { */ public static function unmarshal($xml, $classname) { libxml_clear_errors(); - $doc= new \DOMDocument(); + $doc= new DOMDocument(); $source= '(string)'; if ('' === (string)$xml) { // Handle empty string, raise XML_IO_NO_INPUT throw new XMLFormatException('Empty string supplied as input', 1547, $source, 0, 0); @@ -188,46 +181,49 @@ public static function unmarshal($xml, $classname) { $e= libxml_get_last_error(); throw new XMLFormatException(trim($e->message), $e->code, $source, $e->line, $e->column); } - return self::recurse(new XPath($doc), $doc->documentElement, \lang\XPClass::forName($classname), []); + return self::recurse(new XPath($doc), $doc->documentElement, Reflection::type($classname), []); } /** * Unmarshal XML to an object * - * @param xml.parser.InputSource source - * @param string classname - * @param [:var] inject + * @param xml.parser.InputSource $input + * @param string $classname + * @param [:var] $inject * @return object * @throws lang.ClassNotFoundException * @throws xml.XMLFormatException - * @throws lang.reflect.TargetInvocationException + * @throws lang.reflection.InvocationFailed * @throws lang.IllegalArgumentException */ public function unmarshalFrom(InputSource $input, $classname, $inject= []) { libxml_clear_errors(); - $doc= new \DOMDocument(); + $doc= new DOMDocument(); if (!$doc->load(Streams::readableUri($input->getStream()))) { $e= libxml_get_last_error(); throw new XMLFormatException(trim($e->message), $e->code, $input->getSource(), $e->line, $e->column); } $xpath= new XPath($doc); + $type= Reflection::type($classname); // Class factory based on tag name, reference to a static method which is called with // the class name and returns an XPClass instance. - $class= \lang\XPClass::forName($classname); - if ($class->hasAnnotation('xmlmapping', 'factory')) { - if ($class->hasAnnotation('xmlmapping', 'pass')) { - $factoryArgs= []; - foreach ($class->getAnnotation('xmlmapping', 'pass') as $pass) { - $factoryArgs[]= self::contentOf($xpath->query($pass, $doc->documentElement)); + if ($mapping= $type->annotation(Xmlmapping::class)) { + if ($factory= $mapping->argument('factory')) { + if ($pass= $mapping->argument('pass')) { + $args= []; + foreach ($pass as $path) { + $args[]= self::contentOf($xpath->query($path, $doc->documentElement)); + } + } else { + $args= [$doc->documentElement->nodeName]; } - } else { - $factoryArgs= [$doc->documentElement->nodeName]; + + $type= Reflection::type($type->method($factory)->invoke(null, $args)); } - $class= $class->getMethod($class->getAnnotation('xmlmapping', 'factory'))->invoke(null, $factoryArgs); } - return self::recurse($xpath, $doc->documentElement, $class, $inject); + return self::recurse($xpath, $doc->documentElement, $type, $inject); } } \ No newline at end of file diff --git a/src/test/php/xml/unittest/ButtonType.class.php b/src/test/php/xml/unittest/ButtonType.class.php index 45f8ae0d..e9d3d036 100755 --- a/src/test/php/xml/unittest/ButtonType.class.php +++ b/src/test/php/xml/unittest/ButtonType.class.php @@ -11,7 +11,7 @@ class ButtonType { * * @param string $id */ - #[Xmlmapping(['element' => '@id'])] + #[Xmlmapping(element: '@id')] public function setId($id) { $this->id= $id; } @@ -21,7 +21,7 @@ public function setId($id) { * * @return string id */ - #[Xmlfactory(['element' => '@id'])] + #[Xmlfactory(element: '@id')] public function getId() { return $this->id; } @@ -31,7 +31,7 @@ public function getId() { * * @param string $caption */ - #[Xmlmapping(['element' => '.'])] + #[Xmlmapping(element: '.')] public function setCaption($caption) { $this->caption= $caption; } @@ -41,7 +41,7 @@ public function setCaption($caption) { * * @return string caption */ - #[Xmlfactory(['element' => '.'])] + #[Xmlfactory(element: '.')] public function getCaption() { return $this->caption; } diff --git a/src/test/php/xml/unittest/DialogType.class.php b/src/test/php/xml/unittest/DialogType.class.php index ffd68698..c7a1f3ba 100755 --- a/src/test/php/xml/unittest/DialogType.class.php +++ b/src/test/php/xml/unittest/DialogType.class.php @@ -22,7 +22,7 @@ public function __construct() { * * @param string $id */ - #[Xmlmapping(['element' => '@id'])] + #[Xmlmapping(element: '@id')] public function setId($id) { $this->id= $id; } @@ -32,7 +32,7 @@ public function setId($id) { * * @return string id */ - #[Xmlfactory(['element' => '@id'])] + #[Xmlfactory(element: '@id')] public function getId() { return $this->id; } @@ -42,7 +42,7 @@ public function getId() { * * @param string $caption */ - #[Xmlmapping(['element' => 'caption'])] + #[Xmlmapping(element: 'caption')] public function setCaption($caption) { $this->caption= $caption; } @@ -52,7 +52,7 @@ public function setCaption($caption) { * * @return string caption */ - #[Xmlfactory(['element' => 'caption'])] + #[Xmlfactory(element: 'caption')] public function getCaption() { return $this->caption; } @@ -63,7 +63,7 @@ public function getCaption() { * @param xml.unittest.ButtonType $button * @return xml.unittest.ButtonType the added button */ - #[Xmlmapping(['element' => 'button', 'class' => 'xml.unittest.ButtonType'])] + #[Xmlmapping(element: 'button', class: 'xml.unittest.ButtonType')] public function addButton($button) { $this->buttons->add($button); return $button; @@ -102,7 +102,7 @@ public function hasButtons() { * * @return util.collections.Vector */ - #[Xmlfactory(['element' => 'button'])] + #[Xmlfactory(element: 'button')] public function getButtons() { return $this->buttons; } @@ -113,7 +113,7 @@ public function getButtons() { * @param string $flag1 * @param string $flag2 */ - #[Xmlmapping(['element' => 'flags', 'pass' => ['substring-before(., "|")', 'substring-after(., "|")']])] + #[Xmlmapping(element: 'flags', pass: ['substring-before(., "|")', 'substring-after(., "|")'])] public function setFlags($flag1, $flag2) { $this->flags= [$flag1, $flag2]; } @@ -123,7 +123,7 @@ public function setFlags($flag1, $flag2) { * * @return string[] */ - #[Xmlfactory(['element' => 'flags'])] + #[Xmlfactory(element: 'flags')] public function getFlags() { return $this->flags; } @@ -134,7 +134,7 @@ public function getFlags() { * @param string $name * @param string $value */ - #[Xmlmapping(['element' => 'options/option', 'pass' => ['@name', '@value']])] + #[Xmlmapping(element: 'options/option', pass: ['@name', '@value'])] public function setOptions($name, $value) { $this->options[$name]= $value; } @@ -144,7 +144,7 @@ public function setOptions($name, $value) { * * @return [:string] */ - #[Xmlfactory(['element' => 'options'])] + #[Xmlfactory(element: 'options')] public function getOptions() { return $this->options; } diff --git a/src/test/php/xml/unittest/DomXslProcessorTest.class.php b/src/test/php/xml/unittest/DomXslProcessorTest.class.php index ddb7d608..08c58fa8 100755 --- a/src/test/php/xml/unittest/DomXslProcessorTest.class.php +++ b/src/test/php/xml/unittest/DomXslProcessorTest.class.php @@ -3,8 +3,8 @@ use io\FileNotFoundException; use lang\{ElementNotFoundException, IllegalArgumentException}; use test\verify\Runtime; -use test\{Assert, Expect, Test, Xslmethod}; -use xml\{DomXSLProcessor, TransformerException}; +use test\{Assert, Expect, Test}; +use xml\{DomXSLProcessor, TransformerException, Xslmethod}; #[Runtime(extensions: ['dom', 'xsl'])] class DomXslProcessorTest extends AbstractProcessorTest { diff --git a/src/test/php/xml/unittest/TextInputType.class.php b/src/test/php/xml/unittest/TextInputType.class.php index 2c913367..bd107385 100755 --- a/src/test/php/xml/unittest/TextInputType.class.php +++ b/src/test/php/xml/unittest/TextInputType.class.php @@ -1,5 +1,6 @@ '@id'])] + #[Xmlmapping(element: '@id')] public function setId($id) { $this->id= $id; } @@ -45,7 +46,7 @@ public function setId($id) { * * @return string id */ - #[Xmlfactory(['element' => '@id'])] + #[Xmlfactory(element: '@id')] public function getId() { return $this->id; } @@ -55,7 +56,7 @@ public function getId() { * * @param bool $disabled */ - #[Xmlmapping(['element' => '@disabled', 'cast' => 'asBool'])] + #[Xmlmapping(element: '@disabled', cast: 'asBool')] public function setDisabled($disabled) { $this->disabled= $disabled; } @@ -65,7 +66,7 @@ public function setDisabled($disabled) { * * @return bool disabled */ - #[Xmlfactory(['element' => '@disabled', 'cast' => 'toBool'])] + #[Xmlfactory(element: '@disabled', cast: 'toBool')] public function getDisabled() { return $this->disabled; } diff --git a/src/test/php/xml/unittest/UnmarshallerTest.class.php b/src/test/php/xml/unittest/UnmarshallerTest.class.php index 9cf58271..647936a2 100755 --- a/src/test/php/xml/unittest/UnmarshallerTest.class.php +++ b/src/test/php/xml/unittest/UnmarshallerTest.class.php @@ -2,7 +2,7 @@ use io\streams\MemoryInputStream; use lang\IllegalArgumentException; -use lang\reflect\TargetInvocationException; +use lang\reflection\InvocationFailed; use test\{Assert, Before, Expect, Test, TestCase}; use xml\XMLFormatException; use xml\meta\Unmarshaller; @@ -168,7 +168,7 @@ public function nameBasedFactoryToButton() { Assert::instance(ButtonType::class, $object); } - #[Test, Expect(TargetInvocationException::class)] + #[Test, Expect(InvocationFailed::class)] public function nameBasedFactoryToUnknown() { $this->fixture->unmarshalFrom( new StreamInputSource(new MemoryInputStream('')), @@ -194,7 +194,7 @@ public function idBasedFactoryToButton() { Assert::instance(ButtonType::class, $object); } - #[Test, Expect(TargetInvocationException::class)] + #[Test, Expect(InvocationFailed::class)] public function idBasedFactoryToUnknown() { $this->fixture->unmarshalFrom( new StreamInputSource(new MemoryInputStream('')), diff --git a/src/test/php/xml/unittest/WindowType.class.php b/src/test/php/xml/unittest/WindowType.class.php index 4de65938..44978e96 100755 --- a/src/test/php/xml/unittest/WindowType.class.php +++ b/src/test/php/xml/unittest/WindowType.class.php @@ -11,7 +11,7 @@ class WindowType { * @param string $name * @param [:int] $windows handle lookup */ - #[Xmlmapping(['element' => '@owner-window', 'inject' => ['windows']])] + #[Xmlmapping(element: '@owner-window', inject: ['windows'])] public function setOwnerWindowNamed($name, array $windows) { $this->window= $windows[$name]; } @@ -22,7 +22,7 @@ public function setOwnerWindowNamed($name, array $windows) { * @param [:int] $windows handle lookup * @return string name */ - #[Xmlfactory(['element' => '@owner-window', 'inject' => ['windows']])] + #[Xmlfactory(element: '@owner-window', inject: ['windows'])] public function getOwnerWindowName(array $windows) { return array_search($this->window, $windows); } diff --git a/src/test/php/xml/unittest/XslCallbackTest.class.php b/src/test/php/xml/unittest/XslCallbackTest.class.php index 815e543c..f75c5fd1 100755 --- a/src/test/php/xml/unittest/XslCallbackTest.class.php +++ b/src/test/php/xml/unittest/XslCallbackTest.class.php @@ -12,10 +12,10 @@ class XslCallbackTest { /** * Runs a transformation * - * @param string xml - * @param string callback - * @param string[] arguments - * @param string xslEncoding default 'utf-8' + * @param string $xml + * @param string $callback + * @param string[] $arguments + * @param string $xslEncoding default 'utf-8' * @return string */ protected function runTransformation($xml, $callback, $arguments, $xslEncoding= 'utf-8') {