Skip to content

Commit a1e3d79

Browse files
authored
Merge pull request #14 from goetas-webservices/impr
minor code improvements
2 parents a9049a2 + c8bc8e2 commit a1e3d79

File tree

5 files changed

+50
-40
lines changed

5 files changed

+50
-40
lines changed

bin/xsd2php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env php
22
<?php
33
$paths = [
4-
__DIR__ . '/../vendor/autoload.php',
5-
__DIR__ . '/../../../autoload.php'
4+
__DIR__ . '/../../../autoload.php',
5+
__DIR__ . '/../vendor/autoload.php'
66
];
77
foreach ($paths as $path) {
88
if (is_file($path)) {

src/DependencyInjection/Configuration.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,42 @@ public function getConfigTreeBuilder()
1313

1414
$rootNode
1515
->children()
16-
->scalarNode('naming_strategy')
17-
->defaultValue('short')
18-
->cannotBeEmpty()
19-
->end()
20-
->scalarNode('path_generator')
21-
->defaultValue('psr4')
22-
->cannotBeEmpty()
23-
->end()
24-
->arrayNode('namespaces')->fixXmlConfig('namespace')
25-
->cannotBeEmpty()->isRequired()
26-
->requiresAtLeastOneElement()
27-
->prototype('scalar')
28-
->end()
29-
->end()
30-
->arrayNode('known_locations')->fixXmlConfig('known_location')
31-
->prototype('scalar')
32-
->end()
33-
->end()
34-
->arrayNode('destinations_php')->fixXmlConfig('destination')
35-
->cannotBeEmpty()->isRequired()
36-
->requiresAtLeastOneElement()
37-
->prototype('scalar')
38-
->end()
39-
->end()
40-
->arrayNode('destinations_jms')->fixXmlConfig('destination')
41-
->cannotBeEmpty()->isRequired()
42-
->requiresAtLeastOneElement()
43-
->prototype('scalar')
44-
->end()
45-
->end()
46-
->arrayNode('aliases')->fixXmlConfig('alias')
47-
->prototype('array')
48-
->prototype('scalar')
49-
->end()
50-
->end()
51-
->end()
16+
->scalarNode('naming_strategy')
17+
->defaultValue('short')
18+
->cannotBeEmpty()
19+
->end()
20+
->scalarNode('path_generator')
21+
->defaultValue('psr4')
22+
->cannotBeEmpty()
23+
->end()
24+
->arrayNode('namespaces')->fixXmlConfig('namespace')
25+
->cannotBeEmpty()->isRequired()
26+
->requiresAtLeastOneElement()
27+
->prototype('scalar')
28+
->end()
29+
->end()
30+
->arrayNode('known_locations')->fixXmlConfig('known_location')
31+
->prototype('scalar')
32+
->end()
33+
->end()
34+
->arrayNode('destinations_php')->fixXmlConfig('destination')
35+
->cannotBeEmpty()->isRequired()
36+
->requiresAtLeastOneElement()
37+
->prototype('scalar')
38+
->end()
39+
->end()
40+
->arrayNode('destinations_jms')->fixXmlConfig('destination')
41+
->cannotBeEmpty()->isRequired()
42+
->requiresAtLeastOneElement()
43+
->prototype('scalar')
44+
->end()
45+
->end()
46+
->arrayNode('aliases')->fixXmlConfig('alias')
47+
->prototype('array')
48+
->prototype('scalar')
49+
->end()
50+
->end()
51+
->end()
5252
->end();
5353
return $treeBuilder;
5454
}

src/Php/ClassGenerator.php

+1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ private function handleProperty(Generator\ClassGenerator $class, PHPProperty $pr
345345
$tag->setTypes($t->getPhpType() . "[]");
346346
}
347347
}
348+
$generatedProp->setDefaultValue($type->getArg()->getDefault());
348349
} elseif ($type) {
349350

350351
if ($type->isNativeType()) {

src/Php/PathGenerator/Psr4PathGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Psr4PathGenerator extends Psr4PathGeneratorBase implements PathGenerator
1010
public function getPath(ClassGenerator $php)
1111
{
1212
foreach ($this->namespaces as $namespace => $dir) {
13-
;
13+
1414
if (strpos(trim($php->getNamespaceName()) . "\\", $namespace) === 0) {
1515
$d = strtr(substr($php->getNamespaceName(), strlen($namespace)), "\\", "/");
1616
$dir = rtrim($dir, "/") . "/" . $d;

src/Php/PhpConverter.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ public function visitElementDef(ElementDef $element, $skip = false)
167167
if (!$element->getType()->getName()) {
168168
$this->visitTypeBase($class, $element->getType());
169169
} else {
170+
171+
if ($alias = $this->getTypeAlias($element)) {
172+
$class->setName($alias);
173+
$class->setNamespace(null);
174+
$this->classes[spl_object_hash($element)]["skip"] = true;
175+
$this->skipByType[spl_object_hash($element)] = true;
176+
return $class;
177+
}
178+
170179
$this->handleClassExtension($class, $element->getType());
171180
}
172181
}
@@ -425,7 +434,7 @@ private function visitElement(PHPClass $class, Schema $schema, ElementSingle $el
425434
} elseif ($this->isArrayElement($element)) {
426435
$arg = new PHPArg($this->getNamingStrategy()->getPropertyName($element));
427436
$arg->setType($this->findPHPClass($class, $element));
428-
$arg->setDefault('array()');
437+
$arg->setDefault(array());
429438
$property->setType(new PHPClassOf($arg));
430439
return $property;
431440
}

0 commit comments

Comments
 (0)