php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76451 Aliases during inheritance type checks affected by opcache
Submitted: 2018-06-11 20:07 UTC Modified: 2019-05-24 11:00 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nikic@php.net Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2018-06-11 (Git) OS:
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.
Password:
Status:
Package:
Bug Type:
Summary:
From: nikic@php.net
New email:
PHP Version: OS:

 

 [2018-06-11 20:07 UTC] nikic@php.net
Description:
------------
If type-equality checks during inheritance fail on simple string comparison, they fall back to loaded the class entries and comparing those. This allows aliased classes to pass inheritance checks.

However, if classes are early-bound, then the alias will not be available if opcache is used, as compilation is isolated.

The attached test script will work without opcache and fail with opcache.

Test script:
---------------
// file1.php
<?php
class Foo {}
class_alias('Foo', 'Bar');
require __DIR__ . '/file2.php';

// file2.php
<?php
class A {
    public function test(Foo $foo) {}
}
class B extends A {
    public function test(Bar $foo) {}
}


Expected result:
----------------
No error.

Actual result:
--------------
Warning: Declaration of B::test(Bar $foo) should be compatible with A::test(Foo $foo)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-09 09:18 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2019-05-24 11:00 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC