Skip to content

PHPStan: Call to an undefined method Slince\Shopify\Client::methodName() #130

@FilipCZ

Description

@FilipCZ

Hello, in several classes as part of the project, after testing (PHPStan level 2), I'm encountering errors of the type Slince\Shopify\Client::methodName(). Could you please advise me on how to resolve these issues? Thank you.

<?php

namespace App\Providers\Shopify;

use Slince\Shopify\Exception\ClientException;

class BlogProvider extends ShopifyProvider
{
    public function __construct(...)
    {
        ...
        parent::__construct();
    }

    /**
     * @param int $id
     * @return array
     */
    public function push(int $id): array
    {
        try {
            // getArticleManager() declared in Client.php (https://github.com/slince/shopify-api-php/blob/3.x/src/Client.php)
	    $this->getClient($id)->getArticleManager()->update(); // PHPStan throws error here: Call to an undefined method Slince\Shopify\Client::getArticleManager().
            return ['result' => true];

        } catch (ClientException $exception) {
            ...
        }
    }
}

?>
<?php

namespace App\Providers\Shopify;

...
use Slince\Shopify\Client;
use Slince\Shopify\PublicAppCredential;

class ShopifyProvider
{

	public function __construct(...)
	{
		...
	}

    /**
     * @param int $clientId
     * @return \Slince\Shopify\Client
     */
    public function getClient(int $clientId): Client {
        ...

        return new Client($baseUrl, $credential, [
            'meta_cache_dir' => __DIR__,
            'api_version' => '2023-04',
        ]);
    }
}

?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions