Open
Conversation
Fixed potential problem caused by confusing phpstan-baseline-analyze output files and other - like "composer.json"
Owner
I think we should improve the json file loading so a more useful error is reported in unexpected file content |
Author
|
@staabm sure! What about adding file name to the exceptions messages? We can wrap all this code in foreach ($json as $data) {
if (!is_array($data)) {
throw new \RuntimeException('Expecting array, got ' . gettype($data));
}
foreach ($data as $baselinePath => $resultArray) {
if (!is_string($baselinePath)) {
throw new \RuntimeException('Expecting string, got ' . gettype($baselinePath));
}
if (!is_array($resultArray)) {
throw new \RuntimeException('Expecting array, got ' . gettype($resultArray));
}
$decoded[$baselinePath] = $this->buildAnalyzerResult($resultArray);
}
} |
Owner
|
the reported exception should be able to tell the user with which file a problem occured |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi!
I've recently spend quite a long time trying to understand, why I'm getting error like this one below:
after executing
php ./vendor/bin/phpstan-baseline-graph '*.json' > result.htmlin my project.The reason was really simple:
*.jsonwas catching all json files - including e. g.composer.json.