szepeviktor / phpstan-wordpress

WordPress extensions for PHPStan ⛏️
https://packagist.org/packages/szepeviktor/phpstan-wordpress
MIT License
262 stars 26 forks source link

[FEATURE] Support dynamic property for \wpdb #215

Closed dimitriBouteille closed 5 months ago

dimitriBouteille commented 6 months ago

Is it possible to add dynamic properties support for the \wpdb class?

This class contain magic method __get :

    /**
     * Makes private properties readable for backward compatibility.
     *
     * @since 3.5.0
     *
     * @param string $name The private member to get, and optionally process.
     * @return mixed The private member.
     */
    public function __get( $name ) {
        if ( 'col_info' === $name ) {
            $this->load_col_info();
        }

        return $this->$name;
    }
szepeviktor commented 6 months ago

Hello Dimitri 👋🏻

You can add it in a stubs file. Just copy it from WP core stubs.

szepeviktor commented 6 months ago

But be aware!!

for backward compatibility