@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class PhpType implements PhpTypeInterface |
8 | 8 | { |
9 | - use QualifiedNamePart; |
|
9 | + use QualifiedNamePart; |
|
10 | 10 | |
11 | - public function __construct($qualifiedName) |
|
12 | - { |
|
13 | - $this->setQualifiedName($qualifiedName); |
|
14 | - } |
|
11 | + public function __construct($qualifiedName) |
|
12 | + { |
|
13 | + $this->setQualifiedName($qualifiedName); |
|
14 | + } |
|
15 | 15 | |
16 | - public function __toString(): string |
|
17 | - { |
|
18 | - return $this->getQualifiedName(); |
|
19 | - } |
|
16 | + public function __toString(): string |
|
17 | + { |
|
18 | + return $this->getQualifiedName(); |
|
19 | + } |
|
20 | 20 | } |
@@ -4,12 +4,10 @@ |
||
4 | 4 | |
5 | 5 | use gossi\codegen\model\parts\QualifiedNamePart; |
6 | 6 | |
7 | -class PhpType implements PhpTypeInterface |
|
8 | -{ |
|
7 | +class PhpType implements PhpTypeInterface { |
|
9 | 8 | use QualifiedNamePart; |
10 | 9 | |
11 | - public function __construct($qualifiedName) |
|
12 | - { |
|
10 | + public function __construct($qualifiedName) { |
|
13 | 11 | $this->setQualifiedName($qualifiedName); |
14 | 12 | } |
15 | 13 |
@@ -53,12 +53,12 @@ |
||
53 | 53 | $property->setParent($this); |
54 | 54 | $types = $property->getTypes(); |
55 | 55 | |
56 | - if ($types) { |
|
57 | - foreach ($types as $type) { |
|
58 | - $this->addUseStatement($type); |
|
59 | - $property->addType($type); |
|
60 | - } |
|
61 | - } |
|
56 | + if ($types) { |
|
57 | + foreach ($types as $type) { |
|
58 | + $this->addUseStatement($type); |
|
59 | + $property->addType($type); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | 63 | $this->properties->set($property->getName(), $property); |
64 | 64 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return $this |
80 | 80 | */ |
81 | 81 | public function addSimpleParameter(string $name, $types = null, $defaultValue = null) { |
82 | - $types = (array)$types; |
|
82 | + $types = (array)$types; |
|
83 | 83 | $parameter = new PhpParameter($name); |
84 | 84 | $parameter->setTypes($types); |
85 | 85 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function addSimpleDescParameter(string $name, $types = null, string $typeDescription = null, $defaultValue = null) { |
105 | 105 | $types = (array)$types; |
106 | - $parameter = new PhpParameter($name); |
|
106 | + $parameter = new PhpParameter($name); |
|
107 | 107 | $parameter->setTypes($types); |
108 | 108 | $parameter->setTypeDescription($typeDescription); |
109 | 109 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | $docblock = $this->getDocblock(); |
219 | 219 | $tags = $docblock->getTags('param'); |
220 | 220 | foreach ($this->parameters as $param) { |
221 | - if (!empty($noTypeHint[$param->getName()])) { |
|
222 | - continue; |
|
223 | - } |
|
221 | + if (!empty($noTypeHint[$param->getName()])) { |
|
222 | + continue; |
|
223 | + } |
|
224 | 224 | $ptag = $param->getDocblockTag(); |
225 | 225 | |
226 | 226 | $tag = $tags->find($ptag, function (ParamTag $tag, ParamTag $ptag) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return $this |
80 | 80 | */ |
81 | 81 | public function addSimpleParameter(string $name, $types = null, $defaultValue = null) { |
82 | - $types = (array)$types; |
|
82 | + $types = (array) $types; |
|
83 | 83 | $parameter = new PhpParameter($name); |
84 | 84 | $parameter->setTypes($types); |
85 | 85 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return $this |
103 | 103 | */ |
104 | 104 | public function addSimpleDescParameter(string $name, $types = null, string $typeDescription = null, $defaultValue = null) { |
105 | - $types = (array)$types; |
|
105 | + $types = (array) $types; |
|
106 | 106 | $parameter = new PhpParameter($name); |
107 | 107 | $parameter->setTypes($types); |
108 | 108 | $parameter->setTypeDescription($typeDescription); |
@@ -78,19 +78,19 @@ |
||
78 | 78 | return $this->interfaces; |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * @return iterable|PhpInterface[] |
|
83 | - */ |
|
84 | - public function getPhpInterfaces(): iterable |
|
85 | - { |
|
86 | - $interfaces = []; |
|
87 | - foreach ($this->interfaces as $interface) { |
|
88 | - $interfaces[] = interface_exists($interface) ? |
|
89 | - PhpInterface::fromName($interface) : PhpInterface::create($interface); |
|
90 | - } |
|
91 | - |
|
92 | - return $interfaces; |
|
93 | - } |
|
81 | + /** |
|
82 | + * @return iterable|PhpInterface[] |
|
83 | + */ |
|
84 | + public function getPhpInterfaces(): iterable |
|
85 | + { |
|
86 | + $interfaces = []; |
|
87 | + foreach ($this->interfaces as $interface) { |
|
88 | + $interfaces[] = interface_exists($interface) ? |
|
89 | + PhpInterface::fromName($interface) : PhpInterface::create($interface); |
|
90 | + } |
|
91 | + |
|
92 | + return $interfaces; |
|
93 | + } |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Checks whether interfaces exists |
@@ -75,18 +75,18 @@ |
||
75 | 75 | return $this->traits; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * @return iterable|PhpTrait[] |
|
80 | - */ |
|
81 | - public function getPhpTraits(): iterable { |
|
82 | - $traits = []; |
|
83 | - foreach ($this->traits as $trait) { |
|
84 | - $traits[] = trait_exists($trait) ? |
|
85 | - PhpTrait::fromName($trait) : PhpTrait::create($trait); |
|
86 | - } |
|
87 | - |
|
88 | - return $traits; |
|
89 | - } |
|
78 | + /** |
|
79 | + * @return iterable|PhpTrait[] |
|
80 | + */ |
|
81 | + public function getPhpTraits(): iterable { |
|
82 | + $traits = []; |
|
83 | + foreach ($this->traits as $trait) { |
|
84 | + $traits[] = trait_exists($trait) ? |
|
85 | + PhpTrait::fromName($trait) : PhpTrait::create($trait); |
|
86 | + } |
|
87 | + |
|
88 | + return $traits; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Checks whether a trait exists |
@@ -43,22 +43,22 @@ discard block |
||
43 | 43 | $p->setName($name); |
44 | 44 | $p->setPassedByReference($param->byRef); |
45 | 45 | |
46 | - $type = null; |
|
46 | + $type = null; |
|
47 | 47 | if (is_string($param->type)) { |
48 | 48 | $type = $param->type; |
49 | 49 | } else if ($param->type instanceof Name) { |
50 | - $type = implode('\\', $param->type->parts); |
|
51 | - $qualifiedType = TypeUtils::guessQualifiedName($this->struct, $type); |
|
52 | - if ($type !== $qualifiedType) { |
|
53 | - $type = $qualifiedType; |
|
54 | - } else { |
|
55 | - $type = '\\'.$type; |
|
56 | - } |
|
57 | - } |
|
50 | + $type = implode('\\', $param->type->parts); |
|
51 | + $qualifiedType = TypeUtils::guessQualifiedName($this->struct, $type); |
|
52 | + if ($type !== $qualifiedType) { |
|
53 | + $type = $qualifiedType; |
|
54 | + } else { |
|
55 | + $type = '\\'.$type; |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | 59 | if ($type) { |
60 | - $p->addType($type); |
|
61 | - } |
|
60 | + $p->addType($type); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | $this->parseValue($p, $param); |
64 | 64 | |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | }); |
68 | 68 | |
69 | 69 | if ($tag !== null) { |
70 | - $types = TypeUtils::expressionToTypes($tag->getType()); |
|
71 | - foreach ($types as $type) { |
|
72 | - $p->addType(TypeUtils::guessQualifiedName($this->struct, $type)); |
|
73 | - } |
|
74 | - $p->setTypeDescription($tag->getDescription()); |
|
70 | + $types = TypeUtils::expressionToTypes($tag->getType()); |
|
71 | + foreach ($types as $type) { |
|
72 | + $p->addType(TypeUtils::guessQualifiedName($this->struct, $type)); |
|
73 | + } |
|
74 | + $p->setTypeDescription($tag->getDescription()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $m->addParameter($p); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | if ($type !== $qualifiedType) { |
53 | 53 | $type = $qualifiedType; |
54 | 54 | } else { |
55 | - $type = '\\'.$type; |
|
55 | + $type = '\\' . $type; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 |
@@ -24,12 +24,12 @@ |
||
24 | 24 | $vars = $docblock->getTags('var'); |
25 | 25 | if ($vars->size() > 0) { |
26 | 26 | $var = $vars->get(0); |
27 | - $types = TypeUtils::expressionToTypes($var->getType()); |
|
28 | - foreach($types as $type) { |
|
29 | - $type = TypeUtils::guessQualifiedName($this->struct, $type); |
|
30 | - $member->addType($type); |
|
31 | - } |
|
32 | - $member->setTypeDescription($var->getDescription()); |
|
27 | + $types = TypeUtils::expressionToTypes($var->getType()); |
|
28 | + foreach($types as $type) { |
|
29 | + $type = TypeUtils::guessQualifiedName($this->struct, $type); |
|
30 | + $member->addType($type); |
|
31 | + } |
|
32 | + $member->setTypeDescription($var->getDescription()); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | if ($vars->size() > 0) { |
26 | 26 | $var = $vars->get(0); |
27 | 27 | $types = TypeUtils::expressionToTypes($var->getType()); |
28 | - foreach($types as $type) { |
|
28 | + foreach ($types as $type) { |
|
29 | 29 | $type = TypeUtils::guessQualifiedName($this->struct, $type); |
30 | 30 | $member->addType($type); |
31 | 31 | } |