Skip to content

Fix non-working type assertions in NodeScopeResolverTest cases #1992

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

Merged
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
9 changes: 5 additions & 4 deletions tests/PHPStan/Analyser/data/DateTimeModifyReturnTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

use DateTime;
use DateTimeImmutable;
use function PHPStan\Testing\assertType;

class Foo
{
public function modify(DateTime $datetime, DateTimeImmutable $dateTimeImmutable, string $modify): void {
assertType('DateTime|false', $datetime->modify($modify));
assertType('DateTimeImmutable|false', $dateTimeImmutable->modify($modify));
assertType('(DateTime|false)', $datetime->modify($modify));
assertType('(DateTimeImmutable|false)', $dateTimeImmutable->modify($modify));
}

/**
Expand All @@ -32,8 +33,8 @@ public function modifyWithInvalidConstant(DateTime $datetime, DateTimeImmutable
* @param '+1 day'|'koko' $modify
*/
public function modifyWithBothConstant(DateTime $datetime, DateTimeImmutable $dateTimeImmutable, string $modify): void {
assertType('DateTime|false', $datetime->modify($modify));
assertType('DateTimeImmutable|false', $dateTimeImmutable->modify($modify));
assertType('(DateTime|false)', $datetime->modify($modify));
assertType('(DateTimeImmutable|false)', $dateTimeImmutable->modify($modify));
}

}
2 changes: 2 additions & 0 deletions tests/PHPStan/Analyser/data/bug-7031.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Bug7031;

use function PHPStan\Testing\assertType;

class SomeKey {}

function () {
Expand Down