-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Description
Description
The following code:
<?php
class pass_filter
{
public $filtername;
public $params;
public int $stream = 1;
function filter($in, $out, &$consumed, $closing): int
{
while ($bucket=stream_bucket_make_writeable($in)) {
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
var_dump($this->stream); // resource instead of int -> type system violation
return PSFS_PASS_ON;
}
}
stream_filter_register("pass", "pass_filter");
$fp=fopen("php://memory", "w");
stream_filter_append($fp, "pass");
fwrite($fp, "Thank you\n");
rewind($fp);
echo fread($fp, 1024);Resulted in this output:
resource(5) of type (stream)
resource(5) of type (stream)
resource(5) of type (stream)
resource(5) of type (stream)
Thank you
resource(5) of type (Unknown)
But I expected this output instead:
An exception, because the property shouldn't have been set in the first place. The type system should prevent this.
I discovered this because I wanted to get rid of the OBJPROP accessor, which would avoid building the properties table. It's a bit annoying to fix this as you'd need to conditionally use zend_update_property
PHP Version
8.3+
Operating System
No response