From 9ba8e1fd0e2cb3145bc2e9a4dd6e484ade250082 Mon Sep 17 00:00:00 2001 From: rtek Date: Wed, 11 Apr 2018 13:32:16 -0400 Subject: [PATCH 1/6] Added zendframework/zend-code ^3.0 compatibility --- composer.json | 5 ++- src/Php/ClassGenerator.php | 5 +-- src/Php/PathGenerator/Psr4PathGenerator.php | 5 ++- src/Writer/PHPClassWriter.php | 4 ++ src/Writer/PHPWriter.php | 11 +++-- tests/AbstractGenerator.php | 2 +- tests/Generator.php | 8 ++-- tests/VeryShortNamingStrategy.php | 46 +++++++++++++++++++++ 8 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 tests/VeryShortNamingStrategy.php diff --git a/composer.json b/composer.json index b1e920e5..fb04d4b2 100644 --- a/composer.json +++ b/composer.json @@ -25,14 +25,15 @@ "symfony/config": "^2.2|^3.0|^4.0", "goetas-webservices/xsd-reader": "^0.2|^0.3.1", "doctrine/inflector": "^1.0", - "zendframework/zend-code": "~2.3", + "zendframework/zend-code": "~2.3|^3.0", "psr/log": "^1.0" }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0", "jms/serializer": "^1.3", - "goetas-webservices/xsd2php-runtime": "^0.2.7" + "goetas-webservices/xsd2php-runtime": "^0.2.7", + "ext-xmldiff": "*" }, "autoload": { "psr-4": { diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index f296715d..1206355c 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -46,7 +46,6 @@ private function isNativeType(PHPClass $class) 'integer', 'boolean', 'array', - 'mixed', 'callable' ]); } @@ -141,7 +140,7 @@ private function handleSetter(Generator\ClassGenerator $generator, PHPProperty $ $method = new MethodGenerator("set" . Inflector::classify($prop->getName())); - $parameter = new ParameterGenerator($prop->getName(), "mixed"); + $parameter = new ParameterGenerator($prop->getName()); if ($type && $type instanceof PHPClassOf) { $patramTag->setTypes($type->getArg() @@ -387,7 +386,7 @@ public function generate(PHPClass $type) $this->handleValueMethod($class, $p, $extends); } else { - $class->setExtendedClass($extends->getName()); + $class->setExtendedClass($extends->getFullName()); if ($extends->getNamespace() != $type->getNamespace()) { if ($extends->getName() == $type->getName()) { diff --git a/src/Php/PathGenerator/Psr4PathGenerator.php b/src/Php/PathGenerator/Psr4PathGenerator.php index 52faad61..5bfc4de5 100644 --- a/src/Php/PathGenerator/Psr4PathGenerator.php +++ b/src/Php/PathGenerator/Psr4PathGenerator.php @@ -14,8 +14,9 @@ public function getPath(ClassGenerator $php) if (strpos(trim($php->getNamespaceName()) . "\\", $namespace) === 0) { $d = strtr(substr($php->getNamespaceName(), strlen($namespace)), "\\", "/"); $dir = rtrim($dir, "/") . "/" . $d; - if (!is_dir($dir) && !mkdir($dir, 0777, true)) { - throw new PathGeneratorException("Can't create the '$dir' directory"); + if (!is_dir($dir) && !@mkdir($dir, 0777, true)) { + $error = error_get_last(); + throw new PathGeneratorException("Can't create the '$dir' directory: '{$error['message']}'"); } return rtrim($dir, "/") . "/" . $php->getName() . ".php"; diff --git a/src/Writer/PHPClassWriter.php b/src/Writer/PHPClassWriter.php index 8ac4678e..c6496bbf 100644 --- a/src/Writer/PHPClassWriter.php +++ b/src/Writer/PHPClassWriter.php @@ -1,6 +1,7 @@ logger = $logger ?: new NullLogger(); } + /** + * @param ClassGenerator[] $items + */ public function write(array $items) { foreach ($items as $item) { diff --git a/src/Writer/PHPWriter.php b/src/Writer/PHPWriter.php index 9c43fc5b..d7e83b68 100644 --- a/src/Writer/PHPWriter.php +++ b/src/Writer/PHPWriter.php @@ -22,10 +22,15 @@ public function __construct(PHPClassWriter $classWriter, ClassGenerator $generat $this->logger = $logger ?: new NullLogger(); } + /** + * @param PHPClass[] $items + */ public function write(array $items) { - return $this->classWriter->write(array_filter(array_map(function (PHPClass $item) { - return $this->generator->generate($item); - }, $items))); + while($item = array_pop($items)) { + if($generator = $this->generator->generate($item)) { + $this->classWriter->write([$generator]); + } + } } } diff --git a/tests/AbstractGenerator.php b/tests/AbstractGenerator.php index 3e794cf7..f0315311 100644 --- a/tests/AbstractGenerator.php +++ b/tests/AbstractGenerator.php @@ -34,7 +34,7 @@ public function __construct(array $targetNs, array $aliases = array(), $tmp = nu $this->phpDir = "$tmp/php"; $this->jmsDir = "$tmp/jms"; - $this->namingStrategy = new ShortNamingStrategy(); + $this->namingStrategy = new VeryShortNamingStrategy(); $this->loader = new ClassLoader(); foreach ($this->targetNs as $phpNs) { diff --git a/tests/Generator.php b/tests/Generator.php index 56006b3d..e3ab0e5c 100644 --- a/tests/Generator.php +++ b/tests/Generator.php @@ -9,11 +9,9 @@ class Generator extends AbstractGenerator public function generate(array $schemas) { $this->cleanDirectories(); - - list($php, $jms) = $this->getData($schemas); - - $this->writeJMS($jms); - $this->writePHP($php); + + $this->writeJMS($this->generateJMSFiles($schemas)); + $this->writePHP($this->generatePHPFiles($schemas)); } public function getData(array $schemas) diff --git a/tests/VeryShortNamingStrategy.php b/tests/VeryShortNamingStrategy.php new file mode 100644 index 00000000..31690dc0 --- /dev/null +++ b/tests/VeryShortNamingStrategy.php @@ -0,0 +1,46 @@ +classify($type->getName())) { + if (substr($name, -4) !== 'Type') { + $name .= "T"; + } elseif (substr($name, -4) === 'Type') { + $name = substr($name, 0, -3); + } + } + return $name; + } + + /** + * Suffix with A instead of AType + * @param Type $type + * @param string $parentName + * @return string + */ + public function getAnonymousTypeName(Type $type, $parentName) + { + return $this->classify($parentName) . "A"; + } + + private function classify($name) + { + return Inflector::classify(str_replace(".", " ", $name)); + } +} From 2107cc247cc070fed7252f13afce0e8c40514e86 Mon Sep 17 00:00:00 2001 From: rtek Date: Wed, 11 Apr 2018 14:51:32 -0400 Subject: [PATCH 2/6] Replaced param type declaration aliases with the underlying type for php7 hinting --- src/AbstractConverter.php | 34 ++++++++++++++--------------- src/Jms/YamlConverter.php | 3 ++- src/Php/ClassGenerator.php | 21 +++++++++--------- src/Php/PhpConverter.php | 4 ++-- src/Php/Structure/PHPClass.php | 14 ++++++------ tests/Converter/JMS/Xsd2JmsBase.php | 6 ++--- tests/PHP/PHPConversionTest.php | 4 ++++ 7 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/AbstractConverter.php b/src/AbstractConverter.php index 75545a16..8163c3d9 100644 --- a/src/AbstractConverter.php +++ b/src/AbstractConverter.php @@ -68,16 +68,16 @@ public function __construct(NamingStrategy $namingStrategy, LoggerInterface $log $this->logger = $logger ?: new NullLogger(); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "gYearMonth", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "gMonthDay", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "gMonth", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "gYear", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "NMTOKEN", function (Type $type) { return "string"; @@ -107,43 +107,43 @@ public function __construct(NamingStrategy $namingStrategy, LoggerInterface $log return "string"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "integer", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "int", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "unsignedInt", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "negativeInteger", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "positiveInteger", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "nonNegativeInteger", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "nonPositiveInteger", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "long", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "unsignedLong", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "short", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "boolean", function (Type $type) { - return "boolean"; + return "bool"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "nonNegativeInteger", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "positiveInteger", function (Type $type) { - return "integer"; + return "int"; }); $this->addAliasMap("http://www.w3.org/2001/XMLSchema", "language", function (Type $type) { return "string"; diff --git a/src/Jms/YamlConverter.php b/src/Jms/YamlConverter.php index 9c3de5b6..e25a613d 100644 --- a/src/Jms/YamlConverter.php +++ b/src/Jms/YamlConverter.php @@ -19,6 +19,7 @@ use GoetasWebservices\XML\XSDReader\Schema\Type\Type; use GoetasWebservices\Xsd\XsdToPhp\AbstractConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\NamingStrategy; +use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass; class YamlConverter extends AbstractConverter { @@ -409,7 +410,7 @@ private function typeHasValue(Type $type, $parentClass, $name) * @param PHPClass $class * @param Schema $schema * @param Element $element - * @param boolean $arrayize + * @param bool $arrayize * @return \GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPProperty */ private function visitElement(&$class, Schema $schema, ElementItem $element, $arrayize = true) diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index 1206355c..1fe7f706 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -36,27 +36,26 @@ private function handleBody(Generator\ClassGenerator $class, PHPClass $type) return true; } - +/* private function isNativeType(PHPClass $class) { return !$class->getNamespace() && in_array($class->getName(), [ 'string', 'int', 'float', - 'integer', - 'boolean', + 'bool', 'array', 'callable' ]); } - +*/ private function handleValueMethod(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class, $all = true) { $type = $prop->getType(); $docblock = new DocBlockGenerator('Construct'); $docblock->setWordWrap(false); - $paramTag = new ParamTag("value", "mixed"); + $paramTag = new ParamTag("value"); $paramTag->setTypes(($type ? $type->getPhpType() : "mixed")); $docblock->setTag($paramTag); @@ -75,7 +74,7 @@ private function handleValueMethod(Generator\ClassGenerator $generator, PHPPrope $docblock = new DocBlockGenerator('Gets or sets the inner value'); $docblock->setWordWrap(false); - $paramTag = new ParamTag("value", "mixed"); + $paramTag = new ParamTag("value"); if ($type && $type instanceof PHPClassOf) { $paramTag->setTypes($type->getArg()->getType()->getPhpType() . "[]"); } elseif ($type) { @@ -192,12 +191,12 @@ private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $ $docblock->setLongDescription($prop->getDoc()); } - $patramTag = new ParamTag("index", "scalar"); + $patramTag = new ParamTag("index", "int|string"); $docblock->setTag($patramTag); - $docblock->setTag(new ReturnTag("boolean")); + $docblock->setTag(new ReturnTag("bool")); - $paramIndex = new ParameterGenerator("index", "mixed"); + $paramIndex = new ParameterGenerator("index"); $method = new MethodGenerator("isset" . Inflector::classify($prop->getName()), [$paramIndex]); $method->setDocBlock($docblock); @@ -211,9 +210,9 @@ private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $ $docblock->setLongDescription($prop->getDoc()); } - $patramTag = new ParamTag("index", "scalar"); + $patramTag = new ParamTag("index", "int|string"); $docblock->setTag($patramTag); - $paramIndex = new ParameterGenerator("index", "mixed"); + $paramIndex = new ParameterGenerator("index"); $docblock->setTag(new ReturnTag("void")); diff --git a/src/Php/PhpConverter.php b/src/Php/PhpConverter.php index 6f2155f8..c9f8d423 100644 --- a/src/Php/PhpConverter.php +++ b/src/Php/PhpConverter.php @@ -221,7 +221,7 @@ private function findPHPName(Type $type) /** * * @param Type $type - * @param boolean $force + * @param bool $force * @param bool $skip * @return PHPClass * @throws Exception @@ -399,7 +399,7 @@ private function visitAttribute(PHPClass $class, Schema $schema, AttributeItem $ * @param PHPClass $class * @param Schema $schema * @param Element $element - * @param boolean $arrayize + * @param bool $arrayize * @return \GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPProperty */ private function visitElement(PHPClass $class, Schema $schema, ElementSingle $element, $arrayize = true) diff --git a/src/Php/Structure/PHPClass.php b/src/Php/Structure/PHPClass.php index d94bb6a0..da4b5c01 100644 --- a/src/Php/Structure/PHPClass.php +++ b/src/Php/Structure/PHPClass.php @@ -56,11 +56,11 @@ public function isNativeType() 'string', 'int', 'float', - 'integer', - 'boolean', + 'bool', 'array', - 'mixed', - 'callable' + 'callable', + + 'mixed' //todo this is not a php type but it's needed for now to allow mixed return tags ]); } @@ -167,7 +167,7 @@ public function getProperties() /** * * @param string $name - * @return boolean + * @return bool */ public function hasProperty($name) { @@ -245,7 +245,7 @@ public function addProperty(PHPProperty $property) /** * - * @var boolean + * @var bool */ protected $abstract; @@ -282,7 +282,7 @@ public function getAbstract() public function setAbstract($abstract) { - $this->abstract = (boolean)$abstract; + $this->abstract = (bool)$abstract; return $this; } } diff --git a/tests/Converter/JMS/Xsd2JmsBase.php b/tests/Converter/JMS/Xsd2JmsBase.php index ff203fe1..3000b12f 100644 --- a/tests/Converter/JMS/Xsd2JmsBase.php +++ b/tests/Converter/JMS/Xsd2JmsBase.php @@ -49,8 +49,8 @@ public function getPrimitiveTypeConversions() return [ ['xs:string', 'string'], ['xs:decimal', 'float'], - ['xs:int', 'integer'], - ['xs:integer', 'integer'], + ['xs:int', 'int'], + ['xs:integer', 'int'], ]; } -} \ No newline at end of file +} diff --git a/tests/PHP/PHPConversionTest.php b/tests/PHP/PHPConversionTest.php index 78cc54a8..bfba64cc 100644 --- a/tests/PHP/PHPConversionTest.php +++ b/tests/PHP/PHPConversionTest.php @@ -145,6 +145,10 @@ public function testMulteplicity() $this->assertTrue($codegen->hasMethod('getId')); $this->assertTrue($codegen->hasMethod('setId')); + + $this->assertNull($codegen->getMethod('issetId')->getParameters()['index']->getType()); + $this->assertNull($codegen->getMethod('issetId')->getParameters()['index']->getType()); + } public function testNestedMulteplicity() From e674382ba645d18b873f6bd40a1d26f106814d25 Mon Sep 17 00:00:00 2001 From: rtek Date: Wed, 11 Apr 2018 16:26:20 -0400 Subject: [PATCH 3/6] Removed unneeded code block --- src/Php/ClassGenerator.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index 1fe7f706..b2fa77a6 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -36,19 +36,7 @@ private function handleBody(Generator\ClassGenerator $class, PHPClass $type) return true; } -/* - private function isNativeType(PHPClass $class) - { - return !$class->getNamespace() && in_array($class->getName(), [ - 'string', - 'int', - 'float', - 'bool', - 'array', - 'callable' - ]); - } -*/ + private function handleValueMethod(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class, $all = true) { $type = $prop->getType(); From 2e11f6b398624d5537dd5ce9b2a8379fe58a32f0 Mon Sep 17 00:00:00 2001 From: rtek Date: Wed, 11 Apr 2018 20:14:47 -0400 Subject: [PATCH 4/6] Increased jms/serializer version which understands the non-alias PHP native types - handled zend-code BC break in class extends resolution --- composer.json | 4 ++-- src/Php/ClassGenerator.php | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index fb04d4b2..dba84a95 100644 --- a/composer.json +++ b/composer.json @@ -25,13 +25,13 @@ "symfony/config": "^2.2|^3.0|^4.0", "goetas-webservices/xsd-reader": "^0.2|^0.3.1", "doctrine/inflector": "^1.0", - "zendframework/zend-code": "~2.3|^3.0", + "zendframework/zend-code": "~2.3|^3.0.3", "psr/log": "^1.0" }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0", - "jms/serializer": "^1.3", + "jms/serializer": "^1.9", "goetas-webservices/xsd2php-runtime": "^0.2.7", "ext-xmldiff": "*" }, diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index b2fa77a6..3fde512c 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -373,7 +373,15 @@ public function generate(PHPClass $type) $this->handleValueMethod($class, $p, $extends); } else { - $class->setExtendedClass($extends->getFullName()); + //zend code ^3.0.3 wants FQCNs and resolves the short name based on provided use statements + //https://github.com/zendframework/zend-code/commit/4a6f4ab33480923ac6553ded903c97de168f37fe + //TypeGenerator is new to v3 + if(class_exists('\Zend\Code\Generator\TypeGenerator')) { + $class->setExtendedClass($extends->getFullName()); + } else { + //v2 simply used the string that was passed directly + $class->setExtendedClass($extends->getName()); + } if ($extends->getNamespace() != $type->getNamespace()) { if ($extends->getName() == $type->getName()) { From db632b2604810620970ecedff9a1915459806bbd Mon Sep 17 00:00:00 2001 From: rtek Date: Sat, 14 Apr 2018 20:38:27 -0400 Subject: [PATCH 5/6] Removed zend-code ~2.3 --- composer.json | 2 +- src/Php/ClassGenerator.php | 11 +---------- tests/AbstractGenerator.php | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index dba84a95..c236d621 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "symfony/config": "^2.2|^3.0|^4.0", "goetas-webservices/xsd-reader": "^0.2|^0.3.1", "doctrine/inflector": "^1.0", - "zendframework/zend-code": "~2.3|^3.0.3", + "zendframework/zend-code": "^3.0.3", "psr/log": "^1.0" }, diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index 3fde512c..a4f46819 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -373,20 +373,11 @@ public function generate(PHPClass $type) $this->handleValueMethod($class, $p, $extends); } else { - //zend code ^3.0.3 wants FQCNs and resolves the short name based on provided use statements - //https://github.com/zendframework/zend-code/commit/4a6f4ab33480923ac6553ded903c97de168f37fe - //TypeGenerator is new to v3 - if(class_exists('\Zend\Code\Generator\TypeGenerator')) { - $class->setExtendedClass($extends->getFullName()); - } else { - //v2 simply used the string that was passed directly - $class->setExtendedClass($extends->getName()); - } + $class->setExtendedClass($extends->getFullName()); if ($extends->getNamespace() != $type->getNamespace()) { if ($extends->getName() == $type->getName()) { $class->addUse($type->getExtends()->getFullName(), $extends->getName() . "Base"); - $class->setExtendedClass($extends->getName() . "Base"); } else { $class->addUse($extends->getFullName()); } diff --git a/tests/AbstractGenerator.php b/tests/AbstractGenerator.php index f0315311..6cd5ff2e 100644 --- a/tests/AbstractGenerator.php +++ b/tests/AbstractGenerator.php @@ -34,7 +34,7 @@ public function __construct(array $targetNs, array $aliases = array(), $tmp = nu $this->phpDir = "$tmp/php"; $this->jmsDir = "$tmp/jms"; - $this->namingStrategy = new VeryShortNamingStrategy(); + $this->namingStrategy = defined('PHP_WINDOWS_VERSION_BUILD') ? new VeryShortNamingStrategy() : new ShortNamingStrategy(); $this->loader = new ClassLoader(); foreach ($this->targetNs as $phpNs) { From a895f3cc78997752ed3db4393ffa2cdf4f26d5eb Mon Sep 17 00:00:00 2001 From: rtek Date: Sun, 15 Apr 2018 10:37:09 -0400 Subject: [PATCH 6/6] cs fixes --- tests/VeryShortNamingStrategy.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/VeryShortNamingStrategy.php b/tests/VeryShortNamingStrategy.php index 31690dc0..c7192657 100644 --- a/tests/VeryShortNamingStrategy.php +++ b/tests/VeryShortNamingStrategy.php @@ -12,33 +12,40 @@ class VeryShortNamingStrategy extends ShortNamingStrategy { /** - * Suffix with T instead of Type + * Suffix with 'T' instead of 'Type' * @param Type $type * @return string */ public function getTypeName(Type $type) { - if ($name = $this->classify($type->getName())) { - if (substr($name, -4) !== 'Type') { - $name .= "T"; - } elseif (substr($name, -4) === 'Type') { - $name = substr($name, 0, -3); - } + $name = $this->classify($type->getName()); + + if ($name && substr($name, -4) !== 'Type') { + return $name . 'T'; + } + + if (substr($name, -4) === 'Type') { + return substr($name, 0, -3); } + return $name; } /** - * Suffix with A instead of AType + * Suffix with 'A' instead of 'AType' * @param Type $type * @param string $parentName * @return string */ public function getAnonymousTypeName(Type $type, $parentName) { - return $this->classify($parentName) . "A"; + return $this->classify($parentName) . 'A'; } + /** + * @param string $name + * @return string + */ private function classify($name) { return Inflector::classify(str_replace(".", " ", $name));