mralaminahamed/easycommerce-stubs

EasyCommerce function and class declaration stubs for static analysis.

Maintainers

Package info

github.com/mralaminahamed/phpstan-easycommerce-stubs

Language:Shell

pkg:composer/mralaminahamed/easycommerce-stubs

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.47.1 2026-07-31 12:54 UTC

This package is auto-updated.

Last update: 2026-07-31 12:55:47 UTC


README

Latest Version Downloads License PHP Version

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's dynamicConstantNames.

๐Ÿ”„ 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.