-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #252 Add separate checks for all polyfilled functions and const…
…ants (JanJakes) This PR was merged into the 1.16-dev branch. Discussion ---------- Add separate checks for all polyfilled functions and constants As originally discussed in symfony/polyfill-mbstring#6 and later in #251 in some scenarios it may be better to check for each constant/function before defining it. Such scenarios are typically those where some project or a library defines its polyfills for some parts of extension functionality but not all of it. Probably the most popular example is WordPress, defining some polyfills in `wp-includes/compat.php` but not including complete functionalities (i.e. it defines only a few `mb_` functions). Plugin developers then may need other `mb_` functions and need to load those that WordPress didn't. There may be some performance concerns but it seems that checks such as `function_exists` are [very fast](symfony/polyfill-mbstring#6 (comment)) - in fact, [PHP tries to evaluate both `function_exists` and `defined` at compile time](https://github.com/php/php-src/blob/e141592da6cdb15709e4aeaab5421c9a46564849/ext/opcache/Optimizer/pass1_5.c#L349) (see also [StackOverflow](https://stackoverflow.com/questions/21619939/does-function-exists-cache-its-queries/21620062#21620062)). This means on installs that do have the polyfilled extensions installed, there should be zero overhead (the conditions will evaluate to `true` at compile time). Note that many of the currently existing polyfills already perform checks for each function separately (most of the PHP-version polyfills). Closes #251. Commits ------- a00cffe Add separate checks for all polyfilled functions and constants
- Loading branch information
Showing
12 changed files
with
331 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.