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
[Parallel] Fix system errors expected an instance of SystemError but got string #1610
Conversation
The fix should happen in the other direction. Where the error message is string, should be object. |
@TomasVotruba I tried to convert it to an object, but the required argument The location of the code where the error message is string:
rector-src/packages/Parallel/Application/ParallelFileProcessor.php Lines 224 to 227 in 34c61ba
|
It could be either optional or with with The reason is we should work with strict objects, moreover when we juggle around json data in paralle processes. Only that way we can control what data types are on I/O. When we start to send strings, it could be anything, from error message, to file content, and we'll be unable to resolve what we work with. Jsonable value objects makes sure we know the types all the time. |
…ror but got string" This reverts commit 0a43a7a.
I see. I'll try the optional first and see what happens. |
This is what an error message looks like with
|
How should we rephrase it? |
@@ -166,7 +166,7 @@ function (array $json) use ( | |||
// decode arrays to objects | |||
foreach ($json[Bridge::SYSTEM_ERRORS] as $jsonError) { | |||
if (is_string($jsonError)) { | |||
$systemErrors[] = 'System error: ' . $jsonError; | |||
$systemErrors[] = new SystemError('System error: ' . $jsonError); |
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.
Could you type this array, so phpstan would error when strings are pushed onto the array?
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.
Add a type to this array, but phpstan does not error when a string is pushed into the array. 🤔
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.
It's not supported yet. phpstan/phpstan#3269, phpstan/phpstan#3703
How about
|
@zingimmick Sounds good 👍 |
Thank you 👍 I'm merging this now, so we can fix important bug that blocks us at the moment. Feel free to send PR with better wording. |
Fixes: rectorphp/rector#6901