Describe the bug
A line like:
assert(false, "This shouldn't happen');
appears to mark the rest of the function as unreachable. However asserts can be disabled (and should be in production environments) so the code in question is very reachable. The use case in question is a __get() magic method where it's useful to flag cases where an invalid field is referenced but you don't necessarily want to make that a fatal error in production.
To Reproduce
A code snippet (NOT a screenshot of a code snippet) or steps to reproduce the issue
class foo
{
private int $bar = 5;
public function __get($name)
{
if ($name == 'bar')
{
return $this->bar;
}
assert(false, 'invalid field passed');
return null; // this line is improperly displayed as unreachable.
}
}
Expected behavior
Should not flag the line as unreachable.
Platform and version
Windows 11, 1.18.5
Describe the bug
A line like:
assert(false, "This shouldn't happen');
appears to mark the rest of the function as unreachable. However asserts can be disabled (and should be in production environments) so the code in question is very reachable. The use case in question is a __get() magic method where it's useful to flag cases where an invalid field is referenced but you don't necessarily want to make that a fatal error in production.
To Reproduce
A code snippet (NOT a screenshot of a code snippet) or steps to reproduce the issue
class foo
{
private int $bar = 5;
public function __get($name)
{
if ($name == 'bar')
{
return $this->bar;
}
assert(false, 'invalid field passed');
}
}
Expected behavior
Should not flag the line as unreachable.
Platform and version
Windows 11, 1.18.5