Skip to content

Add @method PHPDocs for the message wrapped functions handled in __call #86

Description

@caricare2

While cleaning up our codebase, we noticed a lot of warnings from PHPStan such as this:

Call to an undefined method Maknz\Slack\Message::send().                         
         method.notFound        

This appears to be a side effect of the magic wrapping of various methods through __call to getOrCreateMessage and then return $this. For example code like this causes warnings because it doesn't recognize the methods that are chained:

        $this->client->to($slackChannel)->attach([
            'title' => $slackTitle,
            'text'       => $slackMessage,
            'color'      => 'danger'
        ])->send($slackTitle);

Adding PHPDocs to the Client class for the more common methods to hint that these methods exist would help, such as this:

/**
 * @method self to(string $channel)
 * @method self attach(mixed $attachment)
 */

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions