-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21ca601
commit c98cf80
Showing
2 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
tests/PHPStan/Rules/Methods/data/check-implicit-mixed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php // lint >= 8.0 | ||
|
||
namespace CheckImplicitMixedMethodCall; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param mixed $explicit | ||
*/ | ||
public function doFoo( | ||
$implicit, | ||
$explicit | ||
): void | ||
{ | ||
$implicit->foo(); | ||
$explicit->foo(); | ||
} | ||
|
||
/** | ||
* @template T | ||
* @param T $t | ||
*/ | ||
public function doBar($t): void | ||
{ | ||
$t->foo(); | ||
} | ||
|
||
} | ||
|
||
class Bar | ||
{ | ||
|
||
/** | ||
* @param mixed $explicit | ||
*/ | ||
public function doFoo( | ||
$implicit, | ||
$explicit | ||
): void | ||
{ | ||
$this->doBar($implicit); | ||
$this->doBar($explicit); | ||
|
||
$this->doBaz($implicit); | ||
$this->doBaz($explicit); | ||
} | ||
|
||
public function doBar(int $i): void | ||
{ | ||
|
||
} | ||
|
||
public function doBaz($mixed): void | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @template T | ||
* @param T $t | ||
*/ | ||
public function doLorem($t): void | ||
{ | ||
$this->doBar($t); | ||
$this->doBaz($t); | ||
} | ||
|
||
} | ||
|
||
class TemplateMixed | ||
{ | ||
|
||
/** | ||
* @template T | ||
* @param T $t | ||
*/ | ||
public function doFoo($t): void | ||
{ | ||
$this->doBar($t); | ||
} | ||
|
||
public function doBar($mixed): void | ||
{ | ||
$this->doFoo($mixed); | ||
} | ||
|
||
} | ||
|
||
class CallableMixed | ||
{ | ||
|
||
/** | ||
* @param callable(int): void $cb | ||
*/ | ||
public function doBar(callable $cb): void | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @param callable() $cb | ||
*/ | ||
public function doFoo2(callable $cb): void | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @param callable(): int $cb | ||
*/ | ||
public function doBar2(callable $cb): void | ||
{ | ||
|
||
} | ||
|
||
public function doLorem(int $i, $m): void | ||
{ | ||
$acceptsInt = function (int $i): void { | ||
|
||
}; | ||
$this->doBar($acceptsInt); | ||
|
||
$acceptsMixed = function ($m): void { | ||
|
||
}; | ||
$this->doBar($acceptsMixed); | ||
|
||
$returnsInt = function () use ($i): int { | ||
return $i; | ||
}; | ||
$this->doFoo2($returnsInt); | ||
$this->doBar2($returnsInt); | ||
|
||
$returnsMixed = function () use ($m) { | ||
return $m; | ||
}; | ||
$this->doFoo2($returnsMixed); | ||
$this->doBar2($returnsMixed); | ||
} | ||
|
||
} |