Skip to content

tectalic/woocommerce-stubs

 
 

Repository files navigation

WooCommerce Stubs

Based on the php-stubs/woocommerce-stubs package. Thanks @szepeviktor!

This package provides stub declarations for WooCommerce functions, classes, and interfaces. These stubs can help plugin and theme developers leverage static analysis tools like PHPStan, which is not able to parse WooCommerce as it is not clean OOP code.

Stubs are generated from the woocommerce-dist repo using php-stubs/generator.

Dev Requirements

  • PHP ^8.0

Installation

Require this package as a development dependency with Composer.

composer require --dev tectalic/woocommerce-stubs

Alternatively, you may download the woocommerce-stubs.php and woocommerce-packages-stubs.php files directly.

Usage in PHPStan

Make PHPStan find it automatically using phpstan/extension-installer.

composer require --dev phpstan/extension-installer

Or manually include it in your phpstan.neon.

parameters:
    bootstrapFiles:
        - vendor/tectalic/woocommerce-stubs/woocommerce-stubs.php
        # Optionally
        - vendor/tectalic/woocommerce-stubs/woocommerce-packages-stubs.php

Generate new version

  1. Make sure the new version has already been added to the woocommerce-dist repo.
  2. Update Private Packagist if needed.
  3. Run the ./generate.sh script with the new version, e.g., ./generate.sh 7.0.0-beta.1.
  4. Update Private Packagist so it shows the newly generated version.

Packages

No packages published

Languages

  • PHP 100.0%