Wrong @params for RankMath\Metadata constructor

#384905
  • Resolved Dovid Levine
    Rank Math free

    Hey again,

    Getting phpstan errors when using RankMath\Metadata types in my plugin.

    The issue is because both protected $object, and public function __construct( $object ), are looking for RankMath\WP_Post|RankMath\WP_User|...

    To refer to the actual WP_ objects, they need to be slashed:

    e.g.
    `php
    /**
    * Holds the object.
    *
    * @var \WP_Post|\WP_Term|\WP_User
    */
    protected $object = null;
    `

    and
    `php
    /**
    * Constructor.
    *
    * @param \WP_Post|\WP_Term|\WP_User $object Current object.
    */
    public function __construct( $object ) {
    $this->object = $object;
    }

    Best,

    David

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    We have shared this with our developers and an issue has been created in our repository to update these instances in our plugin.

    ​​​​​​Thank you for the continuous feedback.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Wrong @params for RankMath\Metadata constructor’ is closed to new replies.