Bug #80914 [NEW]: function_exists is now case-sensitive for aliases
From: chris at vendiadvertising dot com
Operating system: All
PHP version: 8.0.3
Package: *General Issues
Bug Type: Bug
Bug description:function_exists is now case-sensitive for aliases
Description:
------------
Prior to PHP 8, a function could use the same name as a built-in
function's alias as long as it changed the case. For example, the
built-in function dir has an internal alias of getdir, and user-land
code could create a function called getDir without issue. As of PHP 8,
doing so will raise a Fatal error: Cannot redeclare xyz.
https://3v4l.org/hdHSS
This was originally noted on SO
https://stackoverflow.com/q/66854655/231316
It appears that Bug #79382 (Cannot redeclare disabled function) was
fixed in
https://github.com/php/php-src/commit/53eee290b6f5ca531aef19885a392c939013ce36.
That fix uses a simple lower-case lookup of the provided function's
name.
To be clear, overriding a built-in function, alias or not, is probably
not a good idea, and I don't know if this should be fixed. But it is an
unexpected breaking change for legacy code and it should at least be
documented.
Test script:
---------------
var_dump(function_exists('getDir'));
Expected result:
----------------
In PHP prior to 8, the check returned false.
Actual result:
--------------
Starting with PHP 8 this returns true
--
Edit bug report at https://bugs.php.net/bug.php?id=80914&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80914&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80914&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80914&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80914&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80914&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80914&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80914&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80914&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80914&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80914&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80914&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80914&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80914&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80914&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80914&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80914&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80914&r=mysqlcfg
Thread (8 messages)
- chris at vendiadvertising dot com