Bug #65629 [Com]: SplObjectsStorage::detach() rewinds internal pointer

2013-09-21 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=65629edit=1

 ID: 65629
 Comment by: le...@php.net
 Reported by:alan dot bem at gmail dot com
 Summary:SplObjectsStorage::detach() rewinds internal pointer
 Status: Verified
 Type:   Bug
 Package:SPL related
 PHP Version:Irrelevant
 Assigned To:levim
 Block user comment: N
 Private report: N

 New Comment:

Bug #63917 is a duplicate of this one (has a phpt uploaded -- might be useful).


Previous Comments:

[2013-09-21 22:58:59] le...@php.net

Related To: Bug #63917


[2013-09-12 22:49:38] le...@php.net

Regardless of whether this is a bug, in general modifying a structure during 
iteration has undefined behavior. I will look a bit into this and see what 
might 
be done.


[2013-09-07 03:14:18] alan dot bem at gmail dot com

Description:

It seems that SplObjectsStorage::detach() internally rewinds its array pointer.

PHP versions from 5.1.0 to 5.5.3 are affected.

Test script:
---
// To see this live, go to: http://3v4l.org/MAELj

?php
class A
{
public $val;
public function __construct($val) { $this-val = $val; }
}
$storage = new SplObjectStorage;
for($i = 1; $i = 10; $i++) {
$storage-attach(new A($i));
}
$iterations = 0;
$storage-rewind();
while ($storage-valid()) {
$iterations++;
$object = $storage-current();
echo 'Iteration #' . $iterations . ' with object A(' . $object-val . ')';
$storage-next();
if($iterations === 2 || $iterations === 8) {
$storage-detach($object);
echo ' - deleted Object A(' . $object-val . ') ';
}
echo PHP_EOL;
}
echo 'Number of iterations: ' . $iterations . PHP_EOL;

Expected result:

Iteration #1 with object A(1)
Iteration #2 with object A(2) - deleted Object A(2) 
Iteration #3 with object A(3)
Iteration #4 with object A(4)
Iteration #5 with object A(5)
Iteration #6 with object A(6)
Iteration #7 with object A(7) - deleted Object A(7) 
Iteration #8 with object A(8)
Iteration #9 with object A(9)
Iteration #10 with object A(10)
Number of iterations: 10

Actual result:
--
Iteration #1 with object A(1)
Iteration #2 with object A(2) - deleted Object A(2) 
Iteration #3 with object A(1)
Iteration #4 with object A(3)
Iteration #5 with object A(4)
Iteration #6 with object A(5)
Iteration #7 with object A(6)
Iteration #8 with object A(7) - deleted Object A(7) 
Iteration #9 with object A(1)
Iteration #10 with object A(3)
Iteration #11 with object A(4)
Iteration #12 with object A(5)
Iteration #13 with object A(6)
Iteration #14 with object A(8)
Iteration #15 with object A(9)
Iteration #16 with object A(10)
Number of iterations: 16






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65629edit=1


Bug #60338 [Com]: SplFixedArray::key returns index for invalid keys

2013-09-21 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=60338edit=1

 ID: 60338
 Comment by: le...@php.net
 Reported by:g...@php.net
 Summary:SplFixedArray::key returns index for invalid keys
 Status: Open
 Type:   Bug
 Package:SPL related
 PHP Version:5.4SVN-2011-11-19 (SVN)
 Block user comment: N
 Private report: N

 New Comment:

I personally don't see why we should bring this into line with array, 
ArrayObject 
and ArrayIterator behavior. The fact of the matter is simple: you are calling 
`key()` on an iterator that is not in a valid state; therefore the behavior is 
undefined. The fact that array and the other classes you mention return `NULL` 
is 
an implementation detail, the only one of which I believe is guaranteed is the 
case of an array.


Previous Comments:

[2011-11-19 13:38:53] g...@php.net

Apparently the Expected Output is achieved when using key() instead of 
SplFixedArray::key(). See http://codepad.viper-7.com/I3REjD. Thanks to NikiC 
for pointing it out.


[2011-11-19 13:32:44] g...@php.net

Description:

SplFixedArray::key() will return a value even when the key does not exist in 
the SplFixedArray. This does not conform to the behavior we have in regular 
arrays, ArrayObject and ArrayIterator. SplFixedArray::key() should return NULL 
when the current key does not exist to conform.

Test script:
---
http://codepad.viper-7.com/4hWmUn

Expected result:

NULL NULL NULL NULL 

Actual result:
--
int(3) NULL NULL NULL 






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60338edit=1


Req #60760 [PATCH]: Converting zend_parse_parameters() to zend_parse_parameters_none()

2013-09-18 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=60760edit=1

 ID: 60760
 Patch added by: le...@php.net
 Reported by:dragoo...@php.net
 Summary:Converting zend_parse_parameters() to
 zend_parse_parameters_none()
 Status: Assigned
 Type:   Feature/Change Request
 Package:SPL related
 Operating System:   N/A
 PHP Version:5
 Assigned To:levim
 Block user comment: N
 Private report: N

 New Comment:

The following patch has been added/updated:

Patch Name: spl_zpp_none.diff
Revision:   1379516433
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_zpp_none.diffrevision=1379516433


Previous Comments:

[2013-09-18 09:39:20] ni...@php.net

@levi You should use the == FAILURE variant. Nearly all PHP code does the 
failure/success comparison at the end :)


[2013-09-17 23:58:15] le...@php.net

My latest patch changes a few of these. Also, there were two styles in use:

if (zend_parse_parameters_none() == FAILURE)
if (FAILURE == zend_parse_parameters_none())

I picked the latter as `if (FAILURE` indicates the purpose a bit better, in my 
opinion. If I should have picked the former: let me know and I'll attach a new 
patch.


