Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix lost type when assigning variable in method argument #4293

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

Draft
staabm wants to merge 3 commits into phpstan:2.1.x
base: 2.1.x
Choose a base branch
Loading
from staabm:bug12234
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added regression test
  • Loading branch information
staabm committed Sep 7, 2025
commit c235ff7ed9114eee30ec77fe0a8f62f575b9fbac
11 changes: 11 additions & 0 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3656,4 +3656,15 @@ public function testBug3396(): void
$this->analyse([__DIR__ . '/data/bug-3396.php'], []);
}

public function testBug12735(): void
{
$this->checkThisOnly = false;
$this->checkNullables = true;
$this->checkUnionTypes = true;
$this->checkExplicitMixed = true;
$this->checkImplicitMixed = true;

$this->analyse([__DIR__ . '/data/bug-12735.php'], []);
}

}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-12735.php
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Bug12735;

class HelloWorld
{
public function test(): void
{
$this->foo(
$now = new DateTimeImmutable(),
$now,
);

$this->foo($now, $now);
}

private function foo(DateTimeImmutable $a, DateTimeImmutable $b): void {}
}
Loading

AltStyle によって変換されたページ (->オリジナル) /