FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue 6857: Upddate Actor::__call() to have return type 'mixed' by troy-rudolph · Pull Request #6858 · Codeception/Codeception · GitHub

Issue 6857: Upddate Actor::__call() to have return type 'mixed' - #6858

Merged
TavoNiievez merged 1 commit into
Codeception:mainfrom
troy-rudolph:issue_6857
May 13, 2025
Merged

Issue 6857: Upddate Actor::__call() to have return type 'mixed'#6858
TavoNiievez merged 1 commit into
Codeception:mainfrom
troy-rudolph:issue_6857

Conversation

troy-rudolph commented May 13, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

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 merged commit d702f93 into Codeception:main May 13, 2025

Copy link
Copy Markdown
Member

Released as 5.3.1

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL