Skip to content

About

Is your codebase ready for PHP 8.6 (GA 2026-11-19)? Offline scan for all 8.6 deprecations — no PHP binary needed — plus the PHP 8.2 EOL warning (2026-12-31).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

php86-upgrade-check

demo

Find every PHP 8.6 deprecation in your codebase in 0.05 seconds — one command, zero dependencies, no PHP binary needed.

A stdlib-only Python CLI that scans your *.php files for code deprecated in PHP 8.6 and tells you the fix for each hit, with file:line precision. A full scan of the labelled fixture tree (3 files, 19 known hits) takes a median 0.0536 s (7 runs, measured 2026-11-20 on this machine) — faster than opening the release notes. No PHP install required: it reads your source, nothing else.

Why now

PHP 8.6.0 GA was released 2026-11-19 (release managers Daniel Scherzer, Matteo Beccati, Joe Ferguson), and PHP 8.2 reaches end of life on 2026-12-31 — no security fixes after that date. If you are still on 8.2, you have about six weeks to move, and the move is not free: PHP 8.6 deprecates a long list of functions and patterns that are slated for removal in PHP 9. Every one of them will flood your logs with deprecation notices the day you upgrade — unless you find them first.

What was verified from the sources below:

  • Headline features in 8.6: partial function application, clamp(), Time\Duration, readonly property defaults, Io\Poll.
  • Deprecated in 8.6, removal planned in PHP 9: is_double(), is_integer(), is_long(), doubleval() → use is_float() / is_int() / floatval(); strcoll() and the SORT_LOCALE_STRING flag → the Collator class; spl_classes(); spl_object_hash() → spl_object_id(); metaphone(); the mb_ereg* functions and mb_split(); mysqli_get_charset(); mysqli_stmt_init(); returning from a finally block; returning a value from __construct() or __destruct() (a bare return; is still allowed); passing a 3rd argument to define(); using is or let as a class/function/constant name; using _ as a constant name; using namespace as a class constant name; naming a function readonly; ArrayIterator methods inherited from ArrayObject and SplFileObject CSV methods; passing objects to array_walk() / http_build_query() / mb_convert_variables(); passing a string to is_a() / is_subclass_of() when $allow_string is false; session handlers that do not implement create_sid() / validateId(); more than 16 filters in a php://filter URL.
  • New session defaults — fresh installs only: session.use_strict_mode 0→1, session.cookie_httponly 0→1, session.cookie_samesite unset→Lax. Existing installs keep their current values, so this tool does not flag them.
  • This tool covers the function-call deprecations, SORT_LOCALE_STRING, return inside finally, return values from __construct() / __destruct(), and define() with 3 arguments — the ones a source scanner can detect reliably. The name/keyword deprecations (is, let, _, namespace, readonly) need a real parser and are listed here so you know what this tool does not check.

Sources: PHP 8.6 deprecations RFC · Laravel News — PHP 8.6 · Utibox — PHP 8.6 release / PHP 8.2 EOL

Quick start (30 seconds)

git clone https://github.com/Mahgal/php86-upgrade-check.git
cd php86-upgrade-check
python3 php86_upgrade_check.py --path /path/to/your/project --php-version 8.2

No pip installs, no dependencies — Python 3 only. No PHP binary needed. Try it without a PHP project:

python3 php86_upgrade_check.py --demo                 # labelled fixtures: 19 known hits
python3 php86_upgrade_check.py --demo --json           # machine-readable output for CI
python3 php86_upgrade_check.py --path src --fail-on 1  # CI gate: exit 1 if any hit
python3 php86_upgrade_check.py --path src --php-version 8.4

Verified from a clean copy (fresh copy in /tmp, 2026-11-20): --demo runs and the full test suite passes, 54/54, exit 0; the demo output is byte-identical to demo.txt.

Example output

Real output of python3 php86_upgrade_check.py --demo (captured verbatim to demo.txt; re-runs reproduce it byte-for-byte, sha256 c56f4ce7b09785ba6f59b06bf1bfff3872f22c4951ed60ae44deaefeafb8fa8d):

