-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop support for PHP 7.4 #2515
Drop support for PHP 7.4 #2515
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in phpstan-baseline.neon are worrying me
/** @var string|null */ | ||
public $name; | ||
|
||
/** @param string|string[] $value */ | ||
public function __construct($value, ?string $name = null) | ||
public function __construct(public $value, ?string $name = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why $name
wasn't promoted as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume because the property did not have a type associated with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the class is final, I guess we could add types to these properties? A user might have set these properties to another type, but I guess it wouldn't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the type is wrong: $name
can be a string or list of strings, and the AnnotationDriver always converts it to an array. I've removed the parameter type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correction: $value
is what I was talking about, $name
is indeed a string. I've re-added the correct type.
?string $repositoryClass = null, | ||
array $indexes = [], | ||
bool $readOnly = false, | ||
?string $shardKey = null, | ||
$writeConcern = null | ||
public $writeConcern = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a bug in PHPCSFixer? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, a result of phpcs requiring a trailing comma for multi-line method declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poor communication is on me, this was meant to follow previous comment on promoting only some properties instead of all 👼
@@ -234,7 +233,7 @@ public function prepareUpdateData($document) | |||
*/ | |||
public function prepareUpsertData($document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: we should revisit adding object
typehint. For instance here the builder is marked as @internal
so we're free to break inheritance here according to our rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely. I'd do so in a separate pull request.
They look a lot less dramatic once we ignore whitespace changes. Here's the output I had before regenerating the baseline:
|
7554ff5
to
e7752c6
Compare
/** | ||
* @param array<string, mixed> $pipeline | ||
* @param array<string, mixed> $options | ||
* @psalm-param PipelineExpression $pipeline | ||
*/ | ||
public function __construct(DocumentManager $dm, ?ClassMetadata $classMetadata, Collection $collection, array $pipeline, array $options = [], bool $rewindable = true) | ||
public function __construct(private DocumentManager $dm, private ?ClassMetadata $classMetadata, private Collection $collection, array $pipeline, private array $options = [], private bool $rewindable = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened slevomat/coding-standard#1537
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been merged and released, so updating slevomat/coding-standard
and running phpcbf
should fix this and other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
private bool $disableException = false; | ||
|
||
/** @param mixed $identifier */ | ||
public function __construct(object $document, DocumentManager $dm, $identifier) | ||
public function __construct(object $document, DocumentManager $dm, private $identifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for another PR, we can add mixed
types
/** @var string|null */ | ||
public $name; | ||
|
||
/** @param string|string[] $value */ | ||
public function __construct($value, ?string $name = null) | ||
public function __construct(public $value, ?string $name = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the class is final, I guess we could add types to these properties? A user might have set these properties to another type, but I guess it wouldn't work
tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to take a look at phpstan if I find some time
* Drop support for PHP 7.4, require PHP 8.0 * Enforce PHP 8 syntax in phpcs * Fix static analysis errors * Move psalm configuration to .dist file * Set psalm phpVersion through config file * Run PHPStan on PHP 8.2 * Remove superfluous assertion
Summary
This PR drops support for PHP 7.4. This is mainly required due to the aggregation pipeline builder needing to enforce
static
types which cannot be worked around (see #2514).Contained in this PR is a commit that also enforces PHP 8.0 syntax in phpcs. All changes were made using phpcbf and should be safe, but I can drop the commit if we want to defer this to a later PR.