Skip to content

Conversation

troy-rudolph
Copy link
Contributor

@troy-rudolph troy-rudolph commented May 13, 2025

A previous PR set the return type of Actor::__call() to 'never'. This means that any classes that inherit from Actor must also declare __call() with return type 'never'. Any "tester" classes that use __call() to delegate or proxy other services will fail. Additionally, the PHP documentation specifies a return type of 'mixed" for __call(). See https://www.php.net/manual/en/language.oop5.overloading.php#object.call.

Thank you for accepting this PR.

Example of our usage ...

   /**
     * Defer unhandled methods to the current page
     */
    public function __call($method, $args)
    {
        // get the current page class name.
        // via Reflection, locate the method to be called
        // via Reflection, invoke it so it can receive a standard argument list
        try {
            $currentPage = $this->getCurrentPage();
            $cl = new ReflectionClass($currentPage);
            $meth = $cl->getMethod($method);
            return $meth->invokeArgs($currentPage, $args);
        } catch (ReflectionException $e) {
            $msg = "Method $method does not exist in class '" . self::class . "'";
            if (isset($cl)) {
                $msg = $msg . ", or in class '" . $cl->getName() . "'";
            } else {
                $msg = $msg . "; There is NO current page object to use to attempt execution.";
            }
            throw new Exception($msg, null, $e);
        }
    }

@TavoNiievez TavoNiievez merged commit d702f93 into Codeception:main May 13, 2025
8 checks passed
@TavoNiievez
Copy link
Member

Released as 5.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return type 'never' on Actor::__call() causes our entire test framework to stop working.
2 participants