Skip to content

Closure created from magic method does not accept named arguments #11348

Closed

Description

@danog

Description

The following code:

<?php

class a {
	public function __call($name, $args) { var_dump($args); }
}
$a = new a;
$a->test(a: 123);
$a->test(...)(a: 123);

Resulted in this output:

array(1) {
  ["a"]=>
  int(123)
}
PHP Fatal error:  Uncaught Error: Unknown named parameter $a in /home/daniil/repos/MadelineProto/a.php:8
Stack trace:
#0 {main}
  thrown in /home/daniil/repos/MadelineProto/a.php on line 8

But I expected this output instead:

array(1) {
  ["a"]=>
  int(123)
}
array(1) {
  ["a"]=>
  int(123)
}

PHP Version

8.2.6

Operating System

Arch linux

Activity

  1. ndossche commented on Jun 3, 2023

    @ndossche
    Member

    It's indeed a weird missing feature. Even more weird that it actually works as long as you only use positional arguments and no named arguments. I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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