[2013-09-17 23:55:45] le...@php.net

The following patch has been added/updated:

Patch Name: spl_zpp_none.patch
Revision:   1379462145
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_zpp_none.patchrevision=1379462145


[2012-01-20 02:37:31] dragoo...@php.net

This is just the way a lot of the phpsrc has been built. Look around various 
/ext/ places and you'll see it. I'm just cleaning things up and keeping 
consistency.

Got a few more cleanup patches to submit on the SplHeap class for this same 
reason as i've been working on that class recently.

- Paul.


[2012-01-20 02:23:52] larue...@php.net

if no parameters will be accpected, why call to zend_parse_parameters? just a 
arginfo will be enough.




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

https://bugs.php.net/bug.php?id=60760


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60760edit=1


Req #60760 [Com]: Converting zend_parse_parameters() to zend_parse_parameters_none()

2013-09-18 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=60760edit=1

 ID: 60760
 Comment by: le...@php.net
 Reported by:dragoo...@php.net
 Summary:Converting zend_parse_parameters() to
 zend_parse_parameters_none()
 Status: Assigned
 Type:   Feature/Change Request
 Package:SPL related
 Operating System:   N/A
 PHP Version:5
 Assigned To:levim
 Block user comment: N
 Private report: N

 New Comment:

The latest patch follows the convention:

zend_parse_parameters_none() == FAILURE

It also converts a few zpp that are not 'none':

FAILURE == zend_parse_parameters(...)
zend_parse_parameters(...) == FAILURE


Previous Comments:

[2013-09-18 15:00:33] le...@php.net

The following patch has been added/updated:

Patch Name: spl_zpp_none.diff
Revision:   1379516433
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_zpp_none.diffrevision=1379516433


[2013-09-18 09:39:20] ni...@php.net

@levi You should use the == FAILURE variant. Nearly all PHP code does the 
failure/success comparison at the end :)


[2013-09-17 23:58:15] le...@php.net

My latest patch changes a few of these. Also, there were two styles in use:

if (zend_parse_parameters_none() == FAILURE)
if (FAILURE == zend_parse_parameters_none())

I picked the latter as `if (FAILURE` indicates the purpose a bit better, in my 
opinion. If I should have picked the former: let me know and I'll attach a new 
patch.


[2013-09-17 23:55:45] le...@php.net

The following patch has been added/updated:

Patch Name: spl_zpp_none.patch
Revision:   1379462145
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_zpp_none.patchrevision=1379462145


[2012-01-20 02:37:31] dragoo...@php.net

This is just the way a lot of the phpsrc has been built. Look around various 
/ext/ places and you'll see it. I'm just cleaning things up and keeping 
consistency.

Got a few more cleanup patches to submit on the SplHeap class for this same 
reason as i've been working on that class recently.

- Paul.




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

https://bugs.php.net/bug.php?id=60760


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60760edit=1


Req #60760 [PATCH]: Converting zend_parse_parameters() to zend_parse_parameters_none()

2013-09-17 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=60760edit=1

 ID: 60760
 Patch added by: le...@php.net
 Reported by:dragoo...@php.net
 Summary:Converting zend_parse_parameters() to
 zend_parse_parameters_none()
 Status: Assigned
 Type:   Feature/Change Request
 Package:SPL related
 Operating System:   N/A
 PHP Version:5
 Assigned To:levim
 Block user comment: N
 Private report: N

 New Comment:

The following patch has been added/updated:

Patch Name: spl_zpp_none.patch
Revision:   1379462145
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_zpp_none.patchrevision=1379462145


Previous Comments:

[2012-01-20 02:37:31] dragoo...@php.net

This is just the way a lot of the phpsrc has been built. Look around various 
/ext/ places and you'll see it. I'm just cleaning things up and keeping 
consistency.

Got a few more cleanup patches to submit on the SplHeap class for this same 
reason as i've been working on that class recently.

- Paul.


[2012-01-20 02:23:52] larue...@php.net

if no parameters will be accpected, why call to zend_parse_parameters? just a 
arginfo will be enough.


[2012-01-15 03:33:27] dragoo...@php.net

The following patch has been added/updated:

Patch Name: spl_dllist_zend_parse_parameters_none.diff
Revision:   1326598407
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_dllist_zend_parse_parameters_none.diffrevision=1326598407


[2012-01-15 03:32:21] dragoo...@php.net

Description:

Half of the file base uses zend_parse_parameters() to check if theres no params 
passed.

Half of the file already uses zend_parse_parameters_none().

The work done here just updates zend_parse_parameters() calls to 
zend_parse_parameters_none() where necessary.

Test script:
---
N/A

Expected result:

N/A

Actual result:
--
N/A






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60760edit=1


Req #60760 [Com]: Converting zend_parse_parameters() to zend_parse_parameters_none()

2013-09-17 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=60760edit=1

 ID: 60760
 Comment by: le...@php.net
 Reported by:dragoo...@php.net
 Summary:Converting zend_parse_parameters() to
 zend_parse_parameters_none()
 Status: Assigned
 Type:   Feature/Change Request
 Package:SPL related
 Operating System:   N/A
 PHP Version:5
 Assigned To:levim
 Block user comment: N
 Private report: N

 New Comment:

My latest patch changes a few of these. Also, there were two styles in use:

if (zend_parse_parameters_none() == FAILURE)
if (FAILURE == zend_parse_parameters_none())

I picked the latter as `if (FAILURE` indicates the purpose a bit better, in my 
opinion. If I should have picked the former: let me know and I'll attach a new 
patch.


Previous Comments:

[2013-09-17 23:55:45] le...@php.net

The following patch has been added/updated:

Patch Name: spl_zpp_none.patch
Revision:   1379462145
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_zpp_none.patchrevision=1379462145


[2012-01-20 02:37:31] dragoo...@php.net

This is just the way a lot of the phpsrc has been built. Look around various 
/ext/ places and you'll see it. I'm just cleaning things up and keeping 
consistency.

Got a few more cleanup patches to submit on the SplHeap class for this same 
reason as i've been working on that class recently.

- Paul.


[2012-01-20 02:23:52] larue...@php.net

if no parameters will be accpected, why call to zend_parse_parameters? just a 
arginfo will be enough.


[2012-01-15 03:33:27] dragoo...@php.net

The following patch has been added/updated:

Patch Name: spl_dllist_zend_parse_parameters_none.diff
Revision:   1326598407
URL:
https://bugs.php.net/patch-display.php?bug=60760patch=spl_dllist_zend_parse_parameters_none.diffrevision=1326598407


[2012-01-15 03:32:21] dragoo...@php.net

Description:

Half of the file base uses zend_parse_parameters() to check if theres no params 
passed.

Half of the file already uses zend_parse_parameters_none().

The work done here just updates zend_parse_parameters() calls to 
zend_parse_parameters_none() where necessary.

Test script:
---
N/A

Expected result:

N/A

Actual result:
--
N/A






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60760edit=1


Bug #62789 [Com]: Autoloaders are invoked with invalid class names

2013-02-05 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=62789edit=1

 ID: 62789
 Comment by: le...@php.net
 Reported by:drak at zikula dot org
 Summary:Autoloaders are invoked with invalid class names
 Status: Open
 Type:   Bug
 Package:SPL related
 PHP Version:5.3.15
 Block user comment: N
 Private report: N

 New Comment:

I suggest not creating a class from arbitrary strings you pick up from the 
internet . . .


Previous Comments:

[2012-08-10 07:27:50] victor dot berchet at sensiolabs dot com

As indicated in the blog post linked in the issue report, a few functions are 
affected (ie they can trigger the autoload function with an invalid class name):

- class_exists()
- interface_exists()
- class_parents()
- class_implements()
- is_subclass_of()


[2012-08-09 20:04:23] drak at zikula dot org

Description:

It is possible to invoke class autoloaders with invalid class names leading to 
potential security issues. Classes can contain alphaumeric, underscore and 
backslash characters. However, code like:

$foo = new $class

where $class might contain any arbitrary string will cause the autoloader stack 
to be called even if the $class variable contained invalid characters for a 
class name.

This could lead to various file inclusion issues as detailed in 
http://drak3.devmx.de/blog/2012/08/08/autoloaded-remote-file-inclusion/

However, it is not reasonable for classloaders to validate the class name 
passed 
to it via PHP for valid classname characters. Doing so would be an incredible 
burden on performance ever increasing with the size of the autoloader stack.

I suggest that PHP validate the characters of the class before deciding to call 
the autoloader stack or not.







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62789edit=1


Req #44392 [Com]: getFilePointer() for Childs of SplFileObject

2012-12-08 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=44392edit=1

 ID: 44392
 Comment by: le...@php.net
 Reported by:php at benjaminschulz dot com
 Summary:getFilePointer() for Childs of SplFileObject
 Status: Open
 Type:   Feature/Change Request
 Package:SPL related
 PHP Version:5.3CVS-2008-03-10 (CVS)
 Block user comment: N
 Private report: N

 New Comment:

I don't see why this method shouldn't be public. I vote for extending its 
visibility to public.


Previous Comments:

[2012-11-20 23:38:18] mattsch at gmail dot com

What's the status of this bug?  SplFileObject is supposed to be an OO version 
of fopen but it's quite useless to pass into other functions like curl when 
those functions expect a resource.

Example:

$splFileObject = new SplFileObject('/tmp/foo', 'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'sftp://server.com/folder/');
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $splFileObject); # -- won't work, must be 
file resource
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
curl_close($ch);


[2008-11-14 23:49:33] jordan dot raub at dataxltd dot com

add a protected member function to SplFileObject so that extending classes can 
have more control of the file handle... patch included against php5.2.6..


--- php-5.2.6/ext/spl/spl_directory.c   2008-02-13 04:23:26.0 -0800
+++ php52GetResource/ext/spl/spl_directory.c2008-11-14 13:22:17.0 
-0800
@@ -2218,6 +2218,15 @@
}
 } /* }}} */

+/* {{{ proto void SplFileObject::getFileResource()
+   Seek to specified line */
+SPL_METHOD(SplFileObject, getFileResource)
+{
+   spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+   php_stream_to_zval(intern-u.file.stream, return_value);
+} /* }}} */
+
 /* {{{ Function/Class/Method definitions */
 static
 ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object___construct, 0, 0, 1)
@@ -2310,6 +2319,7 @@
SPL_ME(SplFileObject, getMaxLineLen,  NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, hasChildren,NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, getChildren,NULL, ZEND_ACC_PUBLIC)
+   SPL_ME(SplFileObject, getFileResource,NULL, ZEND_ACC_PROTECTED)
SPL_ME(SplFileObject, seek,   arginfo_file_object_seek, 
 ZEND_ACC_PUBLIC)
/* mappings */
SPL_MA(SplFileObject, getCurrentLine, SplFileObject, fgets,  NULL, 
ZEND_ACC_PUBLIC)


[2008-03-10 14:45:49] php at benjaminschulz dot com

Description:

It would be nice if it would be possible to get the underlying resource handle 
of an SplFileObject to be able to add stream filters on the file. Sadly the URI 
parser in PHP seems to be broken and URIs with filters like 
php://filter/read=convert.iconv.ISO-8859-15/UTF-8/resource=... cannot be used 
(encoding the slash doesn't work either (%2F)) therefore it would be nice if 
one could access the underlying resource handle f.e. by providing a protected 
$fp in SplFileObject one could use in a child class then and do the 
stream_filter_append() there.







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=44392edit=1


Req #49369 [Com]: Change current(), key(), next(), etc. to check for Iterator

2012-12-08 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=49369edit=1

 ID: 49369
 Comment by: le...@php.net
 Reported by:admin at ifyouwantblood dot de
 Summary:Change current(), key(), next(), etc. to check for
 Iterator
 Status: Open
 Type:   Feature/Change Request
 Package:Arrays related
 Operating System:   *
 PHP Version:*
 Block user comment: N
 Private report: N

 New Comment:

Added bug #63678 as a duplicate.


Previous Comments:

[2012-11-16 04:35:52] le...@php.net

Sorry, I misunderstood the bug. Silly me.  Ignore my above comments.


[2012-11-16 04:33:26] le...@php.net

Also, calling `current($i)` gets the current value of the object `$i` which is 
the 
array; it doesn't call `$i-current`.


[2012-11-16 04:27:19] le...@php.net

I'm not sure this is a php bug.  Iterators should be rewound almost 100% of the 
time before being used, especially when using an array or an object that 
implements Iterator instead of IteratorAggregate.

Maybe the documentation should try to make this better known?


[2012-07-01 11:14:30] bugs dot php dot net dot nsp at cvogt dot org

As a further note, the current behavior or current() also leaks private fields 
unlike e.g. http://php.net/manual/en/language.oop5.iterations.php.

class Test{
  private $field = 5;
  public $field3 = 6;
}
$t = new Test;
print current($t);

Expected result:
6

Actual result:
5


[2009-08-26 10:34:05] admin at ifyouwantblood dot de

Description:

it would be helpful for chained Iterators, if the default array functions would 
check if an given object is an instanceof Iterator and react appropriate.

thus key() calling object-key(), current() calling object-current() and so on.

Reproduce code:
---
?php

class iterator_array implements Iterator
{
protected $aarray;

public function __construct($array)
{
$this-aarray=$array;
}

public function key()
{
return key($this-aarray);
}

public function current()
{
return current($this-aarray);
}

public function valid()
{
return (current($this-aarray)!==FALSE);
}

public function next()
{
next($this-aarray);
}

public function rewind()
{
reset($this-aarray);
}
}

$i=new iterator_array(Array(1,2));
var_dump(current($i));
var_dump(key($i));
next($i);
var_dump($current($i));
var_dump(key($i));

Expected result:

int(1)
int(0)
int(2)
int(1)


Actual result:
--
array(6) {
  [0]=
  int(1)
  [1]=
  int(2)
  [2]=
  int(3)
  [3]=
  int(4)
  [4]=
  int(5)
  [5]=
  int(6)
}
string(9) #65533;*#65533;aarray
bool(false)
NULL







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=49369edit=1


Bug #62460 [Com]: php binaries installed as binary.dSYM

2012-11-18 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=62460edit=1

 ID: 62460
 Comment by: le...@php.net
 Reported by:phpbugs at adam dot gs
 Summary:php binaries installed as binary.dSYM
 Status: Closed
 Type:   Bug
 Package:*Compile Issues
 Operating System:   OSX 10.8
 PHP Version:5.3.14
 Assigned To:johannes
 Block user comment: N
 Private report: N

 New Comment:

As someone who is showing up late to the party; is it safe to rename the file 
`php.dSYM` to `php` or should I apply the patch, reconfigure, recompile, etc?


Previous Comments:

[2012-08-06 03:31:39] s...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




[2012-08-06 03:28:09] s...@php.net

Automatic comment on behalf of reeze@gmail.com
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=07ee764e5709dc8d9f26382d8e7438696f5bb834
Log: Fixed bug #62460 (php binaries installed as binary.dSYM)


[2012-07-20 02:55:21] reeze dot xia at gmail dot com

Hi, 
  The new released PHP-5.3.15 still have this bug. you could use the 
distributed tar package to reproduce.
using google to search php.dSYM there are a lot of result about it.

Thanks


[2012-07-19 06:45:26] larue...@php.net

johannes, could you please look at this? 

thanks


[2012-07-19 06:32:38] reeze dot xia at gmail dot com

Hi, 
  OSX 10.9 haven't exist at all, although *nix os didn't have any extension for
executable. but I'm ok with *darwin* match too.




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

https://bugs.php.net/bug.php?id=62460


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62460edit=1


Bug #55157 [Com]: ArrayIterator::offsetUnset(); does not work correctly

2012-11-18 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=55157edit=1

 ID: 55157
 Comment by: le...@php.net
 Reported by:olav at fwt dot no
 Summary:ArrayIterator::offsetUnset(); does not work
 correctly
 Status: Assigned
 Type:   Bug
 Package:SPL related
 Operating System:   openSUSE 11.4/Debian 5
 PHP Version:Irrelevant
 Assigned To:colder
 Block user comment: N
 Private report: N

 New Comment:

It seems that calling `ArrayIterator::offsetUnset` moves the internal pointer 
to 
the next element when removing the first index:

$a = range( 0,3 );
$b = new ArrayIterator( $a );

for ($b-rewind(); $b-valid(); ) {
echo {$b-key()} = {$b-current()}\n;
$b-offsetUnset($b-key());
}

var_dump($b-getArrayCopy());


Previous Comments:

[2011-07-19 15:18:57] gergo at gergoerdosi dot com

Please ignore my comment above. The offsetUnset() method unsets elements using 
their index. Changing the code to this gives the expected result (0, 4):

$items = new ArrayObject(array(0, 1, 2, 3, 4));

foreach($items-getArrayCopy() as $item) {
if(in_array($item, array(1, 2, 3))) {
$items-offsetUnset($item);
}
}

var_dump($items-getArrayCopy());


[2011-07-19 15:09:34] gergo at gergoerdosi dot com

I have the same problem, used this code:

$items = new ArrayObject(array(1, 2, 3, 4, 5));

foreach($items as $item) {
if(in_array($item, array(2, 3, 4))) {
$items-offsetUnset($item);
}
}

var_dump($items-getArrayCopy());

Expected result: array(1, 5), actual result: array(1, 3, 5).


[2011-07-07 07:18:36] j...@php.net

Sorry, I should clarify that the code above gives:

array(1) { [1]= int(1) }

Whereas you'd probably expect:

array(0) { }


[2011-07-07 07:17:12] j...@php.net

Just to narrow the scope of the bug a bit:

$a = range( 0,9 );
$b = new ArrayIterator( $a );
 
foreach($b as $k=$v) {
$b-offsetUnset($k);
}

var_dump($b-getArrayCopy()); // why is 1 still around?


[2011-07-07 06:52:24] olav at fwt dot no

Description:

ArrayIterator always skips the second element in the array when calling 
offsetUnset(); on it while looping through.

Using the key from iterator and unsetting in the actual ArrayObject works as 
expected.

Running php 5.3.5 on openSUSE 11.4
Replicated same bug on Debian 5 running PHP 5.2.6-1+lenny9.

php5 is installed as binary on both systems, SPL is builtin package.


Test script:
---
?php

// Create a array range from 0 to 9
$a = new ArrayObject( range( 0,9 ) );
$b = new ArrayIterator( $a );
 
for ( $b-rewind(); $b-valid(); $b-next() )
{
echo #{$b-current()} - \r\n;
$b-offsetUnset( $b-key() );
}
?

Expected result:

Expected a list of from 0 to 9 echoed out.

Actual result:
--
Lists out 0 and then 2-9 leaving index 1 untouched in the original ArrayObject.







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55157edit=1


Req #49369 [Com]: Change current(), key(), next(), etc. to check for Iterator

2012-11-15 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=49369edit=1

 ID: 49369
 Comment by: le...@php.net
 Reported by:admin at ifyouwantblood dot de
 Summary:Change current(), key(), next(), etc. to check for
 Iterator
 Status: Open
 Type:   Feature/Change Request
 Package:Arrays related
 Operating System:   *
 PHP Version:*
 Block user comment: N
 Private report: N

 New Comment:

I'm not sure this is a php bug.  Iterators should be rewound almost 100% of the 
time before being used, especially when using an array or an object that 
implements Iterator instead of IteratorAggregate.

Maybe the documentation should try to make this better known?


Previous Comments:

[2012-07-01 11:14:30] bugs dot php dot net dot nsp at cvogt dot org

As a further note, the current behavior or current() also leaks private fields 
unlike e.g. http://php.net/manual/en/language.oop5.iterations.php.

class Test{
  private $field = 5;
  public $field3 = 6;
}
$t = new Test;
print current($t);

Expected result:
6

Actual result:
5


[2009-08-26 10:34:05] admin at ifyouwantblood dot de

Description:

it would be helpful for chained Iterators, if the default array functions would 
check if an given object is an instanceof Iterator and react appropriate.

thus key() calling object-key(), current() calling object-current() and so on.

Reproduce code:
---
?php

class iterator_array implements Iterator
{
protected $aarray;

public function __construct($array)
{
$this-aarray=$array;
}

public function key()
{
return key($this-aarray);
}

public function current()
{
return current($this-aarray);
}

public function valid()
{
return (current($this-aarray)!==FALSE);
}

public function next()
{
next($this-aarray);
}

public function rewind()
{
reset($this-aarray);
}
}

$i=new iterator_array(Array(1,2));
var_dump(current($i));
var_dump(key($i));
next($i);
var_dump($current($i));
var_dump(key($i));

Expected result:

int(1)
int(0)
int(2)
int(1)


Actual result:
--
array(6) {
  [0]=
  int(1)
  [1]=
  int(2)
  [2]=
  int(3)
  [3]=
  int(4)
  [4]=
  int(5)
  [5]=
  int(6)
}
string(9) #65533;*#65533;aarray
bool(false)
NULL







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=49369edit=1


Req #49369 [Com]: Change current(), key(), next(), etc. to check for Iterator

2012-11-15 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=49369edit=1

 ID: 49369
 Comment by: le...@php.net
 Reported by:admin at ifyouwantblood dot de
 Summary:Change current(), key(), next(), etc. to check for
 Iterator
 Status: Open
 Type:   Feature/Change Request
 Package:Arrays related
 Operating System:   *
 PHP Version:*
 Block user comment: N
 Private report: N

 New Comment:

Also, calling `current($i)` gets the current value of the object `$i` which is 
the 
array; it doesn't call `$i-current`.


Previous Comments:

[2012-11-16 04:27:19] le...@php.net

I'm not sure this is a php bug.  Iterators should be rewound almost 100% of the 
time before being used, especially when using an array or an object that 
implements Iterator instead of IteratorAggregate.

Maybe the documentation should try to make this better known?


[2012-07-01 11:14:30] bugs dot php dot net dot nsp at cvogt dot org

As a further note, the current behavior or current() also leaks private fields 
unlike e.g. http://php.net/manual/en/language.oop5.iterations.php.

class Test{
  private $field = 5;
  public $field3 = 6;
}
$t = new Test;
print current($t);

Expected result:
6

Actual result:
5


[2009-08-26 10:34:05] admin at ifyouwantblood dot de

Description:

it would be helpful for chained Iterators, if the default array functions would 
check if an given object is an instanceof Iterator and react appropriate.

thus key() calling object-key(), current() calling object-current() and so on.

Reproduce code:
---
?php

class iterator_array implements Iterator
{
protected $aarray;

public function __construct($array)
{
$this-aarray=$array;
}

public function key()
{
return key($this-aarray);
}

public function current()
{
return current($this-aarray);
}

public function valid()
{
return (current($this-aarray)!==FALSE);
}

public function next()
{
next($this-aarray);
}

public function rewind()
{
reset($this-aarray);
}
}

$i=new iterator_array(Array(1,2));
var_dump(current($i));
var_dump(key($i));
next($i);
var_dump($current($i));
var_dump(key($i));

Expected result:

int(1)
int(0)
int(2)
int(1)


Actual result:
--
array(6) {
  [0]=
  int(1)
  [1]=
  int(2)
  [2]=
  int(3)
  [3]=
  int(4)
  [4]=
  int(5)
  [5]=
  int(6)
}
string(9) #65533;*#65533;aarray
bool(false)
NULL







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=49369edit=1


Req #49369 [Com]: Change current(), key(), next(), etc. to check for Iterator

2012-11-15 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=49369edit=1

 ID: 49369
 Comment by: le...@php.net
 Reported by:admin at ifyouwantblood dot de
 Summary:Change current(), key(), next(), etc. to check for
 Iterator
 Status: Open
 Type:   Feature/Change Request
 Package:Arrays related
 Operating System:   *
 PHP Version:*
 Block user comment: N
 Private report: N

 New Comment:

Sorry, I misunderstood the bug. Silly me.  Ignore my above comments.


Previous Comments:

[2012-11-16 04:33:26] le...@php.net

Also, calling `current($i)` gets the current value of the object `$i` which is 
the 
array; it doesn't call `$i-current`.


[2012-11-16 04:27:19] le...@php.net

I'm not sure this is a php bug.  Iterators should be rewound almost 100% of the 
time before being used, especially when using an array or an object that 
implements Iterator instead of IteratorAggregate.

Maybe the documentation should try to make this better known?


[2012-07-01 11:14:30] bugs dot php dot net dot nsp at cvogt dot org

As a further note, the current behavior or current() also leaks private fields 
unlike e.g. http://php.net/manual/en/language.oop5.iterations.php.

class Test{
  private $field = 5;
  public $field3 = 6;
}
$t = new Test;
print current($t);

Expected result:
6

Actual result:
5


[2009-08-26 10:34:05] admin at ifyouwantblood dot de

Description:

it would be helpful for chained Iterators, if the default array functions would 
check if an given object is an instanceof Iterator and react appropriate.

thus key() calling object-key(), current() calling object-current() and so on.

Reproduce code:
---
?php

class iterator_array implements Iterator
{
protected $aarray;

public function __construct($array)
{
$this-aarray=$array;
}

public function key()
{
return key($this-aarray);
}

public function current()
{
return current($this-aarray);
}

public function valid()
{
return (current($this-aarray)!==FALSE);
}

public function next()
{
next($this-aarray);
}

public function rewind()
{
reset($this-aarray);
}
}

$i=new iterator_array(Array(1,2));
var_dump(current($i));
var_dump(key($i));
next($i);
var_dump($current($i));
var_dump(key($i));

Expected result:

int(1)
int(0)
int(2)
int(1)


Actual result:
--
array(6) {
  [0]=
  int(1)
  [1]=
  int(2)
  [2]=
  int(3)
  [3]=
  int(4)
  [4]=
  int(5)
  [5]=
  int(6)
}
string(9) #65533;*#65533;aarray
bool(false)
NULL







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=49369edit=1


[PHP-BUG] Bug #63507 [NEW]: IteratorIterator inheritance problems

2012-11-13 Thread le...@php.net
From: le...@php.net
Operating system: 
PHP version:  Irrelevant
Package:  SPL related
Bug Type: Bug
Bug description:IteratorIterator inheritance problems

Description:

IteratorIterator has a method `seek` that matches the signature for
implementing 
SeekableIterator, but it doesn't implement the interface.

Also, subclasses of IteratorIterator do not inherit the seek method. This
breaks 
the rules for inheritance.

I'm not sure how to propose fixing it at this point.  This should have been
caught 
before being released. Like much of the SPL, this was not properly thought
out and 
tested.

Test script:
---
$iterator = new IteratorIterator(
new EmptyIterator()
);

var_dump($iterator instanceof SeekableIterator);
var_dump(method_exists($iterator, 'seek');

$iterator = new NoRewindIterator(
new EmptyIterator()
);
var_dump(method_exists($iterator, 'seek');


Expected result:

bool(true);
bool(true);
bool(true);

Actual result:
--
bool(false);
bool(true);
bool(false);

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



[PHP-BUG] Req #63508 [NEW]: LimitIterator should implement SeekableIterator

2012-11-13 Thread le...@php.net
From: levim
Operating system: 
PHP version:  Irrelevant
Package:  SPL related
Bug Type: Feature/Change Request
Bug description:LimitIterator should implement SeekableIterator

Description:

LimitIterator already implements SeekableIterator; it just doesn't do so
formally.

Test script:
---
?php

$iterator = new LimitIterator(
new ArrayIterator(array(1,2,3,4))
);

var_dump($iterator instanceof SeekableIterator);
var_dump(method_exists($iterator, 'seek'));

$iterator-seek(2);
var_dump($iterator-current());

Expected result:

bool(true)
bool(true)
int(3)

Actual result:
--
bool(false)
bool(true)
int(3)

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



Req #63508 [PATCH]: LimitIterator should implement SeekableIterator

2012-11-13 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=63508edit=1

 ID: 63508
 Patch added by: le...@php.net
 Reported by:le...@php.net
 Summary:LimitIterator should implement SeekableIterator
 Status: Open
 Type:   Feature/Change Request
 Package:SPL related
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

The following patch has been added/updated:

Patch Name: LimitIterator_implement_SeekableIterator
Revision:   1352847640
URL:
https://bugs.php.net/patch-display.php?bug=63508patch=LimitIterator_implement_SeekableIteratorrevision=1352847640


Previous Comments:

[2012-11-13 23:00:18] le...@php.net

Description:

LimitIterator already implements SeekableIterator; it just doesn't do so 
formally.

Test script:
---
?php

$iterator = new LimitIterator(
new ArrayIterator(array(1,2,3,4))
);

var_dump($iterator instanceof SeekableIterator);
var_dump(method_exists($iterator, 'seek'));

$iterator-seek(2);
var_dump($iterator-current());

Expected result:

bool(true)
bool(true)
int(3)

Actual result:
--
bool(false)
bool(true)
int(3)






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63508edit=1


Req #63508 [PATCH]: LimitIterator should implement SeekableIterator

2012-11-13 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=63508edit=1

 ID: 63508
 Patch added by: le...@php.net
 Reported by:le...@php.net
 Summary:LimitIterator should implement SeekableIterator
 Status: Open
 Type:   Feature/Change Request
 Package:SPL related
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

The following patch has been added/updated:

Patch Name: LimitIterator_implement_SeekableIterator
Revision:   1352848115
URL:
https://bugs.php.net/patch-display.php?bug=63508patch=LimitIterator_implement_SeekableIteratorrevision=1352848115


Previous Comments:

[2012-11-13 23:00:40] le...@php.net

The following patch has been added/updated:

Patch Name: LimitIterator_implement_SeekableIterator
Revision:   1352847640
URL:
https://bugs.php.net/patch-display.php?bug=63508patch=LimitIterator_implement_SeekableIteratorrevision=1352847640


[2012-11-13 23:00:18] le...@php.net

Description:

LimitIterator already implements SeekableIterator; it just doesn't do so 
formally.

Test script:
---
?php

$iterator = new LimitIterator(
new ArrayIterator(array(1,2,3,4))
);

var_dump($iterator instanceof SeekableIterator);
var_dump(method_exists($iterator, 'seek'));

$iterator-seek(2);
var_dump($iterator-current());

Expected result:

bool(true)
bool(true)
int(3)

Actual result:
--
bool(false)
bool(true)
int(3)






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63508edit=1


Req #49576 [Com]: Filter var for validating email is not validating emails correctly

2012-08-16 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=49576edit=1

 ID: 49576
 Comment by: le...@php.net
 Reported by:mparkin at de-facto dot com
 Summary:Filter var for validating email is not validating
 emails correctly
 Status: Wont fix
 Type:   Feature/Change Request
 Package:*General Issues
 Operating System:   *
 PHP Version:5.*
 Assigned To:rasmus
 Block user comment: N
 Private report: N

 New Comment:

Honestly, why can't we have an option to FILTER_VALIDATE_EMAIL to not require a 
TLD?  I do write intranet applications and it would be useful. Adding an option 
does not break BC at all.


Previous Comments:

[2012-08-16 18:01:44] ras...@php.net

I am not disagreeing that local domains are invalid per the RFC, but I do think 
that in most cases Web apps probably don't have a use for these cases since 
they 
don't resolve outside of the local environment. I suppose some Intranet web 
apps 
would find this useful, but the bulk of Internet apps would need to add a 
second 
check to make sure that it wasn't a non external SMTP-able address that 
validated. I would suggest that the few cases where you do want local single-
domain addresses to validate you add a simple check in front of filter_var. 
They 
are easy to check for.


[2012-08-16 16:48:28] damien dot regad at merckgroup dot com

Going back to what grangeway posted 2 years ago, the filter still does not 
accept single-domain addresses:

php  var_export( filter_var( 'user@localhost', FILTER_VALIDATE_EMAIL ) );
false

I tested with PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) on Ubuntu 12.04

However, if I understand well the ABNF[1] in the RFC specification [2], this 
should in fact be allowed (see sections 3.4.1 and 3.2.3 for details):

addr-spec   =   local-part @ domain
domain  =   dot-atom / domain-literal / obs-domain
dot-atom=   [CFWS] dot-atom-text [CFWS]
dot-atom-text   =   1*atext *(. 1*atext)

The last bit (dot-atom-text) says that there must be 1 or more chars followed 
by zero or more groups of (. followed by 1 or more chars).

It would be nice to have this fixed. Thanks in advance !

[1] http://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_Form
[2] http://tools.ietf.org/html/rfc5322


[2010-08-17 21:34:47] michael at squiloople dot com

You might find this useful, taken directly from my article on E-mail address 
validation, in deciding whether or not to allow single-label domain names:

There is some confusion over whether or not single-label domain names are 
allowed — michael@squiloople, for example. People often cite the following 
section in RFC 5321 to argue that they are not allowed:

'Only resolvable, fully-qualified domain names (FQDNs) are permitted when 
domain names are used in SMTP. In other words, names that can be resolved to MX 
RRs or address (i.e., A or ) RRs (as discussed in Section 5) are permitted, 
as are CNAME RRs whose targets can be resolved, in turn, to MX or address RRs. 
Local nicknames or unqualified names MUST NOT be used.'

The implicit premise here is that TLD-only domain names cannot be resolved to 
MX RRs. This is simply untrue: both checkdnsrr('ai', 'MX') and getmxrr('ai', 
$array) return true, showing that single-label domain names can, and do, 
resolve 
to MX RRs. Additionally, http://www.to/ is a valid, and active, domain. 
Therefore, michael@squiloople is valid (although in this example, 
‘squiloople’ 
is not a TLD).

And as an extra note, here’s another excerpt from RFC 5321:

'In the case of a top-level domain used by itself in an email address, a 
single 
string is used without any dots.'


[2010-08-15 02:09:23] paj...@php.net

Have you tried with 5.2.14 or 5.3.3?


[2010-08-14 21:10:33] grangeway at hotmail dot com

Additionally:

1) at the moment, I believe the current regex does not allow fred@com as an 
email address. Albeit, it's going back almost 10 years now - I'm pretty sure  I 
received an email from someone @tld, complaining that a regex  did not allow 
their valid email address to sign up.

2) The issue the user hit is the phpmailer class contains the following code to 
validate email addresses against FILTER_VALIDATE_EMAIL regardless of whether 
SMTP or mail() is the sending method.

550  public static function ValidateAddress($address) {
551if (function_exists('filter_var')) { //Introduced in PHP 5.2
...
else 
 regex




The remainder of the comments for this report are too long. To view
the rest

Bug #61312 [Opn-Csd]: StdClass doesn't implement Traversable but can be traversed.

2012-03-07 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=61312edit=1

 ID: 61312
 User updated by:le...@php.net
 Reported by:le...@php.net
 Summary:StdClass doesn't implement Traversable but can be
 traversed.
-Status: Open
+Status: Closed
 Type:   Bug
 Package:Class/Object related
 PHP Version:5.4.0
 Block user comment: N
 Private report: N

 New Comment:

Not a bug, really.  All objects can be iterated. I had been up too late when I 
filed the bug.


Previous Comments:

[2012-03-07 07:44:18] le...@php.net

Description:

StdClass does not implement the Traversable interface but can be iterated over 
in  
a foreach loop.  

Test script:
---
$stdClass = new StdClass;
$stdClass-setUp = function () {
echo event[setUp] . . . \n;
};
$stdClass-tearDown = function () {
echo event[tearDown] . . . \n;
};

echo StdClass instanceof Traversable: ;
echo $stdClass instanceof Traversable
? Traversable\n
: Not traversable\n;

foreach ($stdClass as $key = $value) {
echo $key = ;
$value();
}


Expected result:

StdClass instanceof Traversable: Traversable
setUp = event[setUp] . . . 
tearDown = event[tearDown] . . .

Actual result:
--
StdClass instanceof Traversable: Not traversable
setUp = event[setUp] . . . 
tearDown = event[tearDown] . . .






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61312edit=1


[PHP-BUG] Bug #61312 [NEW]: StdClass doesn't implement Traversable but can be traversed.

2012-03-06 Thread le...@php.net
From: levim
Operating system: 
PHP version:  5.4.0
Package:  Class/Object related
Bug Type: Bug
Bug description:StdClass doesn't implement Traversable but can be traversed.

Description:

StdClass does not implement the Traversable interface but can be iterated
over in  
a foreach loop.  

Test script:
---
$stdClass = new StdClass;
$stdClass-setUp = function () {
echo event[setUp] . . . \n;
};
$stdClass-tearDown = function () {
echo event[tearDown] . . . \n;
};

echo StdClass instanceof Traversable: ;
echo $stdClass instanceof Traversable
? Traversable\n
: Not traversable\n;

foreach ($stdClass as $key = $value) {
echo $key = ;
$value();
}


Expected result:

StdClass instanceof Traversable: Traversable
setUp = event[setUp] . . . 
tearDown = event[tearDown] . . .

Actual result:
--
StdClass instanceof Traversable: Not traversable
setUp = event[setUp] . . . 
tearDown = event[tearDown] . . .

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



Bug #60816 [Com]: spl_autoload_register fails with __call magic

2012-01-19 Thread le...@php.net
Edit report at https://bugs.php.net/bug.php?id=60816edit=1

 ID: 60816
 Comment by: le...@php.net
 Reported by:dan dot lugg at gmail dot com
 Summary:spl_autoload_register fails with __call magic
 Status: Open
 Type:   Bug
 Package:SPL related
 Operating System:   Windows 7x64
 PHP Version:5.3.9
 Block user comment: N
 Private report: N

 New Comment:

This works on viper-7:  http://viper-7.com/KPlQLa


Previous Comments:

[2012-01-20 06:22:38] dan dot lugg at gmail dot com

Description:

When registering a callback object/method pair to spl_autoload_register(), if 
the 
method is not defined, though the object class has defined __call() magic, the 
method will not be called during an autoload attempt.

In a larger project, I found that the PHP executable was crashing out 
altogether, 
appending no output to the logs, and offering minimal information. When I 
isolated 
what I suspected to be the problem, it was in fact the 
spl_autoload_register()/__call() combination. In isolation, it did not crash 
out 
spectacularly as in my project, however it still failed.

While I marked this 5.3.9, these failures have been observed on 5.3.8, 5.3.9, 
and 
5.4.0.RC3.

While this is a bit of an edge case, I doubt that this is expected or 
acceptable 
behaviour, and have not been able to find mention of this elsewhere.

Test script:
---
?php

class Loader
{
public function __call($name, $arguments)
{
var_dump(get_defined_vars());
}
}

spl_autoload_register(array(new Loader(), 'load_class'));
$foo = new Bar();

Expected result:

array(2) {
  [name]=
  string(10) load_class
  [arguments]=
  array(1) {
[0]=
string(3) Bar
  }
}
Fatal error: Class 'Bar' not found in - on line 12

Actual result:
--
Fatal error: Class 'Bar' not found in - on line 12


As you can see, while this test script made no attempt to actually load the 
class, 
it should at least be dumping the array before failing, as in the expected 
output.






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60816edit=1