Bug #38618 [Com]: default implementation of hasChildren() in RecursiveArrayIterator does not work

2010-05-20 Thread mi dot olszewski at gmail dot com
Edit report at http://bugs.php.net/bug.php?id=38618&edit=1

 ID:   38618
 Comment by:       mi dot olszewski at gmail dot com
 Reported by:  mike at silverorange dot com
 Summary:  default implementation of hasChildren() in
   RecursiveArrayIterator does not work
 Status:   No Feedback
 Type: Bug
 Package:  SPL related
 Operating System: *
 PHP Version:  5.2.5
 Assigned To:  colder

 New Comment:

Hi,



I've stumbled upon this issue and although fix
(RecursiveArrayIterator::CHILD_ARRAYS_ONLY flag/constant) is available
on PHP 5.3 it is not present in PHP 5.2.



Additionally PHP sources are out of sync - the new constant is present
only in spl_array.c file but recursivearrayiterator.inc is not updated:
the CHILD_ARRAYS_ONLY constant is missing and hasChildren() definition
contains only is_array() check. This is really confusing because new
users of RecursiveArrayIterator will check PHP sources first. It took me
quite a while to find out about this new flag. Also - most of hosting
providers still use PHP 5.2 which means most of people will have to use
hasChildren() override workaround to get it working.



Could you please add the constant to PHP 5.2 branch and update
recursivearrayiterator.inc (and documentation at
http://www.php.net/~helly/php/ext/spl if possible)?



Thank you.


Previous Comments:

[2008-05-15 23:23:28] col...@php.net

I MFB'ed that patch to HEAD as well with a slight distinction,

The constant now belongs to RecursiveArrayIterator, and not ArrayObject
anymore.



This flag is off by default.


[2007-12-05 16:00:40] he...@php.net

So far the behavior is expected as ArrayObject/ArrayIterator follow
arrays as well as objects. For 5.3 I added a new flag
ArrayObject::CHILD_ARRAYS_ONLY that can be used to prevent ArrayIterator
from following objects. IF you feel this is ok let me know. If you think
the behavior should be reverse, meaning the flag should be active by
default and there should be a way to disable it then open a RFC on
intern...@php.net.


[2007-08-20 15:01:23] j...@php.net

Marcus, can you check this out please?


[2007-08-20 14:14:53] mike at silverorange dot com

I played around with the test case a bit more and it seems that the
default RecursiveArrayIterator iterates the public properties of objects
within the arrays.



For example, if I adda public $foo = 'bar' property to the Fruit class,
I get the following (incorrect) output:



Default recursive array iteraration:

title => apple

foo => bar

title => orange

foo => bar

title => banana

foo => bar

title => grape

foo => bar

title => peach

foo => bar

title => strawberry

foo => bar

title => grapefruit

foo => bar


[2007-08-20 14:05:21] mike at silverorange dot com

I tried changing the scope of the $title property from protected to
public and the test case does indeed run correctly.



Even so, the test case should still run correctly when the property is
protected.




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

http://bugs.php.net/bug.php?id=38618


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=38618&edit=1


[PHP-BUG] Req #51532 [NEW]: Cannot override SplFileObject::fscanf()

2010-04-11 Thread mi dot olszewski at gmail dot com
From: 
Operating system: MS Windows Vista
PHP version:  5.3.2
Package:  SPL related
Bug Type: Feature/Change Request
Bug description:Cannot override SplFileObject::fscanf()

Description:

There seems to be a problem with overriding SPLFileObject::fscanf() method.
I'm not sure whether this is PHP language-related issue or issue with
method definition in SPLFileObject.



When you look at 'splfileobject.inc' file from PHP 5.3.2 source code you
can see that method definition is:



function fscanf($format /* , ... */)



so it seems logical to assume only one parameter in overridden method.



However, using Reflection API to get fscanf parameters:



$class = new ReflectionClass('SPLFileObject');

$method = $class->getMethod('fscanf');

$params = $method->getParameters();

foreach ($params as $p)

{

 echo $p->getName() . PHP_EOL;

}



Prints out:



format

...



Yes - '...' is literally printed out.



So it leaves me puzzled - either I am missing something very obvious or
fscanf is handling variable-length method arguments in some non-standard
way (like using func_get_args()).



All in all - overriding fscanf in a way like in specified example test
script results in strict standards notice.

Test script:
---
class SomeOtherFileObject extends SPLFileObject {

  function fscanf($format) {

echo 'my little dummy';

  }

}



$test = new SomeOtherFileObject('test.php');

$test->fscanf('%s');

Expected result:

The fscanf method is overridden without PHP notices, warnings and errors.

Actual result:
--
Strict standards: Declaration of SomeOtherFileObject::fscanf() should be
compatible with that of SplFileObject::fscanf()

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