generator icon indicating copy to clipboard operation
generator copied to clipboard

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

Open owaisahmed5300 opened this issue 11 months ago • 3 comments
trafficstars

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!

owaisahmed5300 avatar Nov 27 '24 09:11 owaisahmed5300

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!!

szepeviktor avatar Nov 27 '24 09:11 szepeviktor

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.

owaisahmed5300 avatar Nov 27 '24 09:11 owaisahmed5300

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.

szepeviktor avatar Nov 27 '24 10:11 szepeviktor