{"record":{"id":"def4da64fac4457c","repo":"octobercms/october","slug":"getdependencies-must-return-an-array-s","errorCode":null,"errorMessage":"getDependencies() must return an array: %s","messagePattern":"getDependencies\\(\\) must return an array: (.+?)","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/traits/VueMaker.php","lineNumber":50,"sourceCode":"    protected $vueComponentClasses = [];\n\n    /**\n     * registerVueComponent to be loaded when the action view renders.\n     * @param string $className\n     */\n    public function registerVueComponent($className)\n    {\n        if ($this->isVueComponentRegistered($className)) {\n            return;\n        }\n\n        $component = $this->makeVueComponent($className);\n        $this->vueComponents[] = $component;\n        $this->vueComponentClasses[$className] = true;\n\n        $requiredComponents = $component->getDependencies();\n        if (!is_array($requiredComponents)) {\n            throw new SystemException(sprintf('getDependencies() must return an array: %s', $className));\n        }\n\n        foreach ($requiredComponents as $className) {\n            if (!$this->isVueComponentRegistered($className)) {\n                $this->registerVueComponent($className);\n            }\n        }\n    }\n\n    /**\n     * outputVueComponentTemplates outputs templates and ESM component registration.\n     * This method:\n     * 1. Renders text/template scripts for each component\n     * 2. Imports ESM modules and registers them as Vue components with template injection\n     */\n    public function outputVueComponentTemplates()\n    {\n        $registrations = $this->getVueComponentRegistrations();","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/traits/VueMaker.php#L32-L68","documentation":"VueMaker::registerVueComponent() asks each registered Vue component for its dependency components via getDependencies() and requires the result to be a PHP array before recursing. If a component overrides getDependencies() and returns null, a string, or any non-array, registration aborts with this SystemException naming the offending class. The base VueComponentBase returns an array, so only a bad override triggers it.","triggerScenarios":"Calling $this->registerVueComponent('...') (or booting a controller that registers Vue components) where the component's getDependencies() returns null or a non-array — e.g. an override with a conditional return but no final `return [];`, or a dependency property that was never initialized.","commonSituations":"Dependency-ordering overrides that forget the default branch; returning a config value that is sometimes null; refactoring away from a method that always returned an array.","solutions":["Make getDependencies() always return an array — add `return [];` as the final statement.","Normalize external values: `return is_array($deps) ? $deps : [];` when dependencies come from config.","Check for early returns in the override that skip returning a value."],"exampleFix":"// before\npublic function getDependencies()\n{\n    if ($this->advanced) {\n        return [ChartComponent::class];\n    }\n}\n\n// after\npublic function getDependencies()\n{\n    if ($this->advanced) {\n        return [ChartComponent::class];\n    }\n\n    return [];\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Inside your Vue component, normalize before returning\npublic function getDependencies()\n{\n    $deps = $this->calculateDependencies(); // may be null on edge paths\n\n    return is_array($deps) ? $deps : [];\n}","tryCatchPattern":null,"preventionTips":["End every getDependencies() override with `return [];`","Unit-test getDependencies() on every component registered by the controller"],"tags":["vue-component","php","return-type","dependencies"],"backgroundTag":"invalid-return-type","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}