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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 05:01:31 2024 UTC