|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79350 Classes with __toString() do not support early binding
Submitted: 2020-03-07 04:12 UTC Modified: 2021-07-23 09:29 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bugreports at gmail dot com Assigned:
Status: Analyzed Package: Scripting Engine problem
PHP Version: master-Git-2020-03-07 (Git) OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bugreports at gmail dot com
New email:
PHP Version: OS:


 [2020-03-07 04:12 UTC] bugreports at gmail dot com

this is only broken with PHP 8.0-dev for some time now and it's technically not possible that a class defined in the include above the extending definition is not found

require_once __DIR__ . '/PelEntry.php';
class PelEntryUndefined extends PelEntry

[builduser@testserver:/rpmbuild/SPECS]$ /home/builduser/rpmbuild/BUILD/php-8.0.0/sapi/cli/php -n /www/php-bug/test.php
Fatal error: Uncaught Error: Class 'PelEntry' not found in /Volumes/dune/www-servers/php-bug/pel/PelEntryUndefined.php:59
Stack trace:
#0 /Volumes/dune/www-servers/php-bug/pel/PelIfd.php(44): require_once()
#1 /Volumes/dune/www-servers/php-bug/pel/PelTag.php(45): require_once('/Volumes/dune/w...')
#2 /Volumes/dune/www-servers/php-bug/pel/PelEntry.php(52): require_once('/Volumes/dune/w...')
#3 /Volumes/dune/www-servers/php-bug/pel/PelExif.php(47): require_once('/Volumes/dune/w...')
#4 /Volumes/dune/www-servers/php-bug/pel/PelJpeg.php(49): require_once('/Volumes/dune/w...')
#5 /Volumes/dune/www-servers/php-bug/test.php(2): include_once('/Volumes/dune/w...')
#6 {main}
  thrown in /Volumes/dune/www-servers/php-bug/pel/PelEntryUndefined.php on line 59

Test script:
tarball with the (i know outdated) pel-library and the simplest reproducer which works in 7.0-7.4 but no longer with HEAD


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-12 10:09 UTC]
-Status: Open +Status: Verified
 [2020-03-12 10:09 UTC]
I think something is going wrong with a recursive require_once.
 [2020-03-12 10:22 UTC]
No, that's not it. I think the issue is that this code is relying on early binding, and early-binding on the PelEntry class is now prevented due to implicit addition of Stringable interface.
 [2020-03-12 10:29 UTC]
-Status: Verified +Status: Analyzed
 [2020-03-12 10:29 UTC]
Here's a reduced test case:

echo new Test, "\n";

class Test {
    public function __toString() {
        echo "Early bound!";
 [2020-03-12 10:51 UTC] bugreports at gmail dot com
sounds like a terrible BC break and at least the error message is unhelpful nonsense given that even one of the zend engine experts pointed at include at the first try :-)
 [2021-07-23 09:29 UTC]
-Summary: 8.0-dev: Uncaught Error: Class 'PelEntry' not found +Summary: Classes with __toString() do not support early binding
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 06:03:37 2021 UTC