Skip to content

Commit 153ae66

Browse files
authored
Merge pull request #203 from phpDocumentor/php73
Downgrade to php 7.3
2 parents 8ea4d87 + f4df84e commit 153ae66

21 files changed

+445
-480
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.4 || ^8.0",
13+
"php": "^7.3 || ^8.0",
1414
"phpdocumentor/reflection-common": "^2.0",
1515
"phpstan/phpdoc-parser": "^1.13",
1616
"doctrine/deprecations": "^1.0"
@@ -42,7 +42,7 @@
4242
},
4343
"config": {
4444
"platform": {
45-
"php": "7.4.0"
45+
"php": "7.3.0"
4646
},
4747
"allow-plugins": {
4848
"phpstan/extension-installer": true

composer.lock

+343-412
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rector.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
66
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\DowngradeLevelSetList;
78
use Rector\Set\ValueObject\LevelSetList;
89

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

2223
// define sets of rules
2324
$rectorConfig->sets([
24-
LevelSetList::UP_TO_PHP_74
25+
DowngradeLevelSetList::DOWN_TO_PHP_73
2526
]);
2627
};

src/PseudoTypes/ArrayShape.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class ArrayShape implements PseudoType
2626
{
2727
/** @var ArrayShapeItem[] */
28-
private array $items;
28+
private $items;
2929

3030
public function __construct(ArrayShapeItem ...$items)
3131
{

src/PseudoTypes/ArrayShapeItem.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020

2121
final class ArrayShapeItem
2222
{
23-
private ?string $key;
24-
private Type $value;
25-
private bool $optional;
23+
/** @var string|null */
24+
private $key;
25+
/** @var Type */
26+
private $value;
27+
/** @var bool */
28+
private $optional;
2629

2730
public function __construct(?string $key, ?Type $value, bool $optional)
2831
{

src/PseudoTypes/ConstExpression.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
/** @psalm-immutable */
2323
final class ConstExpression implements PseudoType
2424
{
25-
private Type $owner;
26-
private string $expression;
25+
/** @var Type */
26+
private $owner;
27+
/** @var string */
28+
private $expression;
2729

2830
public function __construct(Type $owner, string $expression)
2931
{

src/PseudoTypes/FloatValue.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
/** @psalm-immutable */
2121
class FloatValue implements PseudoType
2222
{
23-
private float $value;
23+
/** @var float */
24+
private $value;
2425

2526
public function __construct(float $value)
2627
{

src/PseudoTypes/IntegerRange.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
*/
2525
final class IntegerRange extends Integer implements PseudoType
2626
{
27-
private string $minValue;
27+
/** @var string */
28+
private $minValue;
2829

29-
private string $maxValue;
30+
/** @var string */
31+
private $maxValue;
3032

3133
public function __construct(string $minValue, string $maxValue)
3234
{

src/PseudoTypes/IntegerValue.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
/** @psalm-immutable */
2121
final class IntegerValue implements PseudoType
2222
{
23-
private int $value;
23+
/** @var int */
24+
private $value;
2425

2526
public function __construct(int $value)
2627
{

src/PseudoTypes/StringValue.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
/** @psalm-immutable */
2323
class StringValue implements PseudoType
2424
{
25-
private string $value;
25+
/** @var string */
26+
private $value;
2627

2728
public function __construct(string $value)
2829
{

src/TypeResolver.php

+48-37
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ final class TypeResolver
115115
* @var array<string, string> List of recognized keywords and unto which Value Object they map
116116
* @psalm-var array<string, class-string<Type>>
117117
*/
118-
private array $keywords = [
118+
private $keywords = [
119119
'string' => String_::class,
120120
'class-string' => ClassString::class,
121121
'interface-string' => InterfaceString::class,
@@ -159,12 +159,21 @@ final class TypeResolver
159159
'non-empty-list' => NonEmptyList::class,
160160
];
161161

162-
/** @psalm-readonly */
163-
private FqsenResolver $fqsenResolver;
164-
/** @psalm-readonly */
165-
private TypeParser $typeParser;
166-
/** @psalm-readonly */
167-
private Lexer $lexer;
162+
/**
163+
* @psalm-readonly
164+
* @var FqsenResolver
165+
*/
166+
private $fqsenResolver;
167+
/**
168+
* @psalm-readonly
169+
* @var TypeParser
170+
*/
171+
private $typeParser;
172+
/**
173+
* @psalm-readonly
174+
* @var Lexer
175+
*/
176+
private $lexer;
168177

169178
/**
170179
* Initializes this TypeResolver with the means to create and resolve Fqsen objects.
@@ -227,11 +236,13 @@ public function createType(?TypeNode $type, Context $context): Type
227236
case ArrayShapeNode::class:
228237
return new ArrayShape(
229238
...array_map(
230-
fn (ArrayShapeItemNode $item) => new ArrayShapeItem(
231-
(string) $item->keyName,
232-
$this->createType($item->valueType, $context),
233-
$item->optional
234-
),
239+
function (ArrayShapeItemNode $item) use ($context): ArrayShapeItem {
240+
return new ArrayShapeItem(
241+
(string) $item->keyName,
242+
$this->createType($item->valueType, $context),
243+
$item->optional
244+
);
245+
},
235246
$type->items
236247
)
237248
);
@@ -252,7 +263,7 @@ public function createType(?TypeNode $type, Context $context): Type
252263
return new Intersection(
253264
array_filter(
254265
array_map(
255-
function (TypeNode $nestedType) use ($context) {
266+
function (TypeNode $nestedType) use ($context): Type {
256267
$type = $this->createType($nestedType, $context);
257268
if ($type instanceof AggregatedType) {
258269
return new Expression($type);
@@ -274,7 +285,7 @@ function (TypeNode $nestedType) use ($context) {
274285
return new Compound(
275286
array_filter(
276287
array_map(
277-
function (TypeNode $nestedType) use ($context) {
288+
function (TypeNode $nestedType) use ($context): Type {
278289
$type = $this->createType($nestedType, $context);
279290
if ($type instanceof AggregatedType) {
280291
return new Expression($type);
@@ -343,16 +354,15 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ
343354
throw new RuntimeException('int<min,max> has not the correct format');
344355
}
345356

346-
return new IntegerRange(
347-
(string) $type->genericTypes[0],
348-
(string) $type->genericTypes[1],
349-
);
357+
return new IntegerRange((string) $type->genericTypes[0], (string) $type->genericTypes[1]);
350358

351359
case 'iterable':
352360
return new Iterable_(
353361
...array_reverse(
354362
array_map(
355-
fn (TypeNode $genericType) => $this->createType($genericType, $context),
363+
function (TypeNode $genericType) use ($context): Type {
364+
return $this->createType($genericType, $context);
365+
},
356366
$type->genericTypes
357367
)
358368
)
@@ -368,7 +378,9 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ
368378
$collectionType->getFqsen(),
369379
...array_reverse(
370380
array_map(
371-
fn (TypeNode $genericType) => $this->createType($genericType, $context),
381+
function (TypeNode $genericType) use ($context): Type {
382+
return $this->createType($genericType, $context);
383+
},
372384
$type->genericTypes
373385
)
374386
)
@@ -378,21 +390,18 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ
378390

379391
private function createFromCallable(CallableTypeNode $type, Context $context): Callable_
380392
{
381-
return new Callable_(
382-
array_map(
383-
function (CallableTypeParameterNode $param) use ($context) {
384-
return new CallableParameter(
385-
$this->createType($param->type, $context),
386-
$param->parameterName !== '' ? trim($param->parameterName, '$') : null,
387-
$param->isReference,
388-
$param->isVariadic,
389-
$param->isOptional
390-
);
391-
},
392-
$type->parameters
393-
),
394-
$this->createType($type->returnType, $context),
395-
);
393+
return new Callable_(array_map(
394+
function (CallableTypeParameterNode $param) use ($context): CallableParameter {
395+
return new CallableParameter(
396+
$this->createType($param->type, $context),
397+
$param->parameterName !== '' ? trim($param->parameterName, '$') : null,
398+
$param->isReference,
399+
$param->isVariadic,
400+
$param->isOptional
401+
);
402+
},
403+
$type->parameters
404+
), $this->createType($type->returnType, $context));
396405
}
397406

398407
private function createFromConst(ConstTypeNode $type, Context $context): Type
@@ -542,7 +551,9 @@ private function createArray(array $typeNodes, Context $context): Array_
542551
{
543552
$types = array_reverse(
544553
array_map(
545-
fn (TypeNode $node) => $this->createType($node, $context),
554+
function (TypeNode $node) use ($context): Type {
555+
return $this->createType($node, $context);
556+
},
546557
$typeNodes
547558
)
548559
);
@@ -596,7 +607,7 @@ private function tryParseRemainingCompoundTypes(TokenIterator $tokenIterator, Co
596607
'phpdocumentor/type-resolver',
597608
'https://github.com/phpDocumentor/TypeResolver/issues/184',
598609
'Legacy nullable type detected, please update your code as
599-
you are using nullable types in a docblock. support will be removed in v2.0.0',
610+
you are using nullable types in a docblock. support will be removed in v2.0.0'
600611
);
601612
}
602613

src/Types/AggregatedType.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ abstract class AggregatedType implements Type, IteratorAggregate
3434
* @psalm-allow-private-mutation
3535
* @var array<int, Type>
3636
*/
37-
private array $types = [];
37+
private $types = [];
3838

39-
private string $token;
39+
/** @var string */
40+
private $token;
4041

4142
/**
4243
* @param array<Type> $types

src/Types/CallableParameter.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@
2121
*/
2222
final class CallableParameter
2323
{
24-
private Type $type;
24+
/** @var Type */
25+
private $type;
2526

26-
private bool $isReference;
27+
/** @var bool */
28+
private $isReference;
2729

28-
private bool $isVariadic;
30+
/** @var bool */
31+
private $isVariadic;
2932

30-
private bool $isOptional;
33+
/** @var bool */
34+
private $isOptional;
3135

32-
private ?string $name;
36+
/** @var string|null */
37+
private $name;
3338

3439
public function __construct(
3540
Type $type,

src/Types/Callable_.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
*/
2323
final class Callable_ implements Type
2424
{
25-
private ?Type $returnType;
25+
/** @var Type|null */
26+
private $returnType;
2627
/** @var CallableParameter[] */
27-
private array $parameters;
28+
private $parameters;
2829

2930
/**
3031
* @param CallableParameter[] $parameters

src/Types/ClassString.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
*/
2525
final class ClassString extends String_ implements PseudoType
2626
{
27-
private ?Fqsen $fqsen;
27+
/** @var Fqsen|null */
28+
private $fqsen;
2829

2930
/**
3031
* Initializes this representation of a class string with the given Fqsen.

src/Types/Collection.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
*/
3232
final class Collection extends AbstractList
3333
{
34-
private ?Fqsen $fqsen;
34+
/** @var Fqsen|null */
35+
private $fqsen;
3536

3637
/**
3738
* Initializes this representation of an array with the given Type or Fqsen.

src/Types/Context.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
final class Context
3737
{
3838
/** @var string The current namespace. */
39-
private string $namespace;
39+
private $namespace;
4040

4141
/**
4242
* @var string[] List of namespace aliases => Fully Qualified Namespace.
4343
* @psalm-var array<string, string>
4444
*/
45-
private array $namespaceAliases;
45+
private $namespaceAliases;
4646

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

src/Types/Expression.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
*/
2323
final class Expression implements Type
2424
{
25-
protected Type $valueType;
25+
/** @var Type */
26+
protected $valueType;
2627

2728
/**
2829
* Initializes this representation of an array with the given Type.

src/Types/InterfaceString.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
*/
2424
final class InterfaceString implements Type
2525
{
26-
private ?Fqsen $fqsen;
26+
/** @var Fqsen|null */
27+
private $fqsen;
2728

2829
/**
2930
* Initializes this representation of a class string with the given Fqsen.

src/Types/Nullable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
final class Nullable implements Type
2424
{
2525
/** @var Type The actual type that is wrapped */
26-
private Type $realType;
26+
private $realType;
2727

2828
/**
2929
* Initialises this nullable type using the real type embedded

0 commit comments

Comments
 (0)