phalcon/cphalcon · error · Phalcon\Di\Exceptions\SetterParametersMustBeArray

Setter injection parameters must be an array

Error message

Setter injection parameters must be an array

What it means

Thrown by Builder::build when the definition's 'calls' key is present but not an array. The 'calls' entry drives setter injection and must be a list of method-call arrays. Pass an array of call definitions, e.g. [['method'=>'setName','arguments'=>[...]]].

Solutions

  1. Make 'calls' an array, e.g. [['method' => 'setCache', 'arguments' => [...]]]
  2. Remove the 'calls' key if no setter injection is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Di/Service/Builder.zep:91 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/a20e3a051fc4e054. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Di/Service/Builder.zep:91

                let instance = create_instance_params(
                    className,
                    this->buildParameters(container, arguments)
                );
            } else {
                let instance = create_instance(className);
            }
        }

        /**
         * The definition has calls?
         */
        if fetch paramCalls, definition["calls"] {
            if unlikely typeof instance !== "object" {
                throw new SetterInjectionRequiresInstance();
            }

            if unlikely typeof paramCalls != "array" {
                throw new SetterParametersMustBeArray();
            }

            /**
             * The method call has parameters
             */
            for methodPosition, method in paramCalls {
                /**
                 * The call parameter must be an array of arrays
                 */
                if unlikely typeof method != "array" {
                    throw new MethodCallMustBeArray(methodPosition);
                }

                /**
                 * A param 'method' is required
                 */
                if unlikely !fetch methodName, method["method"] {
                    throw new MethodNameRequired(methodPosition);

View on GitHub (pinned to b7419de9cd)