TDBF Posted February 25, 2023 Posted February 25, 2023 (edited) Error: Call to undefined method ReflectionUnionType::getName() (0) #0 C:\wamp64\www\invisiondev4.7dev\applications\core\modules\admin\applications\developer.php(3578): IPS\Plugin\_Hook->editForm(Object(IPS\Http\Url\Internal)) #1 C:\wamp64\www\invisiondev4.7dev\system\Dispatcher\Controller.php(107): IPS\core\modules\admin\applications\_developer->editHook() #2 C:\wamp64\www\invisiondev4.7dev\applications\core\modules\admin\applications\developer.php(69): IPS\Dispatcher\_Controller->execute('do') #3 C:\wamp64\www\invisiondev4.7dev\system\Dispatcher\Dispatcher.php(153): IPS\core\modules\admin\applications\_developer->execute() #4 C:\wamp64\www\invisiondev4.7dev\admin\index.php(13): IPS\_Dispatcher->run() #5 {main} Added a hook to extend class \IPS\Content\Controller, I get this error when trying to edit the hook from the Developer Centre. Using PHP 8.0.23 Edited February 25, 2023 by TDBF SeNioR- 1
Runar Posted June 14, 2023 Posted June 14, 2023 I’m having the same issue, and I’ve traced it to this function on line 4353 in system/Content/Controller.php: protected function sendModerationAlert( array $values, \IPS\Content\Item|\IPS\Content\Comment $content ) : \IPS\core\Alerts\Alert { } More specifically, the second argument, the union types, causes issues for the editForm function in system/Plugin/Hook.php. On line 370, the editForm function loops through parameters and tries to get their types and names: $parameters[] = ( $parameter->getType() ? ( ( ( $parameter->allowsNull() ) ? '?' : '' ). '\\' . $parameter->getType()->getName() . ' ' ) : '' ) . ( $parameter->isPassedByReference() ? '&' : '' ) . '$' . $parameter->name . ( $parameter->isOptional() ? ( '=' . var_export( $parameter->getDefaultValue(), TRUE ) ) : '' ); This works with single types, but not with union types. A single type returns a ReflectionNamedType, while union types return ReflectionUnionType, and trying to call getName() on a ReflectionUnionType will not work. I assume a simple check for ReflectionUnionType inside the try block would solve the issue. As far as I can tell, this issue affects all hooks to \IPS\Content\Controller and every class extending that class. For the record, I’m using PHP 8.1.16. TDBF 1
Daniel F Posted July 3, 2023 Posted July 3, 2023 We'll address this in v5, until then I would suggest to either just fix it manually in the IDE, or to literally just use the IDE to implement the methods. G17 Media and SeNioR- 1 1
Recommended Posts