[demo] labelled fixtures in examples/ — known hit counts, not your code
Scanning examples for PHP 8.6 deprecations

examples/legacy.php:6: is_double is deprecated in PHP 8.6 — Use is_float() instead.
examples/legacy.php:9: is_integer is deprecated in PHP 8.6 — Use is_int() instead.
examples/legacy.php:12: is_long is deprecated in PHP 8.6 — Use is_int() instead.
examples/legacy.php:15: doubleval is deprecated in PHP 8.6 — Use floatval() instead.
examples/legacy.php:16: strcoll is deprecated in PHP 8.6 — Use Collator::compare() instead.
examples/legacy.php:17: SORT_LOCALE_STRING is deprecated in PHP 8.6 — Use the Collator class for locale-aware sorting.
examples/legacy.php:18: spl_classes is deprecated in PHP 8.6 — Remove the call — no direct replacement; see the PHP 8.6 deprecations RFC.
examples/legacy.php:19: spl_object_hash is deprecated in PHP 8.6 — Use spl_object_id() instead.
examples/legacy.php:20: metaphone is deprecated in PHP 8.6 — Remove the call — no direct replacement in PHP 8.6.
examples/legacy.php:21: mb_ereg is deprecated in PHP 8.6 — Use preg_*() with the /u modifier instead.
examples/legacy.php:24: mb_split is deprecated in PHP 8.6 — Use preg_split() with the /u modifier instead.
examples/legacy.php:25: mysqli_get_charset is deprecated in PHP 8.6 — Use mysqli_character_set_name() instead.
examples/legacy.php:26: mysqli_stmt_init is deprecated in PHP 8.6 — Use mysqli_prepare() to create a prepared statement directly.
examples/legacy.php:31: return_in_finally is deprecated in PHP 8.6 — Move the return out of the finally block.
examples/legacy.php:37: return_value_from_construct is deprecated in PHP 8.6 — Use a bare 'return;' or restructure.
examples/legacy.php:41: define_3_args is deprecated in PHP 8.6 — Drop the 3rd argument (case-insensitive constants are gone).
examples/mixed.php:4: mb_eregi is deprecated in PHP 8.6 — Use preg_*() with the /u and /i modifiers instead.
examples/mixed.php:7: mb_ereg is deprecated in PHP 8.6 — Use preg_*() with the /u modifier instead.
examples/mixed.php:12: return_value_from_destruct is deprecated in PHP 8.6 — Use a bare 'return;' or restructure.

Summary: 19 hit(s) in 2 file(s) (3 file(s) scanned)
By rule:
  SORT_LOCALE_STRING: 1
  define_3_args: 1
  doubleval: 1
  is_double: 1
  is_integer: 1
  is_long: 1
  mb_ereg: 2
  mb_eregi: 1
  mb_split: 1
  metaphone: 1
  mysqli_get_charset: 1
  mysqli_stmt_init: 1
  return_in_finally: 1
  return_value_from_construct: 1
  return_value_from_destruct: 1
  spl_classes: 1
  spl_object_hash: 1
  strcoll: 1
[demo] exit code 1 by design: fixtures contain known deprecation hits

The same checks against your own code:

$ python3 php86_upgrade_check.py --path examples/clean.php
Scanning examples/clean.php for PHP 8.6 deprecations

Summary: 0 hit(s) in 0 file(s) (1 file(s) scanned)
No PHP 8.6 deprecations found.        # exit 0

$ python3 php86_upgrade_check.py --path src --php-version 8.2
PHP version: 8.2
WARNING: PHP 8.2 reaches end of life on 2026-12-31 — no security fixes after that date. Upgrade to PHP 8.6 (GA 2026-11-19) or at least 8.3+.
...                                    # exit 1 if any hit

Rules

