Argument 1 passed to pluginSplit() must be of the type string, array given

I'm currently attempting a migration from 3.10.2 to 4.0. I've gone through the guide and I'm now trying to fix issues as they come up.

I'm finding this one rather cryptic.

Argument 1 passed to pluginSplit() must be of the type string, array given, called in C:\path\to\app\vendor\cakephp\cakephp\src\Core\ObjectRegistry.php on line 300

I suspect it's related to loading plugins. I'm not finding any references to my own files in the stack trace:

Error in: ROOT\vendor\cakephp\cakephp\src\Core\functions.php, line 89

pluginSplit
CORE\src\Core\ObjectRegistry.php:300
Cake\Core\ObjectRegistry->normalizeArray
CORE\src\View\View.php:1091
Cake\View\View->loadHelpers
CORE\src\View\View.php:350
Cake\View\View->__construct
CORE\src\View\ViewBuilder.php:556
Cake\View\ViewBuilder->build
CORE\src\View\ViewVarsTrait.php:74
Cake\Controller\Controller->createView
CORE\src\Controller\Controller.php:687
Cake\Controller\Controller->render
CORE\src\Controller\Controller.php:530
Cake\Controller\Controller->invokeAction
CORE\src\Controller\ControllerFactory.php:79
Cake\Controller\ControllerFactory->invoke
CORE\src\Http\BaseApplication.php:229
Cake\Http\BaseApplication->handle
CORE\src\Http\Runner.php:77
Cake\Http\Runner->handle
CORE\src\Http\Runner.php:77
Cake\Http\Runner->handle
CORE\src\Http\Middleware\CsrfProtectionMiddleware.php:128
Cake\Http\Middleware\CsrfProtectionMiddleware->process
CORE\src\Http\Runner.php:73
Cake\Http\Runner->handle
CORE\src\Http\Runner.php:58
Cake\Http\Runner->run
CORE\src\Routing\Middleware\RoutingMiddleware.php:166
Cake\Routing\Middleware\RoutingMiddleware->process
CORE\src\Http\Runner.php:73
Cake\Http\Runner->handle
CORE\src\Routing\Middleware\AssetMiddleware.php:68
Cake\Routing\Middleware\AssetMiddleware->process
CORE\src\Http\Runner.php:73
Cake\Http\Runner->handle
CORE\src\Error\Middleware\ErrorHandlerMiddleware.php:119
Cake\Error\Middleware\ErrorHandlerMiddleware->process
CORE\src\Http\Runner.php:73
Cake\Http\Runner->handle
CORE\src\Http\Runner.php:58
Cake\Http\Runner->run
CORE\src\Http\Server.php:90
Cake\Http\Server->run
ROOT\webroot\index.php:40

Edit #1

It's failing on the 3rd line:

$this->loadComponent("WetKit.WetKit");
$this->viewBuilder()->setHelpers(['WetKit.Wet']);
$this->viewBuilder()->setHelpers(['Form', ['templates' => 'WetKit.wet_form']]);
$this->viewBuilder()->setTheme('WetKit');

Solution 1:

The way you define the options for the helper is wrong, it must be defined as the value for an array key, not as a separate array entry, otherwise that array is being passed into the logic that parses the helper name, resulting in the error that you're seeing.

Long story short:

$this->viewBuilder()->setHelpers([
    'Form' => [
        'templates' => 'WetKit.wet_form'
    ],
]);

I feel like there's some documentation missing for how to set/add helpers with configuration. You might want to open an issue for that over at GitHub.