Edit report at http://bugs.php.net/bug.php?id=53967&edit=1
ID: 53967 Updated by: fel...@php.net Reported by: whatthejeff at gmail dot com Summary: ReflectionClass::isCloneable reports false positives -Status: Open +Status: Analyzed Type: Bug Package: Reflection related PHP Version: trunk-SVN-2011-02-09 (snap) Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2011-02-11 22:48:53] whatthejeff at gmail dot com Yeah, I actually realized ReflectionClass::isCloneable wouldn't work for SplFileObject and SplTempFileObject when I was looking at the implementation for SplFileObject. ------------------------------------------------------------------------ [2011-02-11 22:43:57] fel...@php.net SplFileObject and SplTempFileObject are exception because the way as it was coded, there is a logic behinds it to decide if it is clonable or not... ------------------------------------------------------------------------ [2011-02-09 07:47:43] sebast...@php.net I do not think that this is limited to SplFileObject. Have a look at sb@thinkpad ~ % php -r'print_r(array_filter(get_declared_classes(),function($n){$c=new ReflectionClass($n);return $c->isCloneable();}));' Array ( [0] => stdClass [3] => Closure [4] => DateTime [5] => DateTimeZone [6] => DateInterval [7] => DatePeriod [8] => LibXMLError [13] => DOMStringList [14] => DOMNameList [15] => DOMImplementationList [16] => DOMImplementationSource [17] => DOMImplementation [18] => DOMNode [19] => DOMNameSpaceNode [20] => DOMDocumentFragment [21] => DOMDocument [22] => DOMNodeList [23] => DOMNamedNodeMap [24] => DOMCharacterData [25] => DOMAttr [26] => DOMElement [27] => DOMText [28] => DOMComment [29] => DOMTypeinfo [30] => DOMUserDataHandler [31] => DOMDomError [32] => DOMErrorHandler [33] => DOMLocator [34] => DOMConfiguration [35] => DOMCdataSection [36] => DOMDocumentType [37] => DOMNotation [38] => DOMEntity [39] => DOMEntityReference [40] => DOMProcessingInstruction [41] => DOMStringExtend [42] => DOMXPath [43] => finfo [70] => EmptyIterator [72] => ArrayObject [73] => ArrayIterator [74] => RecursiveArrayIterator [75] => SplFileInfo [76] => DirectoryIterator [77] => FilesystemIterator [78] => RecursiveDirectoryIterator [79] => GlobIterator [80] => SplFileObject [81] => SplTempFileObject [82] => SplDoublyLinkedList [83] => SplQueue [84] => SplStack [86] => SplMinHeap [87] => SplMaxHeap [88] => SplPriorityQueue [89] => SplFixedArray [90] => SplObjectStorage [91] => MultipleIterator [93] => PDO [94] => PDOStatement [97] => Reflection [107] => __PHP_Incomplete_Class [108] => php_user_filter [109] => Directory [110] => SimpleXMLElement [111] => SimpleXMLIterator [112] => SoapClient [113] => SoapVar [114] => SoapServer [116] => SoapParam [117] => SoapHeader [119] => Phar [120] => PharData [121] => PharFileInfo [124] => XMLReader ) I am sure that there are more false positives in there. ------------------------------------------------------------------------ [2011-02-09 04:30:41] whatthejeff at gmail dot com Description: ------------ ReflectionClass::isCloneable returns true on some classes which are not actually cloneable. Test script: --------------- <?php $reflection = new ReflectionClass('SplFileObject'); var_dump($reflection->isCloneable()); $reflection = new ReflectionClass('SplTempFileObject'); var_dump($reflection->isCloneable()); ?> Expected result: ---------------- bool(false) bool(false) Actual result: -------------- bool(true) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53967&edit=1