args icon indicating copy to clipboard operation
args copied to clipboard

Breeding a mule

Open szepeviktor opened this issue 3 years ago • 4 comments

Could we somehow inject your args into wordpress-stubs?

szepeviktor avatar Jul 10 '22 14:07 szepeviktor

Or all of your args are from WP core? No manual additions?

I'd like to overcome core's referencing policy: https://github.com/WordPress/wordpress-develop/blob/ac3de7c5b3c6eeeda485e00cc0d94da5b40e023f/src/wp-includes/class-wp-customize-manager.php#L4056-L4058

szepeviktor avatar Jul 10 '22 14:07 szepeviktor

They're about 90% from WP core, with some manual adjustments to increase the strictness and add extra constraints for PHPStan.

I suppose we could use this Args library to generate the @phpstan-param tags in wordpress-stubs. It would need to replace an existing tag where present.

Related discussion about references:

  • https://core.trac.wordpress.org/ticket/56164
  • https://core.trac.wordpress.org/ticket/53946 (comments)
  • https://make.wordpress.org/meta/2022/07/01/exploration-improving-devhub/ (section 7)

johnbillion avatar Jul 10 '22 21:07 johnbillion

Thank you for the links. Cc @marekdedic

So in a format like https://github.com/php-stubs/wordpress-stubs/blob/master/functionMap.php we could export array shapes from Args and import into wp-stubs?

szepeviktor avatar Jul 10 '22 21:07 szepeviktor

Hey. @szepeviktor pointed me to this package, good stuff here!

Feel free to use anything from skaut/wordpress-stubs - I have a bit of a different strategy there compared to php-stubs/wordpress-stubs - strictness over completeness, so I have much more detailed stubs at the cost of not having that many. I think one day we could just merge the two, but feel free to just take anything in the meantime.

Q: What's the benefit of the approach of this library as opposed to stubs? Bundling any 3rd party library in a WordPress plugin is a huge pain, so I'd like to know the benefits.

marekdedic avatar Jul 13 '22 17:07 marekdedic