|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2006-12-19 14:40 UTC] thekid@php.net
  [2006-12-19 14:44 UTC] thekid@php.net
  [2006-12-19 15:13 UTC] thekid@php.net
  [2006-12-19 17:03 UTC] thekid@php.net
  [2006-12-22 15:39 UTC] iliaa@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 07:00:01 2025 UTC | 
Description: ------------ The ReflectionParameter::getClass() method does not work properly if the reflected parameter uses "self" as type hint. Instead, a ReflectionException is thrown saying that the class "self" does not exist. Tested with 5.2 and 6.0.0-dev from Nov 22. Reproduce code: --------------- <?php class stubParamTest { function paramTest(self $param) { // nothing to do } } $test1 = new stubParamTest(); $test2 = new stubParamTest(); $test1->paramTest($test2); $refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param'); var_dump($refParam->getClass()); ?> Expected result: ---------------- object(ReflectionClass)[4] public 'name' => 'stubParamTest' (length=13) Actual result: -------------- Fatal error: Uncaught exception 'ReflectionException' with message 'Class self does not exist' in C:\apachefriends\xampp1.5.3a\xampp\htdocs\tests\type_hint_self.php:13 Stack trace: #0 C:\apachefriends\xampp1.5.3a\xampp\htdocs\tests\type_hint_self.php(13): ReflectionParameter->getClass() #1 {main} thrown in C:\apachefriends\xampp1.5.3a\xampp\htdocs\tests\type_hint_self.php on line 13