Skip to content

call_user_func special function optimization unsound with strict_types #18591

Open
@nielsdos

Description

@nielsdos

Description

The following code:

<?php
declare(strict_types=1);

namespace Foo;

// strlen() will be called with strict_types=0, so this is legal.
var_dump(call_user_func('strlen', false));

// Called with strict_types=1
var_dump(\call_user_func('strlen', false));

Resulted in this output:

int(0)

Fatal error: Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string, false given in /in/bcCZ4:10
Stack trace:
#0 /in/bcCZ4(10): strlen(false)
#1 {main}
  thrown in /in/bcCZ4 on line 10

But I expected this output instead:

Well, not sure, it should be consistent I suppose

PHP Version

8.3+

Operating System

No response

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