php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56662 Wrong access level with RUNKIT_ACC_PUBLIC
Submitted: 2005-11-19 10:06 UTC Modified: 2013-02-23 11:14 UTC
From: svenfuchs at artweb-design dot de Assigned: pollita (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5_1 CVS-2005-11-19 OS: Windows
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: svenfuchs at artweb-design dot de
New email:
PHP Version: OS:

 

 [2005-11-19 10:06 UTC] svenfuchs at artweb-design dot de
Description:
------------
Methods being added as RUNKIT_ACC_PUBLIC seem to somehow have lost their access level when they are inspected through Reflection. 

When a class containing such a method gets extended by another class that overwrites this method and is loaded later on an error gets thrown: "Access level to C::x() must be (as in class A) or weaker"

I've found this in php 5.1.0RC6 as well in previous 5.1.0RC versions. I haven't tested with other php versions.

Reproduce code:
---------------
// does not have a 'public' identifier in Reflection export:
class A {}
runkit_method_add ('A', 'x', '', '', RUNKIT_ACC_PUBLIC);
Reflection::export(new ReflectionMethod('A', 'x'));

// works perfectly well:
class B extends A { public function x() {} }
Reflection::export(new ReflectionMethod('B', 'x'));

// throws an error:
include('C.php'); 
// with C.php being: <?php class C extends A { public function x() {} } ?>
Reflection::export(new ReflectionMethod('C', 'x'));

Expected result:
----------------
Method [ public method x ] { @@ (...) } 
Method [ public method x ] { @@ (...) } 
Method [ public method x ] { @@ (...) } 

Actual result:
--------------
Method [ method x ] { @@ (...) } 
Method [ public method x ] { @@ (...) } 
Fatal error: Access level to C::x() must be (as in class A) or weaker in (...)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-23 11:14 UTC] pollita@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pollita
 [2013-02-23 11:14 UTC] pollita@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

This is working in my checkout and I've added a test to check for it: 
tests/bug56662.phpt
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC