Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: call global functions using a fully qualified name #139

Merged
merged 1 commit into from
Mar 22, 2021

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 22, 2021

Context

  • Code quality

Summary

This PR can be summarized in the following changelog entry:

  • Code quality

Relevant technical choices:

  • No functional changes.
  • Code style compliance.

When PHP encounters an unqualified function call in a namespaced file, it will first try and find the function within the namespace and only when it can not find it in the namespace, fall-back to the global function.

Using fully qualified function names when calling a global function ensures that PHP will bypass the search within the namespace and call the global function directly.

It also ensures that optimal use is made of the PHP7 opcodes on VM level which have been implemented for a select group of PHP internal functions resulting in faster code execution.

Ref: https://www.php.net/manual/en/language.namespaces.fallback.php

Test instructions

This PR can be tested by following these steps:

  • N/A
    This is a code-only change and should have no effect on the functionality. If the build passes (linting, test runs), we're good.

When PHP encounters an unqualified function call in a namespaced file, it will first try and find the function within the namespace and only when it can not find it in the namespace, fall-back to the global function.

Using fully qualified function names when calling a global function ensures that PHP will bypass the search within the namespace and call the global function directly.

It also ensures that optimal use is made of the PHP7 opcodes on VM level which have been implemented for a select group of PHP internal functions resulting in faster code execution.

Ref: https://www.php.net/manual/en/language.namespaces.fallback.php
@jrfnl jrfnl added this to the 4.2 milestone Mar 22, 2021
@jrfnl jrfnl merged commit a001361 into develop Mar 22, 2021
@jrfnl jrfnl deleted the JRF/QA/use-fqn-function-calls-in-namespaced-files branch March 22, 2021 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant