@@ -25,13 +25,13 @@ |
||
25 | 25 | */ |
26 | 26 | final class Intersection extends AggregatedType |
27 | 27 | { |
28 | - /** |
|
29 | - * Initializes a intersection type (i.e. `\A&\B`) and tests if the provided types all implement the Type interface. |
|
30 | - * |
|
31 | - * @param array<Type> $types |
|
32 | - */ |
|
33 | - public function __construct(array $types) |
|
34 | - { |
|
35 | - parent::__construct($types, '&'); |
|
36 | - } |
|
28 | + /** |
|
29 | + * Initializes a intersection type (i.e. `\A&\B`) and tests if the provided types all implement the Type interface. |
|
30 | + * |
|
31 | + * @param array<Type> $types |
|
32 | + */ |
|
33 | + public function __construct(array $types) |
|
34 | + { |
|
35 | + parent::__construct($types, '&'); |
|
36 | + } |
|
37 | 37 | } |
@@ -35,61 +35,61 @@ |
||
35 | 35 | */ |
36 | 36 | final class Context |
37 | 37 | { |
38 | - /** @var string The current namespace. */ |
|
39 | - private $namespace; |
|
38 | + /** @var string The current namespace. */ |
|
39 | + private $namespace; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var string[] List of namespace aliases => Fully Qualified Namespace. |
|
43 | - * @psalm-var array<string, string> |
|
44 | - */ |
|
45 | - private $namespaceAliases; |
|
41 | + /** |
|
42 | + * @var string[] List of namespace aliases => Fully Qualified Namespace. |
|
43 | + * @psalm-var array<string, string> |
|
44 | + */ |
|
45 | + private $namespaceAliases; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN) |
|
49 | - * format (without a preceding `\`). |
|
50 | - * |
|
51 | - * @param string $namespace The namespace where this DocBlock resides in. |
|
52 | - * @param string[] $namespaceAliases List of namespace aliases => Fully Qualified Namespace. |
|
53 | - * @psalm-param array<string, string> $namespaceAliases |
|
54 | - */ |
|
55 | - public function __construct(string $namespace, array $namespaceAliases = []) |
|
56 | - { |
|
57 | - $this->namespace = $namespace !== 'global' && $namespace !== 'default' |
|
58 | - ? trim($namespace, '\\') |
|
59 | - : ''; |
|
47 | + /** |
|
48 | + * Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN) |
|
49 | + * format (without a preceding `\`). |
|
50 | + * |
|
51 | + * @param string $namespace The namespace where this DocBlock resides in. |
|
52 | + * @param string[] $namespaceAliases List of namespace aliases => Fully Qualified Namespace. |
|
53 | + * @psalm-param array<string, string> $namespaceAliases |
|
54 | + */ |
|
55 | + public function __construct(string $namespace, array $namespaceAliases = []) |
|
56 | + { |
|
57 | + $this->namespace = $namespace !== 'global' && $namespace !== 'default' |
|
58 | + ? trim($namespace, '\\') |
|
59 | + : ''; |
|
60 | 60 | |
61 | - foreach ($namespaceAliases as $alias => $fqnn) { |
|
62 | - if ($fqnn[0] === '\\') { |
|
63 | - $fqnn = substr($fqnn, 1); |
|
64 | - } |
|
61 | + foreach ($namespaceAliases as $alias => $fqnn) { |
|
62 | + if ($fqnn[0] === '\\') { |
|
63 | + $fqnn = substr($fqnn, 1); |
|
64 | + } |
|
65 | 65 | |
66 | - if ($fqnn[strlen($fqnn) - 1] === '\\') { |
|
67 | - $fqnn = substr($fqnn, 0, -1); |
|
68 | - } |
|
66 | + if ($fqnn[strlen($fqnn) - 1] === '\\') { |
|
67 | + $fqnn = substr($fqnn, 0, -1); |
|
68 | + } |
|
69 | 69 | |
70 | - $namespaceAliases[$alias] = $fqnn; |
|
71 | - } |
|
70 | + $namespaceAliases[$alias] = $fqnn; |
|
71 | + } |
|
72 | 72 | |
73 | - $this->namespaceAliases = $namespaceAliases; |
|
74 | - } |
|
73 | + $this->namespaceAliases = $namespaceAliases; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Returns the Qualified Namespace Name (thus without `\` in front) where the associated element is in. |
|
78 | - */ |
|
79 | - public function getNamespace(): string |
|
80 | - { |
|
81 | - return $this->namespace; |
|
82 | - } |
|
76 | + /** |
|
77 | + * Returns the Qualified Namespace Name (thus without `\` in front) where the associated element is in. |
|
78 | + */ |
|
79 | + public function getNamespace(): string |
|
80 | + { |
|
81 | + return $this->namespace; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Returns a list of Qualified Namespace Names (thus without `\` in front) that are imported, the keys represent |
|
86 | - * the alias for the imported Namespace. |
|
87 | - * |
|
88 | - * @return string[] |
|
89 | - * @psalm-return array<string, string> |
|
90 | - */ |
|
91 | - public function getNamespaceAliases(): array |
|
92 | - { |
|
93 | - return $this->namespaceAliases; |
|
94 | - } |
|
84 | + /** |
|
85 | + * Returns a list of Qualified Namespace Names (thus without `\` in front) that are imported, the keys represent |
|
86 | + * the alias for the imported Namespace. |
|
87 | + * |
|
88 | + * @return string[] |
|
89 | + * @psalm-return array<string, string> |
|
90 | + */ |
|
91 | + public function getNamespaceAliases(): array |
|
92 | + { |
|
93 | + return $this->namespaceAliases; |
|
94 | + } |
|
95 | 95 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | */ |
26 | 26 | final class Never_ implements Type |
27 | 27 | { |
28 | - /** |
|
29 | - * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
30 | - */ |
|
31 | - public function __toString(): string |
|
32 | - { |
|
33 | - return 'never'; |
|
34 | - } |
|
28 | + /** |
|
29 | + * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
30 | + */ |
|
31 | + public function __toString(): string |
|
32 | + { |
|
33 | + return 'never'; |
|
34 | + } |
|
35 | 35 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | */ |
26 | 26 | final class This implements Type |
27 | 27 | { |
28 | - /** |
|
29 | - * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
30 | - */ |
|
31 | - public function __toString(): string |
|
32 | - { |
|
33 | - return '$this'; |
|
34 | - } |
|
28 | + /** |
|
29 | + * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
30 | + */ |
|
31 | + public function __toString(): string |
|
32 | + { |
|
33 | + return '$this'; |
|
34 | + } |
|
35 | 35 | } |
@@ -22,11 +22,11 @@ |
||
22 | 22 | */ |
23 | 23 | class String_ implements Type |
24 | 24 | { |
25 | - /** |
|
26 | - * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
27 | - */ |
|
28 | - public function __toString(): string |
|
29 | - { |
|
30 | - return 'string'; |
|
31 | - } |
|
25 | + /** |
|
26 | + * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
27 | + */ |
|
28 | + public function __toString(): string |
|
29 | + { |
|
30 | + return 'string'; |
|
31 | + } |
|
32 | 32 | } |
@@ -31,38 +31,38 @@ |
||
31 | 31 | */ |
32 | 32 | final class Collection extends AbstractList |
33 | 33 | { |
34 | - /** @var Fqsen|null */ |
|
35 | - private $fqsen; |
|
34 | + /** @var Fqsen|null */ |
|
35 | + private $fqsen; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Initializes this representation of an array with the given Type or Fqsen. |
|
39 | - */ |
|
40 | - public function __construct(?Fqsen $fqsen, Type $valueType, ?Type $keyType = null) |
|
41 | - { |
|
42 | - parent::__construct($valueType, $keyType); |
|
37 | + /** |
|
38 | + * Initializes this representation of an array with the given Type or Fqsen. |
|
39 | + */ |
|
40 | + public function __construct(?Fqsen $fqsen, Type $valueType, ?Type $keyType = null) |
|
41 | + { |
|
42 | + parent::__construct($valueType, $keyType); |
|
43 | 43 | |
44 | - $this->fqsen = $fqsen; |
|
45 | - } |
|
44 | + $this->fqsen = $fqsen; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Returns the FQSEN associated with this object. |
|
49 | - */ |
|
50 | - public function getFqsen(): ?Fqsen |
|
51 | - { |
|
52 | - return $this->fqsen; |
|
53 | - } |
|
47 | + /** |
|
48 | + * Returns the FQSEN associated with this object. |
|
49 | + */ |
|
50 | + public function getFqsen(): ?Fqsen |
|
51 | + { |
|
52 | + return $this->fqsen; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
57 | - */ |
|
58 | - public function __toString(): string |
|
59 | - { |
|
60 | - $objectType = (string) ($this->fqsen ?? 'object'); |
|
55 | + /** |
|
56 | + * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
57 | + */ |
|
58 | + public function __toString(): string |
|
59 | + { |
|
60 | + $objectType = (string) ($this->fqsen ?? 'object'); |
|
61 | 61 | |
62 | - if ($this->keyType === null) { |
|
63 | - return $objectType . '<' . $this->valueType . '>'; |
|
64 | - } |
|
62 | + if ($this->keyType === null) { |
|
63 | + return $objectType . '<' . $this->valueType . '>'; |
|
64 | + } |
|
65 | 65 | |
66 | - return $objectType . '<' . $this->keyType . ',' . $this->valueType . '>'; |
|
67 | - } |
|
66 | + return $objectType . '<' . $this->keyType . ',' . $this->valueType . '>'; |
|
67 | + } |
|
68 | 68 | } |
@@ -60,9 +60,9 @@ |
||
60 | 60 | $objectType = (string) ($this->fqsen ?? 'object'); |
61 | 61 | |
62 | 62 | if ($this->keyType === null) { |
63 | - return $objectType . '<' . $this->valueType . '>'; |
|
63 | + return $objectType.'<'.$this->valueType.'>'; |
|
64 | 64 | } |
65 | 65 | |
66 | - return $objectType . '<' . $this->keyType . ',' . $this->valueType . '>'; |
|
66 | + return $objectType.'<'.$this->keyType.','.$this->valueType.'>'; |
|
67 | 67 | } |
68 | 68 | } |
@@ -24,11 +24,11 @@ |
||
24 | 24 | */ |
25 | 25 | final class Self_ implements Type |
26 | 26 | { |
27 | - /** |
|
28 | - * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
29 | - */ |
|
30 | - public function __toString(): string |
|
31 | - { |
|
32 | - return 'self'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
29 | + */ |
|
30 | + public function __toString(): string |
|
31 | + { |
|
32 | + return 'self'; |
|
33 | + } |
|
34 | 34 | } |
@@ -25,18 +25,18 @@ |
||
25 | 25 | */ |
26 | 26 | final class ArrayKey extends AggregatedType implements PseudoType |
27 | 27 | { |
28 | - public function __construct() |
|
29 | - { |
|
30 | - parent::__construct([new String_(), new Integer()], '|'); |
|
31 | - } |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + parent::__construct([new String_(), new Integer()], '|'); |
|
31 | + } |
|
32 | 32 | |
33 | - public function underlyingType(): Type |
|
34 | - { |
|
35 | - return new Compound([new String_(), new Integer()]); |
|
36 | - } |
|
33 | + public function underlyingType(): Type |
|
34 | + { |
|
35 | + return new Compound([new String_(), new Integer()]); |
|
36 | + } |
|
37 | 37 | |
38 | - public function __toString(): string |
|
39 | - { |
|
40 | - return 'array-key'; |
|
41 | - } |
|
38 | + public function __toString(): string |
|
39 | + { |
|
40 | + return 'array-key'; |
|
41 | + } |
|
42 | 42 | } |
@@ -24,16 +24,16 @@ |
||
24 | 24 | */ |
25 | 25 | final class TraitString extends String_ implements PseudoType |
26 | 26 | { |
27 | - public function underlyingType(): Type |
|
28 | - { |
|
29 | - return new String_(); |
|
30 | - } |
|
27 | + public function underlyingType(): Type |
|
28 | + { |
|
29 | + return new String_(); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
34 | - */ |
|
35 | - public function __toString(): string |
|
36 | - { |
|
37 | - return 'trait-string'; |
|
38 | - } |
|
32 | + /** |
|
33 | + * Returns a rendered output of the Type as it would be used in a DocBlock. |
|
34 | + */ |
|
35 | + public function __toString(): string |
|
36 | + { |
|
37 | + return 'trait-string'; |
|
38 | + } |
|
39 | 39 | } |