WooCommerce function and class declaration stubs for static analysis.

Overview

WooCommerce Stubs

Build Status

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 directly from the source using giacocorsiglia/stubs-generator.

Requirements

  • PHP >=7.1

Installation

Require this package as a development dependency with Composer.

composer require --dev php-stubs/woocommerce-stubs

Alternatively you may download woocommerce-stubs.php directly.

Usage in PHPStan

Include all stubs in PHPStan configuration file.

parameters:
    bootstrapFiles:
        - %rootDir%/../../php-stubs/wordpress-stubs/wordpress-stubs.php
        - %rootDir%/../../php-stubs/woocommerce-stubs/woocommerce-stubs.php
        #- %rootDir%/../../php-stubs/woocommerce-stubs/woocommerce-packages-stubs.php
Comments
  • Add missing Action Scheduler stubs

    Add missing Action Scheduler stubs

    Hi there

    I spotted that the Action Scheduler classes are missing from the woocommerce-packages-stubs.php file.

    Here is a naive attempt to fix.

    Unfortunately, they not following the same directory structure than the others.

    opened by om4csaba 14
  • Installation fails

    Installation fails

    I'm trying to add the WooCommerce stubs using composer require --dev php-stubs/woocommerce-stubs but I keep getting an error

    Script PHPStan\WordPress\Composer\FixWpStubs::php73Polyfill handling the post-update-cmd event terminated with an exception
    
    Installation failed, reverting ./composer.json to its original content.
    
    
      [ErrorException]
      file_get_contents(.../vendor/giacocorsiglia/
      wordpress-stubs/wordpress-stubs.php): failed to open stream: No such file or directory
    

    Any idea why would this happen?

    opened by dingo-d 9
  • get_variation_price() and get_available_variations() not recognized

    get_variation_price() and get_available_variations() not recognized

    The functions get_available_variations and get_variation_price used when a product is variable is not recognized: "Undefined method" form intelliphpense

    opened by cristianorevil 7
  • Generate stubs for WooCommerce 6.1.0

    Generate stubs for WooCommerce 6.1.0

    Generated by extracting https://downloads.wordpress.org/plugin/woocommerce.6.1.0.zip to source/woocommerce.

    This is necessary because WooCommerce's package on Packagist is broken and not available.

    See #12

    opened by om4james 6
  • autoload_files is deprecated

    autoload_files is deprecated

    autoload_files has been deprecated since PHPSTAN 0.12.26. Please change the instructions in the README from autoload_files to bootstrapFiles as instructed in the warning below:

    > vendor/bin/phpstan analyse -c phpstan.neon
    ⚠️  You're using a deprecated config option autoload_files. ⚠️️
    
    You might not need it anymore - try removing it from your
    configuration file and run PHPStan again.
    
    If the analysis fails, there are now two distinct options
    to choose from to replace autoload_files:
    1) scanFiles - PHPStan will scan those for classes and functions
       definitions. PHPStan will not execute those files.
    2) bootstrapFiles - PHPStan will execute these files to prepare
       the PHP runtime environment for the analysis.
    
    Read more about this in PHPStan's documentation:
    https://phpstan.org/user-guide/discovering-symbols
    
     23/23 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
    
    
     [OK] No errors                                  
    
    opened by dennisameling 5
  • PHP 8.1 - Throwing deprecated warnings

    PHP 8.1 - Throwing deprecated warnings

    I'm seeing these errors when running PHPStan with WooCommerce Stubs:

    PHP Deprecated:  Optional parameter $id declared before required parameter $object is implicitly treated as a required parameter in .../vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php on line 73141
    
    opened by benjaminprojas 4
  • CouponsMovedTrait not found

    CouponsMovedTrait not found

    Hi,

    we have fatal error: Fatal error: Trait 'Automattic\WooCommerce\Internal\Admin\CouponsMovedTrait' not found in /abc/vendor/php-stubs/woocommerce-stubs/woocommerce-packages-stubs.php on line 17764

    opened by seostudio 4
  • Short functions are missing

    Short functions are missing

    Hi, great job!

    However, I've found out missing is_account_page(), is_checkout(), wc_logout_url() functions. Any ideas how to get it there?

    And one more thing, could you help me how to generate my own stubs for Timber plugin (I haven't found a way to make php-stubs-generator work?

    Thanks! Karolina

    opened by vyskoczilova 3
  • I cannot get it to work with VSCode PHP Intelephense!

    I cannot get it to work with VSCode PHP Intelephense!

    Hi,

    First of all thank you for making our life easier, the ACF stubs are working perfectly but not the WooCommerce ones the functions are not recognized at every WooCommerce function i get the Undefined function error message!

    Can you please help me with this because it's been months that i am trying to fix it but i cannot find any solution for it!

    Thanks and Regards!

    opened by bgrrota 2
  • Why 4.7 releases are missing

    Why 4.7 releases are missing

    Could not scan for classes inside "./wp-content/plugins/woocommerce/vendor/league/container" which does not appear to be a file nor a folder

    https://github.com/woocommerce/woocommerce/issues/28399#issuecomment-733646231 👀

    opened by szepeviktor 2
Making multiple identical function calls has the same effect as making a single function call.

Making multiple identical function calls has the same effect as making a single function call.

李铭昕 4 Oct 16, 2021
Beautiful and understandable static analysis tool for PHP

PhpMetrics PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report. Documentation | Twitter | Contributing

PhpMetrics 2.3k Jan 5, 2023
The SensioLabs DeprecationDetector runs a static code analysis against your project's source code to find usages of deprecated methods, classes and interfaces

SensioLabs DeprecationDetector CAUTION: This package is abandoned and will no longer receive any updates. The SensioLabs DeprecationDetector runs a st

QOSSMIC GmbH 389 Nov 24, 2022
Find undefined and unused variables with the PHP Codesniffer static analysis tool.

PHP_CodeSniffer VariableAnalysis Plugin for PHP_CodeSniffer static analysis tool that adds analysis of problematic variable use. Warns if variables ar

Payton Swick 116 Dec 14, 2022
Docker image that provides static analysis tools for PHP

Static Analysis Tools for PHP Docker image providing static analysis tools for PHP. The list of available tools and the installer are actually managed

Jakub Zalas 1.1k Jan 1, 2023
A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

Felix Becker 1.1k Jan 4, 2023
Dockerise Symfony Application (Symfony 6 + Clean Architecture+ DDD+ CQRS + Docker + Xdebug + PHPUnit + Doctrine ORM + JWT Auth + Static analysis)

Symfony Dockerise Symfony Application Install Docker Install Docker Compose Docker PHP & Nginx Create Symfony Application Debugging Install Xdebug Con

null 48 Jan 5, 2023
Attributes to define PHP language extensions (to be enforced by static analysis)

PHP Language Extensions (currently in BETA) This library provides attributes for extending the PHP language (e.g. adding package visibility). The inte

Dave Liddament 70 Dec 19, 2022
Perform static analysis of Drupal PHP code with phpstan-drupal.

Perform static analysis of Drupal PHP code with PHPStan and PHPStan-Drupal on Drupal using PHP 8. For example: docker run --rm \ -v $(pwd)/example01

Dcycle 0 Dec 10, 2021
PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.

forceutf8 PHP Class Encoding featuring popular \ForceUTF8\Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strin

Sebastián Grignoli 1.6k Dec 22, 2022
Generate stubs for any PHP extension.

php-ext-stubs-generator Installation Run $ composer require --dev lctrs/php-ext-stubs-generator Usage $ php vendor/bin/generate-stubs-for-ext extensio

null 5 Dec 14, 2022
Exploiting and fixing security vulnerabilities of an old version of E-Class. Project implemented as part of the class YS13 Cyber-Security.

Open eClass 2.3 Development of XSS, CSRF, SQLi, RFI attacks/defences of an older,vulnerable version of eclass. Project implemented as part of the clas

Aristi_Papastavrou 11 Apr 23, 2022
Stores the customer_user for WooCommerce orders and subscriptions in the post_author column of posts table.

Post Author Optimization for WooCommerce Requires PHP: 7.0 WP requires at least: 5.7 WP tested up to: 5.7 WC requires at least: 5.6.0 WC tested up to:

Devin Price 9 Apr 2, 2022
Boostimer - Product Availability Countdown And Scheduler For Woocommerce

Boostimer - Product Availability Countdown And Scheduler For Woocommerce Contributors: zabiranik Donate link: zabiranik/donate Requires at least: 5.0

Zabir Anik 6 Oct 10, 2022
Custom code snippets and examples for SkyVerge-built WooCommerce extensions

SkyVerge WooCommerce Plugins Welcome to the wc-plugins-snippets repository! This repository stores code snippets related to SkyVerge WooCommerce plugi

SkyVerge 255 Nov 16, 2022
vPOS Official Wordpres WooCommerce Plugin

vPOS - WooCommerce The number #1 payment solution in Angola This plugin currently works for the solutions listed below: EMIS GPO (Multicaixa Express)

vPOS 7 Jun 13, 2022
A simple plugin to override all woocommerce templates

A simple plugin to override all woocommerce templates

null 10 Nov 16, 2021
Adds factory functions for WooCommerce to be used with wp-browser integration tests.

wp-browser-woocommerce This library simplifies testing of WooCommerce themes and plugins with wp-browser. Several Unit Test Factories are added that a

Level Level 12 Dec 29, 2022
A payment gateway plugin for WooCommerce to see if your checkout works.

=== Order Test For All for WooCommerce === Contributors: ikamal Donate link: https://kamal.pw/ Tags: wc order test, wc order, woocommerce, woocommerce

Kamal 3 Dec 7, 2021