phalcon/cphalcon · error · Phalcon\Acl\Exceptions\ParameterTypeMismatch

Your passed parameter does not have the same class as the pa

Error message

Your passed parameter does not have the same class as the parameter in defined function when checking if {roleName} can {access} {componentName}. Class passed: {passedClass} , Class in defined function: {expectedClass}.

What it means

After reading a reply line, BeanstalkConnection compares it against beanstalkd protocol error responses; 'UNKNOWN_COMMAND' means the server did not recognize the command verb the client sent. Phalcon's client speaks the beanstalkd 1.2 protocol subset, so this appears with servers implementing a different protocol version, a non-beanstalkd service on that port, or a desynced stream where a previous reply is misread as the command response.

Source

Thrown at phalcon/Acl/Adapter/Memory.zep:1034

                    reflectionClass->isInstance(componentObject) &&
                    !hasComponent
                ) {
                    let hasComponent            = true,
                        parametersForFunction[] = componentObject;
                    let userParametersSizeShouldBe--;

                    continue;
                }

                /**
                 * This is some user defined class, check if his parameter
                 * is instance of it
                 */
                if unlikely (isset(parameters[parameterToCheck]) &&
                    is_object(parameters[parameterToCheck]) &&
                    !reflectionClass->isInstance(parameters[parameterToCheck])
                ) {
                    throw new ParameterTypeMismatch(
                        "Your passed parameter does not have the " .
                        "same class as the parameter in defined function " .
                        "when checking if " . roleName . " can " . access .
                        " " . componentName . ". Class passed: " .
                        get_class(parameters[parameterToCheck]) .
                        " , Class in defined function: " .
                        reflectionClass->getName() . "."
                    );
                }
            }

            if isset parameters[parameterToCheck] {
                /**
                 * We can't check type of ReflectionParameter in PHP 5.x so
                 * we just add it as it is
                 */
                let parametersForFunction[] = parameters[parameterToCheck];
            }

View on GitHub (pinned to b7419de9cd)

Solutions

  1. Confirm the target is real beanstalkd 1.2+: printf "stats\r\n" | nc <host> 11300 should return a stats body.
  2. Recreate the connection (disconnect then connect) — desynced streams produce bogus replies.
  3. Upgrade or replace the server with a standard beanstalkd build.
  4. Double-check host/port configuration for typos that point at a different service.

Example fix

// before
$connection = new BeanstalkConnection('127.0.0.1', 11300); // another service on 11300

// after
// verify the endpoint speaks the beanstalk 1.2 protocol:
// $ printf "stats\r\n" | nc 127.0.0.1 11300
$connection = new BeanstalkConnection('127.0.0.1', 11300);
try {
    $connection->connect();
} catch (\Phalcon\Queue\Exceptions\Exception $e) {
    $connection->disconnect(); // drop desynced state
    $connection->connect();
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    $stats = $connection->getTubeStats($tube);
} catch (\Phalcon\Queue\Exceptions\Exception $e) {
    if (in_array($e->getMessage(), ['UNKNOWN_COMMAND', 'BAD_FORMAT'], true)) {
        $connection->disconnect();
        $connection->connect(); // reset possibly desynced protocol state
        $stats = $connection->getTubeStats($tube);
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Connecting to a service that is not beanstalkd or a pre-1.2 fork missing commands the client uses; reading from a connection desynced by an earlier timeout/aborted read; proxies that rewrite the text protocol.

Common situations: Port 11300 pointing at another text-protocol service (typo'd port); exotic beanstalkd forks in legacy stacks; state corruption after network errors on persistent connections.

Related errors


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