Skip to content

Commit

Permalink
Typed properties on board
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed May 28, 2020
1 parent ed997cb commit 1e247c9
Show file tree
Hide file tree
Showing 103 changed files with 247 additions and 464 deletions.
4 changes: 1 addition & 3 deletions phpcs.xml.dist
Expand Up @@ -23,9 +23,7 @@
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingParameterTypeHint">
<exclude-pattern>src/Reflection/Adapter/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint">
<exclude-pattern>src/Reflection/Adapter/*</exclude-pattern>
Expand Down
24 changes: 8 additions & 16 deletions src/BetterReflection.php
Expand Up @@ -26,29 +26,21 @@

final class BetterReflection
{
/** @var SourceLocator|null */
private $sourceLocator;
private ?SourceLocator $sourceLocator;

/** @var ClassReflector|null */
private $classReflector;
private ?ClassReflector $classReflector;

/** @var FunctionReflector|null */
private $functionReflector;
private ?FunctionReflector $functionReflector;

/** @var ConstantReflector|null */
private $constantReflector;
private ?ConstantReflector $constantReflector;

/** @var Parser|null */
private $phpParser;
private ?Parser $phpParser;

/** @var AstLocator|null */
private $astLocator;
private ?AstLocator $astLocator;

/** @var FindReflectionOnLine|null */
private $findReflectionOnLine;
private ?FindReflectionOnLine $findReflectionOnLine;

/** @var SourceStubber */
private $sourceStubber;
private ?SourceStubber $sourceStubber;

