Skip to content

mralaminahamed/phpstan-freemius-stubs

Repository files navigation

Freemius WordPress SDK Stubs

Latest Version Downloads License PHP Version Tweet

PHP stub declarations for the Freemius WordPress SDK 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 Freemius SDK versions

📋 Requirements

  • PHP >= 7.1
  • Composer for dependency management

📦 Installation

Via Composer (Recommended)

# Install as a development dependency
composer require --dev mralaminahamed/freemius-stubs

# Or specify a version
composer require --dev mralaminahamed/freemius-stubs:^2.0

Manual Installation

Download the stub files directly:

🔧 Configuration

PHPStan Integration

Add the stubs to your phpstan.neon configuration:

parameters:
    bootstrapFiles:
        - vendor/mralaminahamed/freemius-stubs/freemius-constants-stubs.php
        - vendor/mralaminahamed/freemius-stubs/freemius-stubs.php

IDE Configuration

Most modern IDEs will automatically detect the stubs when installed via Composer. For manual installation, add the stub files to your IDE's include path.

PhpStorm

  1. Go to SettingsPHPInclude Path
  2. Add the directory containing the stub files

VS Code

Add to your settings.json:

{
    "php.stubs": [
        "vendor/mralaminahamed/freemius-stubs/freemius-stubs.php",
        "vendor/mralaminahamed/freemius-stubs/freemius-constants-stubs.php"
    ]
}

🔍 Usage Example

<?php

// Your code will now have full IDE support
$fs = Freemius::instance();

// Constants are properly defined
if (WP_FS__SDK_VERSION) {
    // Your implementation
}

// Interfaces and classes are available
class MyIntegration implements Freemius_Api_Interface {
    // Your implementation
}

🛠 Development

Building Stubs

# Clone the repository
git clone https://github.com/mralaminahamed/phpstan-freemius-stubs.git
cd phpstan-freemius-stubs

# Install dependencies
composer install

# Generate stubs
composer generate

# Release new version
composer release

Running Tests

# Run all checks
composer check

# Individual checks
composer cs      # Coding standards
composer analyze # Static analysis
composer test    # Unit tests

📚 Documentation

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

💬 Support

For bug reports and feature requests, please use the GitHub Issues.

For questions and discussions, please use the GitHub Discussions.


About

PHP stub declarations for the Freemius WordPress SDK to enhance IDE completion and static analysis capabilities.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •