From:             hanskrentel at yahoo dot de
Operating system: 
PHP version:      5.4.14
Package:          SPL related
Bug Type:         Feature/Change Request
Bug description:SplFileObject constructor make $context optional / give it a 
default value

Description:
------------
When extending from SplFileObject and overwriting the constructor, it is
not 
easily possible to override the parent one because for the last parameter
$context 
one can not provide an optional default.

Therefore it requires (somewhat needles) if-branched code only to deal with
the 
$context not passed case when calling the parents constructor.

It would be nice if $context does accept NULL then if I do not want to use
any 
context but need to specify the parameter.

Test script:
---------------
<?php

class Myfile extends SplFileObject
{
    public function __construct($file_name, $open_mode = "r",
$use_include_path = FALSE, $context = NULL) {
        $this->levels = new Levels();
        parent::__construct($file_name, $open_mode, $use_include_path,
$context);
    }
}

$file = new MyFile(__FILE__);

Expected result:
----------------
It should not give any warning or error.

Actual result:
--------------
Warning: Missing argument 4 for Myfile::__construct(), called in [pointing
to the 
line "$file = new MyFile(__FILE__);"]  and defined in [pointing to the line

"public function __construct($file_name, $open_mode = "r",
$use_include_path = 
FALSE, $context = NULL) {"]

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64782&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64782&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64782&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64782&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64782&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64782&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64782&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64782&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64782&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64782&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64782&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64782&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64782&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64782&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64782&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64782&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64782&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64782&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64782&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64782&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64782&r=mysqlcfg

Reply via email to