diff --git a/src/Jms/YamlConverter.php b/src/Jms/YamlConverter.php index e25a613d..3cbf6014 100644 --- a/src/Jms/YamlConverter.php +++ b/src/Jms/YamlConverter.php @@ -306,19 +306,15 @@ private function visitBaseComplexType(&$class, &$data, BaseComplexType $type, $n private function handleClassExtension(&$class, &$data, Type $type, $parentName) { if ($alias = $this->getTypeAlias($type)) { - - $property = array(); $property["expose"] = true; $property["xml_value"] = true; $property["access_type"] = "public_method"; $property["accessor"]["getter"] = "value"; - $property["accessor"]["setter"] = "value"; + $property["accessor"]["setter"] = "__construct"; $property["type"] = $alias; $data["properties"]["__value"] = $property; - - } else { $extension = $this->visitType($type, true); @@ -331,7 +327,7 @@ private function handleClassExtension(&$class, &$data, Type $type, $parentName) $property["xml_value"] = true; $property["access_type"] = "public_method"; $property["accessor"]["getter"] = "value"; - $property["accessor"]["setter"] = "value"; + $property["accessor"]["setter"] = "__construct"; if ($valueProp = $this->typeHasValue($type, $class, $parentName)) { $property["type"] = $valueProp; diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index a4f46819..1c85de4a 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -56,19 +56,12 @@ private function handleValueMethod(Generator\ClassGenerator $generator, PHPPrope $param ]); $method->setDocBlock($docblock); - $method->setBody("\$this->value(\$value);"); + $method->setBody("\$this->" . $prop->getName() . " = \$value;"); $generator->addMethodFromGenerator($method); $docblock = new DocBlockGenerator('Gets or sets the inner value'); $docblock->setWordWrap(false); - $paramTag = new ParamTag("value"); - if ($type && $type instanceof PHPClassOf) { - $paramTag->setTypes($type->getArg()->getType()->getPhpType() . "[]"); - } elseif ($type) { - $paramTag->setTypes($prop->getType()->getPhpType()); - } - $docblock->setTag($paramTag); $returnTag = new ReturnTag("mixed"); @@ -88,10 +81,7 @@ private function handleValueMethod(Generator\ClassGenerator $generator, PHPPrope $method = new MethodGenerator("value", []); $method->setDocBlock($docblock); - $methodBody = "if (\$args = func_get_args()) {" . PHP_EOL; - $methodBody .= " \$this->" . $prop->getName() . " = \$args[0];" . PHP_EOL; - $methodBody .= "}" . PHP_EOL; - $methodBody .= "return \$this->" . $prop->getName() . ";" . PHP_EOL; + $methodBody = "return \$this->" . $prop->getName() . ";" . PHP_EOL; $method->setBody($methodBody); $generator->addMethodFromGenerator($method); diff --git a/tests/Converter/JMS/Xsd2JmsElementTest.php b/tests/Converter/JMS/Xsd2JmsElementTest.php index 34d48ac3..6bc0987e 100644 --- a/tests/Converter/JMS/Xsd2JmsElementTest.php +++ b/tests/Converter/JMS/Xsd2JmsElementTest.php @@ -31,7 +31,7 @@ public function testElementOfPrimitiveType($xsType, $phpName) 'access_type' => 'public_method', 'accessor' => array( 'getter' => 'value', - 'setter' => 'value' + 'setter' => '__construct' ), 'type' => $phpName ) @@ -71,7 +71,7 @@ public function testElementOfPrimitiveTypeAnon($xsType, $phpName) 'access_type' => 'public_method', 'accessor' => array( 'getter' => 'value', - 'setter' => 'value' + 'setter' => '__construct' ), 'type' => $phpName ) @@ -106,7 +106,7 @@ public function testElementOfBaseType($xsType, $phpName, $jmsType) 'access_type' => 'public_method', 'accessor' => array( 'getter' => 'value', - 'setter' => 'value', + 'setter' => '__construct', ), 'type' => $jmsType, ), @@ -143,7 +143,7 @@ public function testElementOfBaseTypeAnon($xsType, $phpName, $jmsType) 'access_type' => 'public_method', 'accessor' => array( 'getter' => 'value', - 'setter' => 'value', + 'setter' => '__construct', ), 'type' => $jmsType, ), diff --git a/tests/Converter/JMS/Xsd2JmsGroupTest.php b/tests/Converter/JMS/Xsd2JmsGroupTest.php index 3ad25255..149b9854 100644 --- a/tests/Converter/JMS/Xsd2JmsGroupTest.php +++ b/tests/Converter/JMS/Xsd2JmsGroupTest.php @@ -619,7 +619,7 @@ public function testGeneralParts() 'access_type' => 'public_method', 'accessor' => array( 'getter' => 'value', - 'setter' => 'value' + 'setter' => '__construct' ), 'type' => 'string' )