Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Automate Stub File Generation for Large Codebase with Splitting into Multiple Files #28

Open
owaisahmed5300 opened this issue Nov 27, 2024 · 3 comments

Comments

@owaisahmed5300
Copy link

Currently, the stub generator creates a single file for the entire codebase, which becomes inefficient for larger projects. I request a feature that automatically splits the stub generation into multiple files based on subfolders or another logical structure.

Reason for Request: This request is primarily to improve the performance of static analysis tools such as PHPStan. For projects that rely heavily on stubs, analyzing a single large stub file significantly slows down the analysis process. Splitting the stubs into multiple, smaller files would make it much easier for static analyzers to process and analyze the stubs more efficiently.

Expected Behavior:

The stub generator should automatically detect subfolders and generate separate stub files for each folder (or based on another configurable structure).
The generated stubs should be organized into multiple files, making it easier to manage and allowing static analysis tools like PHPStan to analyze them faster.
Current Behavior:

The generator currently creates a single stub file for the entire codebase, which causes slowdowns when using static analysis tools.

If there’s any other way to achieve a similar result without splitting files, suggestions would also be appreciated!

@szepeviktor
Copy link
Member

szepeviktor commented Nov 27, 2024

Hello @owaisahmed5300 👋🏻

This is the fork of the original and abandoned generator. For php-stubs purposes.

BTW Those separate files would depend on each other!!

@owaisahmed5300
Copy link
Author

Can you suggest a solution for handling large stubs? PHPStan takes too much time to process a large stub file.

PHPStan works faster if we split a large stub file into multiple smaller files. It becomes extremely, slow when processing a single stub file with 100k lines of code.

I’ve seen other stub projects, such as WordPress & WooCommerce stubs, which consist of multiple files. I’d like to know how they were generated.

@szepeviktor
Copy link
Member

Can you suggest a solution for handling large stubs?

Create stubs only where necessary. Class-autoloaded code needs no stubs!

I’ve seen other stub projects, such as WordPress & WooCommerce stubs, which consist of multiple files.

WP stubs are in one file, WC stubs for packages are rarely used: they were separated to a second file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants