mralaminahamed / divi-theme-stubs
Divi theme function and class declaration stubs for static analysis and IDE completion.
Package info
github.com/mralaminahamed/phpstan-divi-theme-stubs
Language:Shell
pkg:composer/mralaminahamed/divi-theme-stubs
Fund package maintenance!
Requires
- php: >=7.4
- php-stubs/wordpress-stubs: ^5.3 || ^6.0
Requires (Dev)
- php-stubs/generator: ^0.8.0
- phpstan/phpstan: ^1.10
- szepeviktor/phpstan-wordpress: ^1.3
Suggests
- phpstan/extension-installer: For easier PHPStan extensions installation
- symfony/polyfill-php74: Symfony polyfill backporting some PHP 7.4+ features to lower PHP versions
- szepeviktor/phpstan-wordpress: WordPress extensions for PHPStan
README
PHP stub declarations for the Divi Theme to enhance IDE completion and static analysis capabilities. Generated using php-stubs/generator directly from the source code.
🚀 Features
- Complete function, class, and interface declarations
- Constant definitions for proper static analysis
- IDE autocompletion support
- PHPStan integration
- Regular updates with latest Divi theme versions
- Excludes unnecessary files (widgets, WooCommerce integrations, etc.)
- Support for both manual installation and Composer
📋 Requirements
- PHP >= 7.4
- Composer for dependency management
- Git for version control
- Valid Elegant Themes account credentials (for development)
📦 Installation
Via Composer (Recommended)
# Install as a development dependency composer require --dev mralaminahamed/divi-theme-stubs # Or specify a version composer require --dev mralaminahamed/divi-theme-stubs:^4.0
Manual Installation
Download the stub files directly:
🔧 Configuration
PHPStan Integration
Add the stubs to your phpstan.neon configuration:
parameters: bootstrapFiles: - vendor/mralaminahamed/divi-theme-stubs/divi-theme-constants-stubs.stub - vendor/mralaminahamed/divi-theme-stubs/divi-theme-stubs.stub
IDE Configuration
PhpStorm
- Go to
Settings→PHP→Include Path - Add the directory containing the stub files
VS Code with Intelephense
Add to your .vscode/settings.json:
{
"intelephense.stubs": [
"wordpress",
"divi-theme-stubs"
]
}
VS Code with PHP Intellisense
Add to your settings.json:
{
"php.stubs": [
"vendor/mralaminahamed/divi-theme-stubs/divi-theme-stubs.stub",
"vendor/mralaminahamed/divi-theme-stubs/divi-theme-constants-stubs.stub"
]
}
🔍 Usage Example
<?php // Your code will now have full IDE support use ET_Builder_Module; class MyCustomModule extends ET_Builder_Module { public function init() { $this->name = 'Custom Module'; $this->slug = 'custom_module'; // IDE will provide proper autocompletion for all properties } } // Constants are properly defined if (defined('ET_BUILDER_VERSION')) { // Your implementation }
🛠 Development
Setting Up Development Environment
- Clone the repository:
git clone https://github.com/mralaminahamed/phpstan-divi-theme-stubs.git
cd phpstan-divi-theme-stubs
- Install dependencies:
composer install
- Configure authentication:
# Add to your ~/.bashrc or ~/.zshrc export ET_USERNAME='your_elegant_themes_username' export ET_API_KEY='your_elegant_themes_api_key'
Available Commands
# Generate stubs composer generate # Release new version composer release # Release only latest version composer release:latest # Clean up generated files composer cleanup # Run all checks composer check # Run static analysis composer analyze # Run coding standards check composer cs
Directory Structure
.
├── bin/
│ ├── generate.sh
│ └── release.sh
├── configs/
│ └── finder.php
├── lib/
│ └── shared.sh
├── source/
├── tests/
├── composer.json
└── README.md
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow PSR-12 coding standards
- Add/update tests for new features
- Update documentation for significant changes
- Verify stub generation works for latest Divi version
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Elegant Themes for the Divi theme
- php-stubs/generator for the stub generation tools
- All contributors
💬 Support
- For bug reports and feature requests, please use GitHub Issues
- For questions and discussions, use GitHub Discussions
- For security vulnerabilities, please email directly to security@example.com
⚠️ Known Issues and Limitations
- Some dynamic properties and methods may not be properly stubbed
- WooCommerce integration stubs are excluded by default
- Custom module properties need to be explicitly declared
📝 Changelog
See CHANGELOG.md for all notable changes.
Made with ❤️ by Mr Alamin Ahamed