Skip to content

Commit

Permalink
Merge pull request #203 from phpDocumentor/php73
Browse files Browse the repository at this point in the history
Downgrade to php 7.3
  • Loading branch information
jaapio authored Feb 23, 2024
2 parents 8ea4d87 + f4df84e commit 153ae66
Show file tree
Hide file tree
Showing 21 changed files with 445 additions and 480 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^7.3 || ^8.0",
"phpdocumentor/reflection-common": "^2.0",
"phpstan/phpdoc-parser": "^1.13",
"doctrine/deprecations": "^1.0"
Expand Down Expand Up @@ -42,7 +42,7 @@
},
"config": {
"platform": {
"php": "7.4.0"
"php": "7.3.0"
},
"allow-plugins": {
"phpstan/extension-installer": true
Expand Down
755 changes: 343 additions & 412 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -21,6 +22,6 @@

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74
DowngradeLevelSetList::DOWN_TO_PHP_73
]);
};
2 changes: 1 addition & 1 deletion src/PseudoTypes/ArrayShape.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class ArrayShape implements PseudoType
{
/** @var ArrayShapeItem[] */
private array $items;
private $items;

public function __construct(ArrayShapeItem ...$items)
{
Expand Down
9 changes: 6 additions & 3 deletions src/PseudoTypes/ArrayShapeItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@

final class ArrayShapeItem
{
private ?string $key;
private Type $value;
private bool $optional;
/** @var string|null */
private $key;
/** @var Type */
private $value;
/** @var bool */
private $optional;

public function __construct(?string $key, ?Type $value, bool $optional)
{
Expand Down
6 changes: 4 additions & 2 deletions src/PseudoTypes/ConstExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
/** @psalm-immutable */
final class ConstExpression implements PseudoType
{
private Type $owner;
private string $expression;
/** @var Type */
private $owner;
/** @var string */
private $expression;

public function __construct(Type $owner, string $expression)
{
Expand Down
3 changes: 2 additions & 1 deletion src/PseudoTypes/FloatValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
/** @psalm-immutable */
class FloatValue implements PseudoType
{
private float $value;
/** @var float */
private $value;

public function __construct(float $value)
{
Expand Down
6 changes: 4 additions & 2 deletions src/PseudoTypes/IntegerRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
*/
final class IntegerRange extends Integer implements PseudoType
{
private string $minValue;
/** @var string */
private $minValue;

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

public function __construct(string $minValue, string $maxValue)
{
Expand Down
3 changes: 2 additions & 1 deletion src/PseudoTypes/IntegerValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
/** @psalm-immutable */
final class IntegerValue implements PseudoType
{
private int $value;
/** @var int */
private $value;

public function __construct(int $value)
{
Expand Down
3 changes: 2 additions & 1 deletion src/PseudoTypes/StringValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
/** @psalm-immutable */
class StringValue implements PseudoType
{
private string $value;
/** @var string */
private $value;

public function __construct(string $value)
{
Expand Down
85 changes: 48 additions & 37 deletions src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ final class TypeResolver
* @var array<string, string> List of recognized keywords and unto which Value Object they map
* @psalm-var array<string, class-string<Type>>
*/
private array $keywords = [
private $keywords = [
'string' => String_::class,
'class-string' => ClassString::class,
'interface-string' => InterfaceString::class,
Expand Down Expand Up @@ -159,12 +159,21 @@ final class TypeResolver
'non-empty-list' => NonEmptyList::class,
];

/** @psalm-readonly */
private FqsenResolver $fqsenResolver;
/** @psalm-readonly */
private TypeParser $typeParser;
/** @psalm-readonly */
private Lexer $lexer;
/**
* @psalm-readonly
* @var FqsenResolver
*/
private $fqsenResolver;
/**
* @psalm-readonly
* @var TypeParser
*/
private $typeParser;
/**
* @psalm-readonly
* @var Lexer
*/
private $lexer;

/**
* Initializes this TypeResolver with the means to create and resolve Fqsen objects.
Expand Down Expand Up @@ -227,11 +236,13 @@ public function createType(?TypeNode $type, Context $context): Type
case ArrayShapeNode::class:
return new ArrayShape(
...array_map(
fn (ArrayShapeItemNode $item) => new ArrayShapeItem(
(string) $item->keyName,
$this->createType($item->valueType, $context),
$item->optional
),
function (ArrayShapeItemNode $item) use ($context): ArrayShapeItem {
return new ArrayShapeItem(
(string) $item->keyName,
$this->createType($item->valueType, $context),
$item->optional
);
},
$type->items
)
);
Expand All @@ -252,7 +263,7 @@ public function createType(?TypeNode $type, Context $context): Type
return new Intersection(
array_filter(
array_map(
function (TypeNode $nestedType) use ($context) {
function (TypeNode $nestedType) use ($context): Type {
$type = $this->createType($nestedType, $context);
if ($type instanceof AggregatedType) {
return new Expression($type);
Expand All @@ -274,7 +285,7 @@ function (TypeNode $nestedType) use ($context) {
return new Compound(
array_filter(
array_map(
function (TypeNode $nestedType) use ($context) {
function (TypeNode $nestedType) use ($context): Type {
$type = $this->createType($nestedType, $context);
if ($type instanceof AggregatedType) {
return new Expression($type);
Expand Down Expand Up @@ -343,16 +354,15 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ
throw new RuntimeException('int<min,max> has not the correct format');
}

return new IntegerRange(
(string) $type->genericTypes[0],
(string) $type->genericTypes[1],
);
return new IntegerRange((string) $type->genericTypes[0], (string) $type->genericTypes[1]);

case 'iterable':
return new Iterable_(
...array_reverse(
array_map(
fn (TypeNode $genericType) => $this->createType($genericType, $context),
function (TypeNode $genericType) use ($context): Type {
return $this->createType($genericType, $context);
},
$type->genericTypes
)
)
Expand All @@ -368,7 +378,9 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ
$collectionType->getFqsen(),
...array_reverse(
array_map(
fn (TypeNode $genericType) => $this->createType($genericType, $context),
function (TypeNode $genericType) use ($context): Type {
return $this->createType($genericType, $context);
},
$type->genericTypes
)
)
Expand All @@ -378,21 +390,18 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ

private function createFromCallable(CallableTypeNode $type, Context $context): Callable_
{
return new Callable_(
array_map(
function (CallableTypeParameterNode $param) use ($context) {
return new CallableParameter(
$this->createType($param->type, $context),
$param->parameterName !== '' ? trim($param->parameterName, '$') : null,
$param->isReference,
$param->isVariadic,
$param->isOptional
);
},
$type->parameters
),
$this->createType($type->returnType, $context),
);
return new Callable_(array_map(
function (CallableTypeParameterNode $param) use ($context): CallableParameter {
return new CallableParameter(
$this->createType($param->type, $context),
$param->parameterName !== '' ? trim($param->parameterName, '$') : null,
$param->isReference,
$param->isVariadic,
$param->isOptional
);
},
$type->parameters
), $this->createType($type->returnType, $context));
}

private function createFromConst(ConstTypeNode $type, Context $context): Type
Expand Down Expand Up @@ -542,7 +551,9 @@ private function createArray(array $typeNodes, Context $context): Array_
{
$types = array_reverse(
array_map(
fn (TypeNode $node) => $this->createType($node, $context),
function (TypeNode $node) use ($context): Type {
return $this->createType($node, $context);
},
$typeNodes
)
);
Expand Down Expand Up @@ -596,7 +607,7 @@ private function tryParseRemainingCompoundTypes(TokenIterator $tokenIterator, Co
'phpdocumentor/type-resolver',
'https://github.com/phpDocumentor/TypeResolver/issues/184',
'Legacy nullable type detected, please update your code as
you are using nullable types in a docblock. support will be removed in v2.0.0',
you are using nullable types in a docblock. support will be removed in v2.0.0'
);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Types/AggregatedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ abstract class AggregatedType implements Type, IteratorAggregate
* @psalm-allow-private-mutation
* @var array<int, Type>
*/
private array $types = [];
private $types = [];

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

/**
* @param array<Type> $types
Expand Down
15 changes: 10 additions & 5 deletions src/Types/CallableParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@
*/
final class CallableParameter
{
private Type $type;
/** @var Type */
private $type;

private bool $isReference;
/** @var bool */
private $isReference;

private bool $isVariadic;
/** @var bool */
private $isVariadic;

private bool $isOptional;
/** @var bool */
private $isOptional;

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

public function __construct(
Type $type,
Expand Down
5 changes: 3 additions & 2 deletions src/Types/Callable_.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
*/
final class Callable_ implements Type
{
private ?Type $returnType;
/** @var Type|null */
private $returnType;
/** @var CallableParameter[] */
private array $parameters;
private $parameters;

/**
* @param CallableParameter[] $parameters
Expand Down
3 changes: 2 additions & 1 deletion src/Types/ClassString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
*/
final class ClassString extends String_ implements PseudoType
{
private ?Fqsen $fqsen;
/** @var Fqsen|null */
private $fqsen;

/**
* Initializes this representation of a class string with the given Fqsen.
Expand Down
3 changes: 2 additions & 1 deletion src/Types/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
*/
final class Collection extends AbstractList
{
private ?Fqsen $fqsen;
/** @var Fqsen|null */
private $fqsen;

/**
* Initializes this representation of an array with the given Type or Fqsen.
Expand Down
4 changes: 2 additions & 2 deletions src/Types/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
final class Context
{
/** @var string The current namespace. */
private string $namespace;
private $namespace;

/**
* @var string[] List of namespace aliases => Fully Qualified Namespace.
* @psalm-var array<string, string>
*/
private array $namespaceAliases;
private $namespaceAliases;

/**
* Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN)
Expand Down
3 changes: 2 additions & 1 deletion src/Types/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*/
final class Expression implements Type
{
protected Type $valueType;
/** @var Type */
protected $valueType;

/**
* Initializes this representation of an array with the given Type.
Expand Down
3 changes: 2 additions & 1 deletion src/Types/InterfaceString.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/
final class InterfaceString implements Type
{
private ?Fqsen $fqsen;
/** @var Fqsen|null */
private $fqsen;

/**
* Initializes this representation of a class string with the given Fqsen.
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Nullable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
final class Nullable implements Type
{
/** @var Type The actual type that is wrapped */
private Type $realType;
private $realType;

/**
* Initialises this nullable type using the real type embedded
Expand Down
Loading

0 comments on commit 153ae66

Please sign in to comment.