php-stubs / generator Goto Github PK
View Code? Open in Web Editor NEWGenerate stubs from any PHP code for IDE completion and static analysis.
Home Page: https://packagist.org/packages/php-stubs/generator
License: MIT License
Generate stubs from any PHP code for IDE completion and static analysis.
Home Page: https://packagist.org/packages/php-stubs/generator
License: MIT License
Package installed with composer: abraham/twitteroauth
(I need the stubs as I'm doing something like you do with the WP stubs which do not use composer, so I need stubs)
generate-stubs --force --functions --classes --interfaces --traits --out="a.php" --no-interaction twitter
(package is installed in twitter folder)
It generates the stubs (10 classes), but stubs for class TwitterOAuth extends Config
are missing.
But e.g. class TwitterOAuthException extends \Exception
and all other classes are there (total 11 classes, but only 10 have stubs created).
Is this a bug or is there something I'm doing wrong?
an issue you encountered yourself already here https://github.com/php-stubs/woocommerce-stubs/blob/master/finder.php
Symfony ->append( '/path/to/file.php' )
should work fine
but when doing this the generator fails silently.
Instead one has to workaround with:
->append(
\StubsGenerator\Finder::create()
->in(['source/woocommerce'])
->files()
->depth('< 1')
->path('woocommerce.php')
)
which is a pain if you have an array of files you want to append
when using https://github.com/php-stubs/woocommerce-stubs/blob/master/finder.php I get a PHP error:
Undefined property: PhpParser\Node\Expr\BinaryOp\Concat::$value
File: vendor/php-stubs/generator/src/NodeVisitor.php on line 378
just wanted to ask if you want to fix (workaround?) it, or if this should be reported upstream?
Worked great so far, however for 1 plugin I cannot generate the stubs and get PHP notices.
Maybe I'm doing something wrong?
Plugin: https://wordpress.org/plugins/woocommerce-paypal-payments/
Trying to access array offset on value of type null
in php-stubs/generator/src/NodeVisitor.php on line 169
I'm using ->notPath( '/Test/' )
to exclude tests (there are some other errors otherwise)
Additionally generate-stubs fails silently (and with result code 0) which may be an issue that needs to be investigated separately (to get a proper error message/exit code 1)
Moved here from README.
When I am generating the stub, I would like to modify the PHPDoc of a specific method of a specific class.
Would it be possible?
Could the dependency for symfony/finder be updated from ^5.0 to ^6.0?
There's a bug in v5 finder which will not find certain files (e.g. in WooCommerce), which is why this would be necessary
The generator uses ContainerInterface
and it excludes loaded interfaces
https://github.com/php-stubs/generator/blob/master/src/NodeVisitor.php#L352
so it won't be included in the output.
Added in 7cbedd8
@johnbillion Do you see a solution/work-around?
I don't want to upset package devs, but Psalm has a similar generator for a long time: https://psalm.dev/docs/running_psalm/plugins/authoring_plugins/ It would be great to combine packages.
PHP file:
<?php
use foo\bar;
/**
* @return bar
*/
function hello() {
...
}
stubs:
<?php
/**
* @return bar
*/
function hello() {
}
Currently, the stubs just remove all "use". This will cause errors for undefined class "bar".
Would it be possible to automatically just replace all param/return with their corresponding "use" class?
So the stubs would actually be:
<?php
/**
* @return foo\bar
*/
function hello() {
}
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.