nikic/scalar_objects — pull request #11 by thekid (2014-04-27 15:01:54+00:00)
Title: Fix segmentation fault when invoking __callStatic()

This pull request fixes a segmentation fault when invocations fall back to `__callStatic`:

```php
class h {
static function __callStatic($name, $args) { }
}

register_primitive_type_handler('null', 'h');
$x= null;
return $x->method();
```

The hack that `$this` is available in the primitive handler methods and points to the value the method is called on although they're actually static methods doesn't work here. See the comment in `zend_vm_def.h` in its `ZEND_VM_HELPER(zend_do_fcall_common_helper...)`: *An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call*. Why the Zend Engine treats `__callStatic` as an *internal* function is not 100% clear to me; an educated guess is that it's for performance reasons.