Considering the following PHP class:
class someObject {
public function broken(){
return isset($this->something()) ? 'worked' : 'didnt';
}
public function something(){
return true;
}
public function notBroken(){
print('worked');
}
}
Let's say I now do:
$obj= new someObject();
$obj->broken();
Considering you can't pass a function call to isset(), (it's by-reference), I expect this to fail with a fatal error: PHP Fatal error: Can't use method return value in write context
This is fine, and expected.
However, let's say I now do:
$obj= new someObject();
$obj->notBroken();
Considering I'm not hitting the broken()
anywhere in this execution, and the error in broken()
is a Fatal Error (and not a Parse error), I wouldn't expect the normal output of "worked". FALSE! It still generates the Fatal Error.
Question:
Aside from just not writing code that has errors, are there any other errors that are not Parse Errors but still trigger a runtime error? I only know about: PHP Fatal error: Can't use method return value in write context
. Is there any way to detect these errors?
Is there a special name for this type of error?