-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #605 from stof/better_analysis
Improve types for places dealing with class or interface names
- Loading branch information
Showing
7 changed files
with
55 additions
and
62 deletions.
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
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
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
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
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 |
---|---|---|
|
@@ -20,13 +20,15 @@ | |
* Lazy double. | ||
* Gives simple interface to describe double before creating it. | ||
* | ||
* @template T of object | ||
* | ||
* @author Konstantin Kudryashov <[email protected]> | ||
*/ | ||
class LazyDouble | ||
{ | ||
private $doubler; | ||
/** | ||
* @var ReflectionClass<object>|null | ||
* @var ReflectionClass<T>|null | ||
*/ | ||
private $class; | ||
/** | ||
|
@@ -38,7 +40,7 @@ class LazyDouble | |
*/ | ||
private $arguments = null; | ||
/** | ||
* @var DoubleInterface|null | ||
* @var (T&DoubleInterface)|null | ||
*/ | ||
private $double; | ||
|
||
|
@@ -50,12 +52,16 @@ public function __construct(Doubler $doubler) | |
/** | ||
* Tells doubler to use specific class as parent one for double. | ||
* | ||
* @param string|ReflectionClass<object> $class | ||
* @param class-string|ReflectionClass<object> $class | ||
* | ||
* @return void | ||
* | ||
* @throws \Prophecy\Exception\Doubler\ClassNotFoundException | ||
* @throws \Prophecy\Exception\Doubler\DoubleException | ||
* @template U of object | ||
* @phpstan-param class-string<U>|ReflectionClass<U> $class | ||
* @phpstan-this-out static<U> | ||
* | ||
* @throws ClassNotFoundException | ||
* @throws DoubleException | ||
*/ | ||
public function setParentClass($class) | ||
{ | ||
|
@@ -71,18 +77,24 @@ public function setParentClass($class) | |
$class = new ReflectionClass($class); | ||
} | ||
|
||
/** @var static<U> $this */ | ||
|
||
$this->class = $class; | ||
} | ||
|
||
/** | ||
* Tells doubler to implement specific interface with double. | ||
* | ||
* @param string|ReflectionClass<object> $interface | ||
* @param class-string|ReflectionClass<object> $interface | ||
* | ||
* @return void | ||
* | ||
* @throws \Prophecy\Exception\Doubler\InterfaceNotFoundException | ||
* @throws \Prophecy\Exception\Doubler\DoubleException | ||
* @template U of object | ||
* @phpstan-param class-string<U>|ReflectionClass<U> $interface | ||
* @phpstan-this-out static<T&U> | ||
* | ||
* @throws InterfaceNotFoundException | ||
* @throws DoubleException | ||
*/ | ||
public function addInterface($interface) | ||
{ | ||
|
@@ -121,7 +133,7 @@ public function setArguments(array $arguments = null) | |
/** | ||
* Creates double instance or returns already created one. | ||
* | ||
* @return DoubleInterface | ||
* @return T&DoubleInterface | ||
*/ | ||
public function getInstance() | ||
{ | ||
|
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
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