Skip to content

Commit fb39335

Browse files
authored
Merge pull request #34 from jaapio/feature/code-style-improvements
Improves code style
2 parents 18db4ab + ca661c2 commit fb39335

10 files changed

+134
-132
lines changed

src/FqsenResolver.php

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private function isFqsen($type)
5252
* @param Context $context
5353
*
5454
* @return Fqsen
55+
* @throws \InvalidArgumentException when type is not a valid FQSEN.
5556
*/
5657
private function resolvePartialStructuralElementName($type, Context $context)
5758
{

src/TypeResolver.php

+23-22
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ final class TypeResolver
2929

3030
/** @var string[] List of recognized keywords and unto which Value Object they map */
3131
private $keywords = array(
32-
'string' => 'phpDocumentor\Reflection\Types\String_',
33-
'int' => 'phpDocumentor\Reflection\Types\Integer',
34-
'integer' => 'phpDocumentor\Reflection\Types\Integer',
35-
'bool' => 'phpDocumentor\Reflection\Types\Boolean',
36-
'boolean' => 'phpDocumentor\Reflection\Types\Boolean',
37-
'float' => 'phpDocumentor\Reflection\Types\Float_',
38-
'double' => 'phpDocumentor\Reflection\Types\Float_',
39-
'object' => 'phpDocumentor\Reflection\Types\Object_',
40-
'mixed' => 'phpDocumentor\Reflection\Types\Mixed',
41-
'array' => 'phpDocumentor\Reflection\Types\Array_',
42-
'resource' => 'phpDocumentor\Reflection\Types\Resource',
43-
'void' => 'phpDocumentor\Reflection\Types\Void_',
44-
'null' => 'phpDocumentor\Reflection\Types\Null_',
45-
'scalar' => 'phpDocumentor\Reflection\Types\Scalar',
46-
'callback' => 'phpDocumentor\Reflection\Types\Callable_',
47-
'callable' => 'phpDocumentor\Reflection\Types\Callable_',
48-
'false' => 'phpDocumentor\Reflection\Types\Boolean',
49-
'true' => 'phpDocumentor\Reflection\Types\Boolean',
50-
'self' => 'phpDocumentor\Reflection\Types\Self_',
51-
'$this' => 'phpDocumentor\Reflection\Types\This',
52-
'static' => 'phpDocumentor\Reflection\Types\Static_',
53-
'parent' => 'phpDocumentor\Reflection\Types\Parent_',
32+
'string' => Types\String_::class,
33+
'int' => Types\Integer::class,
34+
'integer' => Types\Integer::class,
35+
'bool' => Types\Boolean::class,
36+
'boolean' => Types\Boolean::class,
37+
'float' => Types\Float_::class,
38+
'double' => Types\Float_::class,
39+
'object' => Object_::class,
40+
'mixed' => Types\Mixed::class,
41+
'array' => Array_::class,
42+
'resource' => Types\Resource::class,
43+
'void' => Types\Void_::class,
44+
'null' => Types\Null_::class,
45+
'scalar' => Types\Scalar::class,
46+
'callback' => Types\Callable_::class,
47+
'callable' => Types\Callable_::class,
48+
'false' => Types\Boolean::class,
49+
'true' => Types\Boolean::class,
50+
'self' => Types\Self_::class,
51+
'$this' => Types\This::class,
52+
'static' => Types\Static_::class,
53+
'parent' => Types\Parent_::class,
5454
'iterable' => Iterable_::class,
5555
);
5656

@@ -255,6 +255,7 @@ private function resolveKeyword($type)
255255
* Resolves the given FQSEN string into an FQSEN object.
256256
*
257257
* @param string $type
258+
* @param Context|null $context
258259
*
259260
* @return Object_
260261
*/

src/Types/Array_.php

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace phpDocumentor\Reflection\Types;
1414

15-
use phpDocumentor\Reflection\Fqsen;
1615
use phpDocumentor\Reflection\Type;
1716

1817
/**

src/Types/Compound.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
final class Compound implements Type
2525
{
2626
/** @var Type[] */
27-
private $types = [];
27+
private $types;
2828

2929
/**
3030
* Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface.
3131
*
3232
* @param Type[] $types
33+
* @throws \InvalidArgumentException when types are not all instance of Type
3334
*/
3435
public function __construct(array $types)
3536
{

src/Types/Context.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
final class Context
3030
{
3131
/** @var string The current namespace. */
32-
private $namespace = '';
32+
private $namespace;
3333

3434
/** @var array List of namespace aliases => Fully Qualified Namespace. */
35-
private $namespaceAliases = [];
35+
private $namespaceAliases;
3636

3737
/**
3838
* Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN)

src/Types/ContextFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class ContextFactory
3232
/**
3333
* Build a Context given a Class Reflection.
3434
*
35-
* @param \ReflectionClass $reflector
35+
* @param \Reflector $reflector
3636
*
3737
* @see Context for more information on Contexts.
3838
*

src/Types/Object_.php

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class Object_ implements Type
3131
* Initializes this object with an optional FQSEN, if not provided this object is considered 'untyped'.
3232
*
3333
* @param Fqsen $fqsen
34+
* @throws \InvalidArgumentException when provided $fqsen is not a valid type.
3435
*/
3536
public function __construct(Fqsen $fqsen = null)
3637
{

0 commit comments

Comments
 (0)