From: pieterbregman1982 at gmail dot com
Operating system: Windows
PHP version: 5.3.1
PHP Bug Type: Class/Object related
Bug description: Strict errors when including/requiring class files
Description:
------------
PHP reports a strict error when classes are being included using include()
(or require()).
This error doesn't come up when the classes are in the scope allready by
inlining them in the same file that makes the calls to the classes.
I can't figure out why the error only occurs when the classes are being
included by using include()
Reproduce code:
---------------
test1.php (This code gives no strict errors)
<?php
ini_set('display_errors', '1');
error_reporting(-1);
abstract class Model {
public function create() {
echo __CLASS__;
}
}
class Person extends Model {
public function create($name) {
echo $name;
}
}
$person = new Person();
$person->create('Foo');
?>
test2.php (This code does give a strict error)
<?php
ini_set('display_errors', '1');
error_reporting(-1);
include_once 'Model.php';
include_once 'Person.php';
$person = new Person();
$person->create('Foo');
?>
Model.php
<?php
abstract class Model {
public function create() {
echo __CLASS__;
}
}
?>
Person.php
<?php
class Person extends Model {
public function create($name) {
echo $name;
}
}
?>
Expected result:
----------------
I would expect that both tests don't give strict errors.
Actual result:
--------------
test02.php - Strict error:
Strict standards: Declaration of Person::create() should be compatible
with that of Model::create() in Person.php on line 6
--
Edit bug report at http://bugs.php.net/?id=50925&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50925&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50925&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50925&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50925&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50925&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50925&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50925&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50925&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50925&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50925&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50925&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50925&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50925&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50925&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50925&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50925&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50925&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50925&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50925&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50925&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50925&r=mysqlcfg