Skip to content

Change the way built-in functions are resolved #13632

Closed
@javiereguiluz

Description

@javiereguiluz

Description

When some PHP app uses a function like file_exists(), the PHP compiler doesn't know if it's the PHP built-in function or a user-defined function added by that project.


This has some impact with changes like this: #12461

To unlock the potential performance improvements of that PR, you have two options:

(1) Prefix all calls to PHP built-in functions with \
(2) Import all PHP built-in functions with use function ...

Both solutions look cumbersome to me.


In other words:

  • All PHP projects in the World are a bit slower than they could be...
  • ... because maybe, some project, could include a user-defined function called substr() or file_exists() and PHP needs to take that into account

Could PHP fix this in some way? Here are some proposals:

(1) We could make this behavior opt-in instead of opt-out. If a project includes user-defined functions that match built-in function names, make them add a declares(overrides_php_functions=1); statement

(2) In order to change the default behavior in a backward-compatible way, we could add a transitory php.ini directive such as overrides_php_functions set to true by default (to match current PHP behavior) and then apps can change it to false so the performance improvement can be unlocked without changing their codebase

Thanks

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions