php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75242 RecursiveArrayIterator doesn't have constants from parent class
Submitted: 2017-09-21 21:07 UTC Modified: -
From: kukulich at kukulich dot cz Assigned:
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2017-09-21 21:07 UTC] kukulich at kukulich dot cz
Description:
------------
RecursiveArrayIterator doesn't have constants from parent class

See https://3v4l.org/7fVc4

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

class Foo extends \ArrayIterator
{
    
}

$fooReflection = new \ReflectionClass(\Foo::class);
$recursiveArrayIteratorReflection = new \ReflectionClass(\RecursiveArrayIterator::class);

printf("%d constants in %s, ", count($fooReflection->getConstants()), \Foo::class);
if ($fooReflection->getParentClass()) {
    printf("%s extends %s\n", Foo::class, $fooReflection->getParentClass()->getName());
}
printf("%d constants in %s, ", count($recursiveArrayIteratorReflection->getConstants()), \RecursiveArrayIterator::class);
if ($recursiveArrayIteratorReflection->getParentClass()) {
    printf("%s extends %s\n", \RecursiveArrayIterator::class, $recursiveArrayIteratorReflection->getParentClass()->getName());
}
printf("%d constants in %s\n", count((new \ReflectionClass(\ArrayIterator::class))->getConstants()), \ArrayIterator::class);

Expected result:
----------------
2 constants in Foo, Foo extends ArrayIterator
3 constants in RecursiveArrayIterator, RecursiveArrayIterator extends ArrayIterator
2 constants in ArrayIterator

Actual result:
--------------
2 constants in Foo, Foo extends ArrayIterator
1 constants in RecursiveArrayIterator, RecursiveArrayIterator extends ArrayIterator
2 constants in ArrayIterator

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-22 17:12 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ec142f2c86c28b970aef631a5750f6a02b954089
Log: Fixed bug #75242
 [2017-12-22 17:12 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC