Skip to content
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

Last PHP 8.1 chores #2560

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<exclude-pattern>tests/Proxies*</exclude-pattern>
<exclude-pattern>tests/Hydrators*</exclude-pattern>
<exclude-pattern>tests/PersistentCollections*</exclude-pattern>
<!-- Figure out what to do with "Scope keyword "static" must be followed by a single space; found newline" -->
<exclude-pattern>tests/Doctrine/ODM/MongoDB/Tests/PersistentCollection/CollWithPHP80Types.php</exclude-pattern>
<!-- Figure out what to do with PHP 8.1 errors in coding standard -->
<exclude-pattern>tests/Doctrine/ODM/MongoDB/Tests/PersistentCollection/CollWithPHP81Types.php</exclude-pattern>

<rule ref="Doctrine">
<!-- Traversable type hints often end up as mixed[], so we skip them for now -->
Expand Down
6 changes: 0 additions & 6 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
</errorLevel>
</UndefinedConstant>

<UndefinedAttributeClass>
<errorLevel type="suppress">
<!-- Remove it when using PHP 8.1 for running Psalm -->
<referencedClass name="ReturnTypeWillChange" />
</errorLevel>
</UndefinedAttributeClass>
<InvalidReturnType>
<errorLevel type="suppress">
<!-- Remove it when dropping support for doctrine/collections v1 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
*/
class CollWithPHP80Types extends ArrayCollection
{
public function mixed(mixed $param) : mixed
public function mixed(mixed $param): mixed
{
return $param;
}

/**
* @param Collection<TKey, TElement>|ArrayCollection<TKey, TElement> $param
*
* @return Collection<TKey, TElement>|ArrayCollection<TKey, TElement>
*/
public function union(Collection|ArrayCollection $param) : Collection|ArrayCollection
public function union(Collection|ArrayCollection $param): Collection|ArrayCollection
{
return $param;
}

public function static() : static
public function static(): static
{
return $this;
}

public function nullableStatic() : ?static
public function nullableStatic(): ?static
{
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
*/
class CollWithPHP81Types extends ArrayCollection
{
/**
* @param Collection<TKey, TElement>&ArrayCollection<TKey, TElement> $param
Copy link
Member Author

@malarzm malarzm Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPCS somehow was producing [..]TElement> &ArrayCol[..] (note the space) and I have no willpower to dig into why. Everyone's happy with no PHPDoc ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe prefixing with @psalm- like @psalm-param and @psalm-return would make PHPCS do not fail, anyway I don't know why static analysis is not complaining 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be because they got better over time and now they can infer same thing from class' @template-extends and return types? :)

* @return Collection<TKey, TElement>&ArrayCollection<TKey, TElement>
*/
public function intersection(Collection&ArrayCollection $param) : Collection&ArrayCollection
public function intersection(Collection&ArrayCollection $param): Collection&ArrayCollection
{
return $param;
}

public function never() : never
public function never(): never
{
die('You shall not pass');
}
Expand Down