Skip to content

Commit 5ccddc6

Browse files
committed
Bump PHP to 7.2
This allows us to simplify some dependencies constraints, and to add parameter type declarations.
1 parent 6d49292 commit 5ccddc6

11 files changed

+57
-84
lines changed

.github/workflows/continuous-integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
name: "PHPUnit"
1717
uses: "doctrine/.github/.github/workflows/[email protected]"
1818
with:
19-
php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]'
19+
php-versions: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]'

UPGRADE.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
implement `ArrayAccess` as a way for you to still be able to treat them as
66
arrays in some ways.
77
- `CachedReader` and `FileCacheReader` have been removed.
8-
- `AnnotationRegistry` method related to registering annotations instead of
8+
- `AnnotationRegistry` methods related to registering annotations instead of
99
using autoloading have been removed.
10+
- Parameter type declarations have been added to all methods of all classes. If
11+
you have classes inheriting from classes inside this package, you should add
12+
parameter and return type declarations.
13+
- Support for PHP < 7.2 has been removed

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
],
3333
"homepage": "https://www.doctrine-project.org/projects/annotations.html",
3434
"require": {
35-
"php": "^7.1 || ^8.0",
35+
"php": "^7.2 || ^8.0",
3636
"ext-tokenizer": "*",
3737
"doctrine/lexer": "^2",
3838
"psr/cache": "^1 || ^2 || ^3"
3939
},
4040
"require-dev": {
41-
"doctrine/cache": "^1.11 || ^2.0",
42-
"doctrine/coding-standard": "^9 || ^10",
43-
"phpstan/phpstan": "~1.4.10 || ^1.8.0",
41+
"doctrine/cache": "^2.0",
42+
"doctrine/coding-standard": "^10",
43+
"phpstan/phpstan": "^1.8.0",
4444
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
45-
"symfony/cache": "^4.4 || ^5.4 || ^6",
45+
"symfony/cache": "^5.4 || ^6",
4646
"vimeo/psalm": "^4.10"
4747
},
4848
"suggest": {

lib/Doctrine/Common/Annotations/Annotation.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ final public function __construct(array $data)
2929
/**
3030
* Error handler for unknown property accessor in Annotation class.
3131
*
32-
* @param string $name Unknown property name.
33-
*
3432
* @throws BadMethodCallException
3533
*/
36-
public function __get($name)
34+
public function __get(string $name)
3735
{
3836
throw new BadMethodCallException(
3937
sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class)
@@ -43,12 +41,11 @@ public function __get($name)
4341
/**
4442
* Error handler for unknown property mutator in Annotation class.
4543
*
46-
* @param string $name Unknown property name.
47-
* @param mixed $value Property value.
44+
* @param mixed $value Property value.
4845
*
4946
* @throws BadMethodCallException
5047
*/
51-
public function __set($name, $value)
48+
public function __set(string $name, $value)
5249
{
5350
throw new BadMethodCallException(
5451
sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class)

lib/Doctrine/Common/Annotations/AnnotationException.php

+28-37
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,19 @@ class AnnotationException extends Exception
1919
/**
2020
* Creates a new AnnotationException describing a Syntax error.
2121
*
22-
* @param string $message Exception message
23-
*
2422
* @return AnnotationException
2523
*/
26-
public static function syntaxError($message)
24+
public static function syntaxError(string $message)
2725
{
2826
return new self('[Syntax Error] ' . $message);
2927
}
3028

3129
/**
3230
* Creates a new AnnotationException describing a Semantical error.
3331
*
34-
* @param string $message Exception message
35-
*
3632
* @return AnnotationException
3733
*/
38-
public static function semanticalError($message)
34+
public static function semanticalError(string $message)
3935
{
4036
return new self('[Semantical Error] ' . $message);
4137
}
@@ -44,36 +40,29 @@ public static function semanticalError($message)
4440
* Creates a new AnnotationException describing an error which occurred during
4541
* the creation of the annotation.
4642
*
47-
* @param string $message
48-
*
4943
* @return AnnotationException
5044
*/
51-
public static function creationError($message, ?Throwable $previous = null)
45+
public static function creationError(string $message, ?Throwable $previous = null)
5246
{
5347
return new self('[Creation Error] ' . $message, 0, $previous);
5448
}
5549

5650
/**
5751
* Creates a new AnnotationException describing a type error.
5852
*
59-
* @param string $message
60-
*
6153
* @return AnnotationException
6254
*/
63-
public static function typeError($message)
55+
public static function typeError(string $message)
6456
{
6557
return new self('[Type Error] ' . $message);
6658
}
6759

6860
/**
6961
* Creates a new AnnotationException describing a constant semantical error.
7062
*
71-
* @param string $identifier
72-
* @param string $context
73-
*
7463
* @return AnnotationException
7564
*/
76-
public static function semanticalErrorConstants($identifier, $context = null)
65+
public static function semanticalErrorConstants(string $identifier, ?string $context = null)
7766
{
7867
return self::semanticalError(sprintf(
7968
"Couldn't find constant %s%s.",
@@ -85,16 +74,17 @@ public static function semanticalErrorConstants($identifier, $context = null)
8574
/**
8675
* Creates a new AnnotationException describing an type error of an attribute.
8776
*
88-
* @param string $attributeName
89-
* @param string $annotationName
90-
* @param string $context
91-
* @param string $expected
92-
* @param mixed $actual
77+
* @param mixed $actual
9378
*
9479
* @return AnnotationException
9580
*/
96-
public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual)
97-
{
81+
public static function attributeTypeError(
82+
string $attributeName,
83+
string $annotationName,
84+
string $context,
85+
string $expected,
86+
$actual
87+
) {
9888
return self::typeError(sprintf(
9989
'Attribute "%s" of @%s declared on %s expects %s, but got %s.',
10090
$attributeName,
@@ -108,15 +98,14 @@ public static function attributeTypeError($attributeName, $annotationName, $cont
10898
/**
10999
* Creates a new AnnotationException describing an required error of an attribute.
110100
*
111-
* @param string $attributeName
112-
* @param string $annotationName
113-
* @param string $context
114-
* @param string $expected
115-
*
116101
* @return AnnotationException
117102
*/
118-
public static function requiredError($attributeName, $annotationName, $context, $expected)
119-
{
103+
public static function requiredError(
104+
string $attributeName,
105+
string $annotationName,
106+
string $context,
107+
string $expected
108+
) {
120109
return self::typeError(sprintf(
121110
'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.',
122111
$attributeName,
@@ -129,16 +118,18 @@ public static function requiredError($attributeName, $annotationName, $context,
129118
/**
130119
* Creates a new AnnotationException describing a invalid enummerator.
131120
*
132-
* @param string $attributeName
133-
* @param string $annotationName
134-
* @param string $context
135-
* @param mixed $given
136-
* @phpstan-param list<string> $available
121+
* @param mixed $given
122+
* @phpstan-param list<string> $available
137123
*
138124
* @return AnnotationException
139125
*/
140-
public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
141-
{
126+
public static function enumeratorError(
127+
string $attributeName,
128+
string $annotationName,
129+
string $context,
130+
array $available,
131+
$given
132+
) {
142133
return new self(sprintf(
143134
'[Enum Error] Attribute "%s" of @%s declared on %s accepts only [%s], but got %s.',
144135
$attributeName,

lib/Doctrine/Common/Annotations/AnnotationReader.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,16 @@ class AnnotationReader implements Reader
4848

4949
/**
5050
* Add a new annotation to the globally ignored annotation names with regard to exception handling.
51-
*
52-
* @param string $name
5351
*/
54-
public static function addGlobalIgnoredName($name)
52+
public static function addGlobalIgnoredName(string $name)
5553
{
5654
self::$globalIgnoredNames[$name] = true;
5755
}
5856

5957
/**
6058
* Add a new annotation to the globally ignored annotation namespaces with regard to exception handling.
61-
*
62-
* @param string $namespace
6359
*/
64-
public static function addGlobalIgnoredNamespace($namespace)
60+
public static function addGlobalIgnoredNamespace(string $namespace)
6561
{
6662
self::$globalIgnoredNamespaces[$namespace] = true;
6763
}

lib/Doctrine/Common/Annotations/DocParser.php

+7-18
Original file line numberDiff line numberDiff line change
@@ -286,33 +286,29 @@ public function setIgnoredAnnotationNames(array $names)
286286
*
287287
* @return void
288288
*/
289-
public function setIgnoredAnnotationNamespaces($ignoredAnnotationNamespaces)
289+
public function setIgnoredAnnotationNamespaces(array $ignoredAnnotationNamespaces)
290290
{
291291
$this->ignoredAnnotationNamespaces = $ignoredAnnotationNamespaces;
292292
}
293293

294294
/**
295295
* Sets ignore on not-imported annotations.
296296
*
297-
* @param bool $bool
298-
*
299297
* @return void
300298
*/
301-
public function setIgnoreNotImportedAnnotations($bool)
299+
public function setIgnoreNotImportedAnnotations(bool $bool)
302300
{
303-
$this->ignoreNotImportedAnnotations = (bool) $bool;
301+
$this->ignoreNotImportedAnnotations = $bool;
304302
}
305303

306304
/**
307305
* Sets the default namespaces.
308306
*
309-
* @param string $namespace
310-
*
311307
* @return void
312308
*
313309
* @throws RuntimeException
314310
*/
315-
public function addNamespace($namespace)
311+
public function addNamespace(string $namespace)
316312
{
317313
if ($this->imports) {
318314
throw new RuntimeException('You must either use addNamespace(), or setImports(), but not both.');
@@ -342,27 +338,22 @@ public function setImports(array $imports)
342338
/**
343339
* Sets current target context as bitmask.
344340
*
345-
* @param int $target
346-
*
347341
* @return void
348342
*/
349-
public function setTarget($target)
343+
public function setTarget(int $target)
350344
{
351345
$this->target = $target;
352346
}
353347

354348
/**
355349
* Parses the given docblock string for annotations.
356350
*
357-
* @param string $input The docblock string to parse.
358-
* @param string $context The parsing context.
359-
*
360351
* @phpstan-return list<object> Array of annotations. If no annotations are found, an empty array is returned.
361352
*
362353
* @throws AnnotationException
363354
* @throws ReflectionException
364355
*/
365-
public function parse($input, $context = '')
356+
public function parse(string $input, string $context = '')
366357
{
367358
$pos = $this->findInitialTokenPosition($input);
368359
if ($pos === null) {
@@ -379,10 +370,8 @@ public function parse($input, $context = '')
379370

380371
/**
381372
* Finds the first valid annotation
382-
*
383-
* @param string $input The docblock string to parse
384373
*/
385-
private function findInitialTokenPosition($input): ?int
374+
private function findInitialTokenPosition(string $input): ?int
386375
{
387376
$pos = 0;
388377

lib/Doctrine/Common/Annotations/IndexedReader.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN
8888
/**
8989
* Proxies all methods to the delegate.
9090
*
91-
* @param string $method
9291
* @param mixed[] $args
9392
*
9493
* @return mixed
9594
*/
96-
public function __call($method, $args)
95+
public function __call(string $method, array $args)
9796
{
9897
return call_user_func_array([$this->delegate, $method], $args);
9998
}

lib/Doctrine/Common/Annotations/PhpParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function parseUseStatements($reflection): array
7070
*
7171
* @return string|null The content of the file or null if the file does not exist.
7272
*/
73-
private function getFileContent($filename, $lineNumber)
73+
private function getFileContent(string $filename, $lineNumber)
7474
{
7575
if (! is_file($filename)) {
7676
return null;

lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ public function __construct()
3131
/**
3232
* Adds a namespace in which we will look for annotations.
3333
*
34-
* @param string $namespace
35-
*
3634
* @return void
3735
*/
38-
public function addNamespace($namespace)
36+
public function addNamespace(string $namespace)
3937
{
4038
$this->parser->addNamespace($namespace);
4139
}

lib/Doctrine/Common/Annotations/TokenParser.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class TokenParser
4646
*/
4747
private $pointer = 0;
4848

49-
/** @param string $contents */
50-
public function __construct($contents)
49+
public function __construct(string $contents)
5150
{
5251
$this->tokens = token_get_all($contents);
5352

@@ -71,7 +70,7 @@ public function __construct($contents)
7170
*
7271
* @return mixed[]|string|null The token if exists, null otherwise.
7372
*/
74-
public function next($docCommentIsComment = true)
73+
public function next(bool $docCommentIsComment = true)
7574
{
7675
for ($i = $this->pointer; $i < $this->numTokens; $i++) {
7776
$this->pointer++;
@@ -149,7 +148,7 @@ public function parseUseStatement()
149148
*
150149
* @return array<string, string> A list with all found use statements.
151150
*/
152-
public function parseUseStatements($namespaceName)
151+
public function parseUseStatements(string $namespaceName)
153152
{
154153
$statements = [];
155154
while (($token = $this->next())) {

0 commit comments

Comments
 (0)