Rule What it flags Fix
is_double is_double() is_float()
is_integer is_integer() is_int()
is_long is_long() is_int()
doubleval doubleval() floatval()
strcoll strcoll() Collator::compare()
SORT_LOCALE_STRING SORT_LOCALE_STRING flag Collator class
spl_classes spl_classes() Remove — no replacement
spl_object_hash spl_object_hash() spl_object_id()
metaphone metaphone() Remove — no replacement
mb_ereg mb_ereg*() preg_*() with /u
mb_eregi mb_eregi*() preg_*() with /u + /i
mb_split mb_split() preg_split() with /u
mysqli_get_charset mysqli_get_charset() mysqli_character_set_name()
mysqli_stmt_init mysqli_stmt_init() mysqli_prepare()
return_in_finally return <value>; inside finally Move the return out
return_value_from_construct return <value>; in __construct() Bare return; or restructure
return_value_from_destruct return <value>; in __destruct() Bare return; or restructure
define_3_args define() with 3 arguments Drop the 3rd argument

Hits inside //, # and /* */ comments and inside '...' / "..." string literals are skipped — the scanner blanks them before matching, so a commented-out call or a call mentioned in a string is not flagged. Method calls ($obj->is_double()) and static calls (Foo::is_long()) are not flagged either: only plain function calls are.

The --php-version flag

$ python3 php86_upgrade_check.py --path src --php-version 8.2
WARNING: PHP 8.2 reaches end of life on 2026-12-31 — ...

$ python3 php86_upgrade_check.py --path src --php-version 8.4
NOTE: PHP 8.6.0 GA was released 2026-11-19 — plan your upgrade from PHP 8.4; ...

$ python3 php86_upgrade_check.py --path src --php-version 8.6
NOTE: PHP 8.6 — these deprecations apply now; fix them before they are removed in PHP 9.

Exit codes

Code Meaning
0 No hits found (or hits below --fail-on)
1 Hits found — by design, so it works as a CI gate; --demo exits 1 because the fixtures contain known hits
2 Usage error (bad flag, unreadable path, invalid --php-version)

--fail-on N overrides the threshold: exit 1 if hits ≥ N, else exit 0. --json prints the full result (hits, per-rule counts, version note) as JSON for CI.

Tests

Stdlib unittest only — no pytest, no network:

python3 tests/run_tests.py

54 tests, all passing (exit 0), covering: every rule's detection (all 14 function rules plus the structural rules), comment and string skipping (//, #, /* */, single- and double-quoted strings, multi-line block comments), line-number preservation after stripping, method/static-call exclusion, bare return; in __construct() (allowed) vs. return-with-value (flagged), define() with 2 vs. 3 arguments (including nested parens), version parsing and EOL/upgrade notes for 8.1/8.2/8.4/8.6, JSON output shape, --fail-on thresholds, demo determinism (two runs byte-identical), and the fixture hit counts (legacy 16, mixed 3, clean 0).

Limitations — read before trusting the output

  • This is a regex scanner, not a parser. It blanks comments and string literals and then pattern-matches. It does not understand heredocs or nowdocs, so a deprecated call written inside a heredoc may be flagged (false positive), and code built with eval() or variable function names ($fn = 'is_double'; $fn($x);) is invisible to it (false negative). It also cannot see the name/keyword deprecations (is, let, _, namespace, readonly) — those need a real parser; check them by hand or with php -l plus the RFC list above.
  • It checks the deprecation list, not your runtime. A hit means "this code is deprecated in PHP 8.6" — it does not mean your app is broken today. Deprecated code still runs (with a notice) until PHP 9 removes it.
  • Version data is as published 2026-11-19/20. If the PHP project changes the removal timeline, the rules in php86_upgrade_check.py need updating — check the RFC link above.

License

MIT — see LICENSE.

About

Is your codebase ready for PHP 8.6 (GA 2026-11-19)? Offline scan for all 8.6 deprecations — no PHP binary needed — plus the PHP 8.2 EOL warning (2026-12-31).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages