Bug #80552 [NEW]: Match is a reserved word
| From: | rasmus at mindplay dot dk | Date: | Fri, 25 Dec 2020 15:57:19 +0000 |
| Subject: | Bug #80552 [NEW]: Match is a reserved word | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-231250@lists.php.net to get a copy of this message | ||
From: rasmus at mindplay dot dk
Operating system: Linux
PHP version: 8.0.0
Package: *General Issues
Bug Type: Bug
Bug description:Match is a reserved word
Description:
------------
PHP 8.0 breaks any existing code with a class named "match", which
became a reserved word for some reason.
PHP 7.0 intentionally loosened such reserved word restrictions, per the
original release announcement here:
https://www.php.net/manual/en/migration70.other-changes.php
It would be nice if PHP continued in that vein to avoid more variations
of this problem.
Parser failure is demonstrated with a minimal repro here:
https://3v4l.org/A9Glt
A quick google search reveals at least two major projects (PHPUnit and
MediaWiki) affected by this change - here's a handful of examples from a
quick google search:
- https://github.com/sebastianbergmann/phpunit/issues/4373
-
https://github.com/wikimedia/mediawiki-vendor/blob/master/ruflin/elastica/lib/Elastica/Query/Match.php
- https://github.com/mindplay-dk/timber/blob/master/src/Match.php
-
https://github.com/zweifisch/php-pattern-matching/blob/master/match.php
- https://github.com/extesy/foosball/blob/master/match.php
Test script:
---------------
<?php
class Match {}
class Matcher
{
public function match(): Match {}
}
$matcher = new Matcher();
$match = $matcher->match();
Expected result:
----------------
It would be nice if this could be treated as a bug, and could be fixed
with a minor release, such that packages that were broken by this change
can be versioned correctly against e.g. PHP ^8.0.1, before everyone goes
and starts renaming classes and functions.
--
Edit bug report at https://bugs.php.net/bug.php?id=80552&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80552&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80552&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80552&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80552&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80552&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80552&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80552&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80552&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80552&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80552&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80552&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80552&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80552&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80552&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80552&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80552&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80552&r=mysqlcfg