-
Notifications
You must be signed in to change notification settings - Fork 94
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
Update to PHPStan level 3; various fixes #281
base: master
Are you sure you want to change the base?
Conversation
@@ -30,7 +30,7 @@ class OutlineNode implements ScenarioInterface | |||
*/ | |||
private $steps; | |||
/** | |||
* @var ExampleTableNode|ExampleTableNode[] | |||
* @var array<array-key, ExampleTableNode> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the (original) constructor code, this property could never contain a singular value.
$this->assertCount(1, $scenarios = $feature->getScenarios()); | ||
$this->assertSame('Scenario#3', $scenarios[0]->getTitle()); | ||
$this->assertInstanceOf(OutlineNode::class, $scenarios[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assertInstanceOf()
statements are a convenient way to (phpunit-)test the code as well as to tell phpstan that the ScenarioInterface
object is in fact an OutlineNode
(otherwise it complains that e.g. the getExampleTable()
below, doesn't exist).
@@ -57,6 +58,9 @@ public function supports($resource) | |||
public function load($resource) | |||
{ | |||
$path = $this->findAbsolutePath($resource); | |||
if ($path === false) { | |||
throw new \LogicException("Unable to locate absolute path of supported resource: $resource"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope that what is happening here is clear - it should not be possible for this exception to be thrown unless something happens between calling supports()
and load()
.
In any case, feel free to come up with a better message.. I'm a bit unsure with the current one.
6969a49
to
bc9da46
Compare
@@ -50,7 +50,7 @@ protected function findRelativePath($path) | |||
* | |||
* @param string $path Relative path | |||
* | |||
* @return string | |||
* @return false|string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't see any better way to solve this - downstream users with PHPStan that extended this class will now get warnings, unless they fix it in a similar way to (for example), the DirectoryLoader
changes in this PR.
No description provided.