php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63133 Runtime Notice & Declaration of private methods
Submitted: 2012-09-21 15:45 UTC Modified: 2016-01-24 04:22 UTC
Votes:3
Avg. Score:3.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: goetas at lignano dot it Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.3.17 OS: ubuntu/slackware
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: goetas at lignano dot it
New email:
PHP Version: OS:

 

 [2012-09-21 15:45 UTC] goetas at lignano dot it
Description:
------------
There is some "erros" with overwritten private methods in different classes.

The bug is linked to #62956, but the bug seems to be solved only for classes defined inside the same file. 

Test script:
---------------
Example 1
test.php
----
class ClassA {
	public function fun(){
		$this->myMethod(5);
	}
	private function myMethod($param){
	}
}
class ClassB extends ClassA {
	public function fun(){
		$this->myMethod();
	}
	private function myMethod(){
	}
}
---



Example 2

----
test.php
----
class ClassA {
	public function fun(){
		$this->myMethod(5);
	}

	private function myMethod($param){
	}
}
include 'test2.php'
---

test2.php
----
class ClassB extends ClassA {
	public function fun(){
		$this->myMethod();
	}
	private function myMethod(){
	}
}
---




Expected result:
----------------
The two examples should work both

Actual result:
--------------
The second example rises this error:

Strict Standards: Declaration of ClassB::myMethod() should be compatible with that of ClassA::myMethod() in /mnt/md1/data/www/test2.php on line 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-22 03:26 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2012-09-22 03:26 UTC] laruence@php.net
the two example both throw strict warning here. could you please check it again? 
make sure you set error_reporting to show E_STRICT.

the fix for #62956 is only for 5.4 branch.  5.3 is a very stable version, we don't 
want to make such change to it.

thanks
 [2012-09-24 07:30 UTC] goetas at lignano dot it
-Status: Feedback +Status: Open
 [2012-09-24 07:30 UTC] goetas at lignano dot it
I've just tested with fresh PHP downloaded and compiled few minutes ago.

goetas@goetas-desktop:~/php-5.3.17/sapi/cli$ php -v
PHP 5.3.2-1ubuntu4.17 with Suhosin-Patch (cli) (built: Jun 19 2012 03:21:35) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


goetas@goetas-desktop:~/php-5.3.17/sapi/cli$ php /home/goetas/Scrivania/www/varie/testprivarte.php 
PHP Strict Standards:  Declaration of ClassB::myMethod() should be compatible with that of ClassA::myMethod() in /home/goetas/sviluppo/mnt/md1/data/www/varie/testprivarteB.php on line 10

Strict Standards: Declaration of ClassB::myMethod() should be compatible with that of ClassA::myMethod() in /home/goetas/sviluppo/mnt/md1/data/www/varie/testprivarteB.php on line 10
 [2012-09-24 14:56 UTC] nikic@php.net
@goetas: Your CLI indicates that you are using PHP 5.3, but as laruence pointed out above this was only fixed in PHP 5.4 ;)

Not sure though what prevents us from fixing it in 5.3 too. Doesn't break BC after all.
 [2012-09-24 15:32 UTC] goetas at lignano dot it
@nikic You are right. I've forgot to add "./" before "php" 

goetas@goetas-desktop:~/php-5.3.17/sapi/cli$ ./php -v  
PHP 5.3.17 (cli) (built: Sep 24 2012 09:14:34) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

goetas@goetas-desktop:~/php-5.3.17/sapi/cli$ ./php  /home/goetas/Scrivania/www/varie/testprivarte.php 

Strict Standards: Declaration of ClassB::myMethod() should be compatible with that of ClassA::myMethod() in /home/goetas/sviluppo/mnt/md1/data/www/varie/testprivarteB.php on line 10
 [2012-09-25 03:06 UTC] laruence@php.net
@goetas  5.3 didn't apply the fix at all, so it's right that E_STRCT warning shows 
up in 5.3.

@nikic it's not a big issue, and it's a engine behavior change. I assume lstrojny 
did'nt apply that fix to 5.3 for that reason.
 [2012-09-25 06:58 UTC] goetas at lignano dot it
Should it be fixed?
 [2016-01-16 12:49 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2016-01-16 12:49 UTC] danack@php.net
This appears to be fixed in current versions of PHP.

If you believe there is still an issue, please provide more information.
 [2016-01-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC