mralaminahamed / easycommerce-stubs
EasyCommerce function and class declaration stubs for static analysis.
Package info
github.com/mralaminahamed/phpstan-easycommerce-stubs
Language:Shell
pkg:composer/mralaminahamed/easycommerce-stubs
Requires
- php: >=7.4
- php-stubs/wordpress-stubs: ^5.3 || ^6.0 || ^7.0
Requires (Dev)
- php-stubs/generator: ^0.9.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^9.5 || ^10.5 || ^11.0
- squizlabs/php_codesniffer: ^3.13
Suggests
- symfony/polyfill-php73: Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
- szepeviktor/phpstan-wordpress: WordPress extensions for PHPStan
README
PHP stub declarations for the EasyCommerce plugin, for IDE completion and static analysis. Generated with php-stubs/generator directly from the plugin source.
Generated from EasyCommerce 1.47 โ 115 classes ยท 10 traits ยท 128 functions ยท 7 constants.
๐ Features
- Complete class, interface, trait and function declarations
- Constants in a separate file, so PHPStan can scan them rather than analyse them
- IDE autocompletion for a plugin that is not a Composer dependency
- Reproducible: the source is downloaded from WordPress.org, never vendored
๐ Requirements
- PHP >= 7.4
- Composer
๐ฆ Installation
composer require --dev mralaminahamed/easycommerce-stubs
Or download the stub files directly:
๐ง Configuration
Add both files to PHPStan. scanFiles rather than bootstrapFiles: the stubs declare
symbols for analysis, they are not meant to be executed.
parameters: scanFiles: - vendor/mralaminahamed/easycommerce-stubs/easycommerce-stubs.stub - vendor/mralaminahamed/easycommerce-stubs/easycommerce-constants-stubs.stub
For IDE completion, point your IDE at the same files โ in PhpStorm, mark them as an Include Path rather than a source root, so the empty method bodies never shadow the real plugin.
๐ Quick usage example
<?php if ( defined( 'EASYCOMMERCE_VERSION' ) ) { // Your implementation }
โ ๏ธ Limitations
- Stubs are a snapshot. They describe EasyCommerce 1.47. Regenerate when the plugin changes a signature, or pin the stub version alongside the plugin version you support.
- Method bodies are empty by design. PHPStan reads declarations and types; it never needs the implementation. Do not load these files at runtime.
- Only top-level constants are captured. All seven of its top-level constants are captured. A constant defined inside a
function or method is invisible to any stub generator; declare those in your own
bootstrapFiles, or list them under PHPStan'sdynamicConstantNames.
๐ Regenerating
composer install composer generate # reads source/easycommerce, writes both .stub files composer release # tag a new version for each untagged upstream release
bin/generate.sh expects the plugin unpacked at source/easycommerce; bin/release-latest-versions.sh
downloads each version from WordPress.org and tags it. Sources are gitignored โ the repository
carries stubs, not a copy of the plugin.
The finder reads app/. Assets, templates, language files and vendor/ are excluded:
they declare nothing a consumer calls, and vendored packages ship their own stubs.
๐ Package structure
phpstan-easycommerce-stubs/
โโโ bin/ # generate.sh, release scripts
โโโ configs/ # finder.php (what to read), bootstrap.php (WP constants)
โโโ source/ # plugin source, gitignored
โโโ tests/ # smoke tests over the generated stubs
โโโ easycommerce-stubs.stub # classes, interfaces, traits, functions
โโโ easycommerce-constants-stubs.stub # constants only
โโโ phpstan.neon # analyses the stubs themselves
๐ License
The tooling in this repository is MIT. The generated stubs are derived from EasyCommerce, which is GPL-licensed; using them for static analysis is fair use of the declarations, but redistributing them as your own product is not. See LICENSE.