public function sourceLocator() : SourceLocator
{
Expand Down
6 changes: 2 additions & 4 deletions src/Identifier/Identifier.php
Expand Up @@ -17,11 +17,9 @@ class Identifier

private const VALID_NAME_REGEXP = '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*/';

/** @var string */
private $name;
private string $name;

/** @var IdentifierType */
private $type;
private IdentifierType $type;

/**
* @throws InvalidIdentifierName
Expand Down
3 changes: 1 addition & 2 deletions src/Identifier/IdentifierType.php
Expand Up @@ -24,8 +24,7 @@ class IdentifierType
self::IDENTIFIER_CONSTANT => null,
];

/** @var string */
private $name;
private string $name;

public function __construct(string $type = self::IDENTIFIER_CLASS)
{
Expand Down
6 changes: 2 additions & 4 deletions src/NodeCompiler/CompilerContext.php
Expand Up @@ -10,11 +10,9 @@

class CompilerContext
{
/** @var Reflector */
private $reflector;
private Reflector $reflector;

/** @var ReflectionClass|null */
private $self;
private ?ReflectionClass $self;

public function __construct(Reflector $reflector, ?ReflectionClass $self)
{
Expand Down
3 changes: 1 addition & 2 deletions src/NodeCompiler/Exception/UnableToCompileNode.php
Expand Up @@ -15,8 +15,7 @@

class UnableToCompileNode extends LogicException
{
/** @var string|null */
private $constantName;
private ?string $constantName = null;

public function constantName() : ?string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionClass.php
Expand Up @@ -28,8 +28,7 @@

class ReflectionClass extends CoreReflectionClass
{
/** @var BetterReflectionClass */
private $betterReflectionClass;
private BetterReflectionClass $betterReflectionClass;

public function __construct(BetterReflectionClass $betterReflectionClass)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionClassConstant.php
Expand Up @@ -9,8 +9,7 @@

class ReflectionClassConstant extends CoreReflectionClassConstant
{
/** @var BetterReflectionClassConstant */
private $betterClassConstant;
private BetterReflectionClassConstant $betterClassConstant;

public function __construct(BetterReflectionClassConstant $betterClassConstant)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionFunction.php
Expand Up @@ -15,8 +15,7 @@

class ReflectionFunction extends CoreReflectionFunction
{
/** @var BetterReflectionFunction */
private $betterReflectionFunction;
private BetterReflectionFunction $betterReflectionFunction;

public function __construct(BetterReflectionFunction $betterReflectionFunction)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Reflection/Adapter/ReflectionMethod.php
Expand Up @@ -17,11 +17,9 @@

class ReflectionMethod extends CoreReflectionMethod
{
/** @var BetterReflectionMethod */
private $betterReflectionMethod;
private BetterReflectionMethod $betterReflectionMethod;

/** @var bool */
private $accessible = false;
private bool $accessible = false;

public function __construct(BetterReflectionMethod $betterReflectionMethod)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionNamedType.php
Expand Up @@ -9,8 +9,7 @@

class ReflectionNamedType extends CoreReflectionNamedType
{
/** @var BetterReflectionType */
private $betterReflectionType;
private BetterReflectionType $betterReflectionType;

public function __construct(BetterReflectionType $betterReflectionType)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionObject.php
Expand Up @@ -23,8 +23,7 @@

class ReflectionObject extends CoreReflectionObject
{
/** @var BetterReflectionObject */
private $betterReflectionObject;
private BetterReflectionObject $betterReflectionObject;

public function __construct(BetterReflectionObject $betterReflectionObject)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionParameter.php
Expand Up @@ -12,8 +12,7 @@

class ReflectionParameter extends CoreReflectionParameter
{
/** @var BetterReflectionParameter */
private $betterReflectionParameter;
private BetterReflectionParameter $betterReflectionParameter;

public function __construct(BetterReflectionParameter $betterReflectionParameter)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Reflection/Adapter/ReflectionProperty.php
Expand Up @@ -15,11 +15,9 @@

class ReflectionProperty extends CoreReflectionProperty
{
/** @var BetterReflectionProperty */
private $betterReflectionProperty;
private BetterReflectionProperty $betterReflectionProperty;

/** @var bool */
private $accessible = false;
private bool $accessible = false;

public function __construct(BetterReflectionProperty $betterReflectionProperty)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Adapter/ReflectionType.php
Expand Up @@ -9,8 +9,7 @@

class ReflectionType extends CoreReflectionType
{
/** @var BetterReflectionType */
private $betterReflectionType;
private BetterReflectionType $betterReflectionType;

public function __construct(BetterReflectionType $betterReflectionType)
{
Expand Down
35 changes: 14 additions & 21 deletions src/Reflection/ReflectionClass.php
Expand Up @@ -55,47 +55,43 @@ class ReflectionClass implements Reflection
{
public const ANONYMOUS_CLASS_NAME_PREFIX = 'class@anonymous';

/** @var Reflector */
private $reflector;
private Reflector $reflector;

/** @var NamespaceNode|null */
private $declaringNamespace;
private ?NamespaceNode $declaringNamespace = null;

/** @var LocatedSource */
private $locatedSource;
private LocatedSource $locatedSource;

/** @var ClassLikeNode */
private $node;
private ClassLikeNode $node;

/**
* @var ReflectionClassConstant[]|null indexed by name, when present
* @psalm-var ?array<string, ReflectionClassConstant>
*/
private $cachedReflectionConstants;
private ?array $cachedReflectionConstants = null;

/**
* @var ReflectionProperty[]|null
* @psalm-var ?array<string, ReflectionProperty>
*/
private $cachedImmediateProperties;
private ?array $cachedImmediateProperties = null;

/**
* @var ReflectionProperty[]|null
* @psalm-var ?array<string, ReflectionProperty>
*/
private $cachedProperties;
private ?array $cachedProperties = null;

/**
* @var ReflectionMethod[]|null
* @psalm-var ?array<lowercase-string, ReflectionMethod>
*/
private $cachedMethods;
private ?array $cachedMethods = null;

/** @var array<string, string>|null */
private $cachedTraitAliases;
private ?array $cachedTraitAliases = null;

/** @var array<string, string>|null */
private $cachedTraitPrecedences;
private ?array $cachedTraitPrecedences = null;

private function __construct()
{
Expand Down Expand Up @@ -147,13 +143,10 @@ public static function createFromNode(
) : self {
$class = new self();

$class->reflector = $reflector;
$class->locatedSource = $locatedSource;
$class->node = $node;

if ($namespace !== null) {
$class->declaringNamespace = $namespace;
}
$class->reflector = $reflector;
$class->locatedSource = $locatedSource;
$class->node = $node;
$class->declaringNamespace = $namespace;

return $class;
}
Expand Down
14 changes: 5 additions & 9 deletions src/Reflection/ReflectionClassConstant.php
Expand Up @@ -15,26 +15,22 @@

class ReflectionClassConstant
{
/** @var bool */
private $valueWasCached = false;
private bool $valueWasCached = false;

/**
* @var bool|int|float|string|array<bool|int|float|string>|null const value
* @psalm-var scalar|array<scalar>|null
*/
private $value;

/** @var Reflector */
private $reflector;
private Reflector $reflector;

/** @var ReflectionClass Constant owner */
private $owner;
private ReflectionClass $owner;

/** @var ClassConst */
private $node;
private ClassConst $node;

/** @var int */
private $positionInNode;
private int $positionInNode;

private function __construct()
{
Expand Down
15 changes: 5 additions & 10 deletions src/Reflection/ReflectionConstant.php
Expand Up @@ -26,29 +26,24 @@

class ReflectionConstant implements Reflection
{
/** @var Reflector */
private $reflector;
private Reflector $reflector;

/** @var Node\Stmt\Const_|Node\Expr\FuncCall */
private $node;

/** @var LocatedSource */
private $locatedSource;
private LocatedSource $locatedSource;

/** @var NamespaceNode|null */
private $declaringNamespace;
private ?NamespaceNode $declaringNamespace;

/** @var int|null */
private $positionInNode;
private ?int $positionInNode;

/**
* @var bool|int|float|string|array<bool|int|float|string>|null const value
* @psalm-var scalar|array<scalar>|null
*/
private $value;

/** @var bool */
private $valueWasCached = false;
private bool $valueWasCached = false;

private function __construct()
{
Expand Down
12 changes: 4 additions & 8 deletions src/Reflection/ReflectionFunctionAbstract.php
Expand Up @@ -43,20 +43,16 @@ abstract class ReflectionFunctionAbstract
{
public const CLOSURE_NAME = '{closure}';

/** @var NamespaceNode|null */
private $declaringNamespace;
private ?NamespaceNode $declaringNamespace;

/** @var LocatedSource */
private $locatedSource;
private LocatedSource $locatedSource;

/** @var Node\Stmt\ClassMethod|Node\Stmt\Function_|Node\Expr\Closure|null */
private $node;

/** @var Reflector */
private $reflector;
private Reflector $reflector;

/** @var Parser|null */
private static $parser;
private static ?Parser $parser;

protected function __construct()
{
Expand Down
12 changes: 4 additions & 8 deletions src/Reflection/ReflectionMethod.php
Expand Up @@ -24,17 +24,13 @@

class ReflectionMethod extends ReflectionFunctionAbstract
{
/** @var ReflectionClass */
private $declaringClass;
private ReflectionClass $declaringClass;

/** @var ReflectionClass */
private $implementingClass;
private ReflectionClass $implementingClass;

/** @var MethodNode */
private $methodNode;
private MethodNode $methodNode;

/** @var string|null */
private $aliasName;
private ?string $aliasName;

/**
* @internal
Expand Down

0 comments on commit 1e247c9

Please sign in to comment.