Jump to content

Recommended Posts

Posted (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}

Could contain: Text, Chart, Plot

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 by TDBF
  • 3 months later...
Posted

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.

  • 3 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...