I have the following code.
public function childSignalHandler($signal_nr, $pid = null, $status = null) {
// Check if child is really finished.
$status = null;
$pid = pcntl_waitpid($pid, $status, WNOHANG);
if ($pid > 0) {
// Handle finished job.
$this->handleFineshedChild($pid);
// Start new job.
$this->startChild();
}
}
The inspection warns me at:
$status = null; $pid = pcntl_waitpid($pid, $status, WNOHANG);
That $status "The parameter is overridden immediately (original value is lost).".
In most cases this is correct but I need to provide the second argument $status in pcntl_waitpid.
I have to set it, but I do not need to check it. So in that case if a parameter is required by a function/method which is passed by reference, the inspection should not give an error. Or maybe make this as an option within the inspection settings. "Allow passed by reference variables"
Or do I miss something?
$status parameter should be a reference. Actually you are really overriding the argumented value.
@prdatur inspection works correctly in this case.
You have several options:
$status then you do not need third parameter $status..... Sorry.. I miss undetstod the error. I didn't saw the parameter of my childSignalHandler method that it is the same name.
Btw. Thank's for the great work. It really helps to get clean code. First I just searched for a better exception inspection, then I rewrote everything :)
I will close this issue. Works as expected.
Most helpful comment
@prdatur inspection works correctly in this case.
You have several options:
$statusthen you do not need third parameter$status.