php-stubs / generator

Generate stubs from any PHP code for IDE completion and static analysis.
https://packagist.org/packages/php-stubs/generator
MIT License
52 stars 11 forks source link

Constant support #1

Closed machitgarha closed 3 years ago

machitgarha commented 3 years ago

Add support for constant generation, defined with either const and define().

Side Note

I'm dubious about opening the PR here. Initially, I was going to make an issue before starting to work on it; but, unfortunately, for some unknown reason, the Issues pane is not available. This is why I started with a commit having nothing to do with the issue itself. :)

The topmost-upstream repository has the most stars, so I first decided to make the progress there. But, I'm now doing it here because of two reasons: (1) the vendor of the repo (php-stubs), both for its name and having other stub-related repositories focused, and (2) being more recently updated (also its main maintainer).

So, I'm not really sure whether it's a good decision, but it's better than nothing. :) Waiting for your thoughts on this as well.

szepeviktor commented 3 years ago

Hello @machitgarha!

the Issues pane is not available.

This is a fork under pressure :) See the latest commits.

szepeviktor commented 3 years ago

This is a work-in-progress constant support, defined with either const and define().

Your PR is welcome.

machitgarha commented 3 years ago

Hello, @szepeviktor.

I love quick responses on GitHub. Thanks. :)

machitgarha commented 3 years ago

Tested against my other project, Bimoo, and it seems to work fine.

P.S.: Unrelated to the repository itself, but would you mind moving Bimoo completely to php-stubs organization? It may become more visible and useful to people using Moodle.

szepeviktor commented 3 years ago

moving Bimoo completely to php-stubs organization?

To php-stubs/moodle-stubs?

szepeviktor commented 3 years ago

If you are wiling to move, please clone e.g. the WooCommerce stubs repo and set up finder.php

machitgarha commented 3 years ago

@szepeviktor

Does this PR need something more to be done in order to be merged?

szepeviktor commented 3 years ago

Just change those double quotes to single quotes.

machitgarha commented 3 years ago

moving Bimoo completely to php-stubs organization?

To php-stubs/moodle-stubs?

Maybe. Personally, I prefer the project name 'Bimoo' to remain, if it's possible. However, being used by more people is much more important than that. So, I would like to move it, willing you not renaming it. :)

szepeviktor commented 3 years ago

So, I would like to move it, willing you not renaming it. :)

It may keep its name. moodle-stubs is SEO and user friendly!

machitgarha commented 3 years ago

Just change those double quotes to single quotes.

Oh... it's easier for me to change all single quotes to double quotes than those double quotes to single quotes. My mind doesn't work that way. :)

But OK. I'll do it.

machitgarha commented 3 years ago

If you are wiling to move, please clone e.g. the WooCommerce stubs repo and set up finder.php

* by adding all files with user-facing (non-internal) classes, functions

* excluding compatibility and deprecated ones

Is there a guide for it to cover everything I have to do (and maybe talk about it there), or it is limited to these statements? If so, I have some questions:

machitgarha commented 3 years ago

So, I would like to move it, willing you not renaming it. :)

It may keep its name. moodle-stubs is SEO and user friendly!

Right. It's up to you then. :)

szepeviktor commented 3 years ago
  • Do I have to include every function and class that a user may need, but I'm not aware of? Or what you mean is, not to include something internal? Or both?

Simply include all minus internals, deprecated and compat. (and anything else that should not be used by users)

  • Moodle still supports version 3.9, while it's latest is 3.11. Do I have to (or should I) take those into serious consideration, or no, or at all I have not to care about it?

Stubs follow the source with every tag. So initially we release 3.9.0 - up to the latest. Please see the release script and the generator script: https://github.com/php-stubs/woocommerce-stubs

machitgarha commented 3 years ago
  • Do I have to include every function and class that a user may need, but I'm not aware of? Or what you mean is, not to include something internal? Or both?

Simply include all minus internals, deprecated and compat. (and anything else that should not be used by users)

  • Moodle still supports version 3.9, while it's latest is 3.11. Do I have to (or should I) take those into serious consideration, or no, or at all I have not to care about it?

Stubs follow the source with every tag. So initially we release 3.9.0 - up to the latest. Please see the release script and the generator script: https://github.com/php-stubs/woocommerce-stubs

Thanks for the info.

machitgarha commented 3 years ago

So... Are we able to merge this?

szepeviktor commented 3 years ago

@machitgarha I'm sorry about Moodle. That is something I do not want to have any nexus.

machitgarha commented 3 years ago

Thank you very much. :)

Waiting for version 0.7.0 to be released. :)

machitgarha commented 3 years ago

@machitgarha I'm sorry about Moodle. That is something I do not want to have any nexus.

I didn't mean that you have to be the maintainer of the package; I personally will do that, if that's the problem. But if the reason is something else, then that's OK, thanks for your patience. :)

szepeviktor commented 3 years ago

reason is something else

Yes it is. Moodle is something I do not call a software.

machitgarha commented 3 years ago

reason is something else

Yes it is. Moodle is something I do not call a software.

Could you tell why?

P.S.: Sorry about being curious here. :)

szepeviktor commented 3 years ago

Could you tell why?

Look at it's source code. It has no structure. It has many-many entry-points. In PHP I expect code to be procedural or object-oriented. Moodle goes on another way.

machitgarha commented 3 years ago

It has many-many entry-points.

Exactly.

It has no structure.

I thought Wordpress would go in the same category (just from my readings and hearings, not an analysis of the Wordpress's source code).

And, it's all about backward compatibility IMHO.