php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53992 ambiguous property/method access
Submitted: 2011-02-11 07:23 UTC Modified: 2011-02-11 08:56 UTC
From: msg2maciej at aol dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS: MAC OSX
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: msg2maciej at aol dot com
New email:
PHP Version: OS:

 

 [2011-02-11 07:23 UTC] msg2maciej at aol dot com
Description:
------------
I'm not sure if this is a bug. If you look in code why protected method hello() can be accessed and property $this->var not, from that method? PHP 5.3.3

Test script:
---------------
<?php
abstract class abstract_class {	abstract protected function  hello(); }
class A extends abstract_class
{	private $B; 	protected $var;
	function __construct ()	{
		$this->var = 'Undefined property??';
		$this->B = new B(__CLASS__);
	}
	protected function  hello()	{
		echo 'accessing '.__CLASS__.'::protected method - hello()'.PHP_EOL;
		echo $this->var;
}}
class B extends abstract_class
{	function __construct ( $class_A )
	{	$class_A::hello();	}
	protected function hello(){}
} new A; ?>

Expected result:
----------------
access $this->var , look into script.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-11 08:55 UTC] scottmac@php.net
You're accessing hello() statically therefore there is no $this context.

Add error_reporting(-1); to the top of your script and see all the errors.
 [2011-02-11 08:56 UTC] scottmac@php.net
-Status: Open +Status: Bogus
 [2011-02-11 08:56 UTC] scottmac@php.net
See previous comment.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 01:01:32 2025 UTC