php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53082 unexp. warning with abstract static methods used inside another file
Submitted: 2010-10-16 09:36 UTC Modified: 2010-10-16 17:21 UTC
From: giorgio dot liscio at email dot it Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 + 30 = ?
Subscribe to this entry?

 
 [2010-10-16 09:36 UTC] giorgio dot liscio at email dot it
Description:
------------
without namespace works perfectly:


<?php
// index.php
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL | E_STRICT);
abstract class AbstractFileSystemItem
{
	abstract static function ensurePathIsValid($fullPath);
}
class Dir extends AbstractFileSystemItem
{
	static function ensurePathIsValid($fullPath){}
}
?>

--------------------------------------------------------

with namespace and require: (test the two files)
gives unexpected warning 
Static function AbstractFileSystemItem::ensurePathIsValid() should not be abstract

<?php
// index.php (run this)
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL | E_STRICT);
require("FSNuovo/Directory.php");
?>


<?php
// FSNuovo/Directory.php
namespace FSNuovo;
abstract class AbstractFileSystemItem
{
	abstract static function ensurePathIsValid($fullPath);
}
class Dir extends AbstractFileSystemItem
{
	static function ensurePathIsValid($fullPath){}
}
?>

original discussion: http://bugs.php.net/bug.php?id=53081


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-16 16:34 UTC] felipe@php.net
-Status: Open +Status: Verified
 [2010-10-16 16:34 UTC] felipe@php.net
The namespace is not a factor, but the require yes.

Internally the php_error_cb() function is called for both cases, but just displays when the code is in another file because EG(error_reporting) is set to 'E_ALL | E_STRICT', when it's in the same file, EG(error_reporting) is 22519.
 [2010-10-16 17:07 UTC] felipe@php.net
This is because when the code is in another file, the error is triggered in runtime, and when it is in the same file, it is triggered in compile-time, so EG(error_reporting) has the default value (E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED).
 [2010-10-16 17:09 UTC] felipe@php.net
-Summary: unexp. warning with abstract static methods used inside namespace/required file +Summary: unexp. warning with abstract static methods used inside another file -Package: Class/Object related +Package: Scripting Engine problem
 [2010-10-16 17:21 UTC] felipe@php.net
-Status: Verified +Status: Bogus
 [2010-10-16 17:22 UTC] felipe@php.net
So... Not a bug.
 [2010-10-17 02:24 UTC] cmanley at xs4all dot nl
If it doesn't work as expected then it's either a bug or poor design in PHP. 
Either way it should be fixed. People put effort into reporting bugs, so it's rude 
to flag them as bogus (to make them go away) without putting much thought into 
them.
 [2010-10-17 02:45 UTC] giorgio dot liscio at email dot it
felipe is right, this is not a bug, but it is a limitation of the design

read this and comment here please:
http://bugs.php.net/bug.php?id=53081
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC