zephir
zephir copied to clipboard
[RFC] Instanceof for non objects
Is it okey?
refs https://github.com/phalcon/zephir/pull/821
Error https://github.com/phalcon/zephir/blob/master/ext/kernel/object.c#L74 https://github.com/phalcon/zephir/blob/master/ext/kernel/object.c#L62
No error: https://github.com/phalcon/zephir/blob/master/ext/kernel/object.c#L84
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
PHP behavior is that you can call instanceof on anything except constants. So something like
var_dump("test" instanceof STDClass);
fails, but when using a variable, any type is ok.
I do not see why we shouldn't adopt that behavior.
So I think it's safe to remove that warning/error.
The more errors you get, the better you application can be
Instead of throwing error it could assume false
:
if typeof this->validation == "object" && (this->validation instanceof Validation) && this->validation->valid() {
}
if this->validation instanceof Validation && this->validation->valid() {}
Also https://github.com/phalcon/zephir/issues/277 would be helpful:
if !validation instanceof Validation {}