Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Incompatible behavior of func_get_args() in a closure #60

Open
weirdan opened this issue Dec 30, 2015 · 0 comments
Open

Incompatible behavior of func_get_args() in a closure #60

weirdan opened this issue Dec 30, 2015 · 0 comments
Assignees
Labels

Comments

@weirdan
Copy link
Contributor

weirdan commented Dec 30, 2015

In Phalanger (1d64ede) func_get_args() returns use()'d variables in addition to real arguments, while php and hhvm only return closure's arguments:

$ cat qq.php
<?php
class QQ
{
    public static function main()
    {
        $q = 123;
        $f = function($param) use($q) {
            var_dump(func_get_args());
        };
        $f("asd");
    }
}

$ Deployment/Debug/phpc.exe qq.php /reference:/usr/lib/mono/gac/PhpNetCore/4.0.0.0__0a8e8c4c76728c71/PhpNetCore.dll /reference:/usr/lib/mono/gac/PhpNetClassLibrary/4.0.0.0__4af37afe3cde05fb/PhpNetClassLibrary.dll /out:qq.exe /target:exe /encoding:UTF-8 /pure+ /entrypoint:qq.php /debug+
Phalanger - the PHP Language Compiler - version 4.0
for Microsoft (R) .NET Framework version 4.0
Arguments:
qq.php
/reference:/usr/lib/mono/gac/PhpNetCore/4.0.0.0__0a8e8c4c76728c71/PhpNetCore.dll
/reference:/usr/lib/mono/gac/PhpNetClassLibrary/4.0.0.0__4af37afe3cde05fb/PhpNetClassLibrary.dll
/out:qq.exe
/target:exe
/encoding:UTF-8
/pure+
/entrypoint:qq.php
/debug+

Encoding  cannot be loaded.
fileEncoding=""

Loaded libraries:
PhpNetCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71
Base Library (PhpNetClassLibrary)

Performing compilation ...

Statistics:
Compiled in 0:00.280.
AST: LibraryFunctionCalls = 2, UnknownFunctionCalls = 0


Build complete -- 0 errors, 0 warnings.

$ ./qq.exe
Encoding  cannot be loaded.
fileEncoding=""

array(2) {
  [0]=>
  int(123)
  [1]=>
  string(3) "asd"
}

$ php -r 'echo phpversion() . PHP_EOL; require "qq.php"; QQ::main();'
5.6.16-2
array(1) {
  [0] =>
  string(3) "asd"
}

See https://3v4l.org/GoUiU for more environments (various php & hhvm versions).

@jakubmisek jakubmisek self-assigned this Jul 9, 2017
@jakubmisek jakubmisek added the bug label Jul 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants