--TEST-- Bug #39884 (ReflectionParameter::getClass() throws exception for type hint self) --FILE-- getClass()->getName(); } // OK class A { function ax(self $a) { } } // OK class B extends A { function bx(parent $b) { } } // Broken (C has no parent class) class C { function cx(parent $c) { } } // Broken (dx is a global function, self does not make sense) function dx(self $d) { } // Broken (dx is a global function, parent does not make sens) function ex(parent $e) { } var_dump(parameterClassName(array('A', 'ax'), 0)); var_dump(parameterClassName(array('B', 'bx'), 0)); try { parameterClassName(array('C', 'cx'), 0); exit('C::cx(0) - Expected exception not thrown'); } catch (ReflectionException $e) { echo $e->getMessage(), "\n"; } try { parameterClassName('dx', 0); exit('
::dx(0) - Expected exception not thrown'); } catch (ReflectionException $e) { echo $e->getMessage(), "\n"; } try { parameterClassName('ex', 0); exit('
::ex(0) - Expected exception not thrown'); } catch (ReflectionException $e) { echo $e->getMessage(), "\n"; } ?> --EXPECTF-- string(1) "A" string(1) "A" Parameter uses 'parent' as type hint although class does not have a parent! Parameter uses 'self' as type hint but function is not a class member! Parameter uses 'parent' as type hint but function is not a class member! --UEXPECTF-- unicode(1) "A" unicode(1) "A" Parameter uses 'parent' as type hint although class does not have a parent! Parameter uses 'self' as type hint but function is not a class member! Parameter uses 'parent' as type hint but function is not a class member!