facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.19k stars 2.99k forks source link

stream_socket_get_name(bool, needs resource) returns NULL, should return false #6616

Open effeks opened 8 years ago

effeks commented 8 years ago

Hi,

Wondering about a diff between HHVM (3.9.1) and PHP (5.6)

Testscript:

<?php
$stream = fopen('/tmp/temp', 'r+');
var_dump(stream_socket_get_name($stream,true));
host:~# hhvm test.php 
[Mon Nov 30 11:32:37 2015] [hphp] [29397:7fcc32378480:0:000001] [] 
Fatal error: Unexpected object type File. in /root/test.php on line 3
host:~# php test.php 
bool(false)
fredemmott commented 8 years ago

Not a fatal error in recent versions:

<?php
error_reporting(E_ALL);
$stream = fopen('/tmp/temp', 'r+');
var_dump(stream_socket_get_name($stream,true));

error_reporting call doesn't change behavior, but makes PHP5 output more similar.

fred@hhvm-oss-bench:~/test$ php5 test.php
PHP Warning:  fopen(/tmp/temp): failed to open stream: No such file or directory in /home/fred/test/test.php on line 3
PHP Warning:  stream_socket_get_name() expects parameter 1 to be resource, boolean given in /home/fred/test/test.php on line 4
bool(false)
fred@hhvm-oss-bench:~/test$ hhvm test.php

Warning: No such file or directory in /home/fred/test/test.php on line 3

Warning: stream_socket_get_name() expects parameter 1 to be resource, boolean given in /home/fred/test/test.php on line 4
NULL

re-titling issue to indicate remaining problem