Skip to content

Fatal error: Cannot use result of built-in function in write context #12102

Closed
@mvorisek

Description

@mvorisek

Description

The following code:

repro: https://3v4l.org/E8CsC

<?php

class Cl {
    public static function createAnd(...$args)
    {
        var_dump($args);
    }
    
    public function bar()
    {
        static::createAnd(func_get_args()[0]);
    }
}

(new Cl())->bar('y');

Resulted in this output:

Fatal error: Cannot use result of built-in function in write context

But I expected this output instead:

array(1) {
  [0]=>
  string(1) "y"
}

the 3v4l repro shows the issue is present only in some cases, when the same code is in non-class AST, it works

(func_get_args()[0] should return the 1st argument, it is simplified repro from more complex usecase)

PHP Version

any

Operating System

any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions