Skip to content
New issue

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

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

Already on GitHub? # to your account

Class missing in stubs #9

Closed
kkmuffme opened this issue Jan 26, 2022 · 13 comments
Closed

Class missing in stubs #9

kkmuffme opened this issue Jan 26, 2022 · 13 comments

Comments

@kkmuffme
Copy link
Contributor

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?

@szepeviktor
Copy link
Member

Hello @kkmuffme!
Try to generate from that specific file.

It is very easy to debug this project.

@kkmuffme
Copy link
Contributor Author

If I run it for that file only, there are no errors either (but no stubs generated) it even says "OK":

PHP Stubs Generator
===================


 [OK] Stubs written to /some/path/a.php


 ----------- --------- ------------ -------- ----------- ---------
  functions   classes   interfaces   traits   constants   globals
 ----------- --------- ------------ -------- ----------- ---------
  0           0         0            0        0           0
 ----------- --------- ------------ -------- ----------- ---------

and the output file contains only:

<?php

@szepeviktor
Copy link
Member

Try debugging in this try/catch block

$unparsed[$file->getPathname()] = $e;

Please see #4

@dingo-d
Copy link

dingo-d commented May 17, 2022

I'm also experiencing the same issue. When manually trying to generate the stubs from the command line I get the correct number of stubs recognized, but when I check the file, it's empty.

image

When I don't specify out parameter I don't get anything out.

No error is thrown.

I var dumped the visitor in the StubsGenerator.php, and I can see the correct class and traits mentioned, the $unparsed variable is empty, which is ok.

Not sure why nothing is getting parsed out.

@szepeviktor
Copy link
Member

Dear Denis!
You may be hit by #14

@dingo-d
Copy link

dingo-d commented May 17, 2022

My PHP parsing is not strong, so I'll wait for a fix, but when you'll have something feel free to ping me to test it 👍🏼

@szepeviktor
Copy link
Member

I went the wrong way: temporarily commented out that line mentioned in #14

@dingo-d
Copy link

dingo-d commented May 17, 2022

Tried that, but didn't do anything (nothing was generated)

@szepeviktor
Copy link
Member

I've just commented out all four *exists conditions (func, trait, class, interface) and generate-stubs gave me 909 lines of stubs :)

@szepeviktor
Copy link
Member

$ vendor/bin/generate-stubs --functions --classes --interfaces --traits src/Helpers/ | wc -l
909

@dingo-d
Copy link

dingo-d commented May 17, 2022

Yup can confirm, commenting those lines out seems to generate a correct stub 👍🏼

@herndlm
Copy link
Contributor

herndlm commented May 17, 2022

Would a new config switch for that behaviour (include "existing" things) be useful? Maybe such issues can then be avoided

@szepeviktor
Copy link
Member

szepeviktor commented May 17, 2022

I'm sorry, Martin! This is a highly dangerous ⚡ fork for php-stubs organization stubs only.
Without php-stubs this would be https://github.com/GiacoCorsiglia/php-stubs-generator

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

No branches or pull requests

4 participants