Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add stubs for WP 6.5 #167

Merged
merged 3 commits into from
Apr 14, 2024
Merged

Add stubs for WP 6.5 #167

merged 3 commits into from
Apr 14, 2024

Conversation

IanDelMar
Copy link
Contributor

This pull request updates the stubs to WordPress 6.5.

Changes to functionMap.php:

  • Removal of WP_List_Table::display_tablenav and WP_List_Table::pagination. The visitor now adds these PHPStan tags without relying on functionMap.php.
  • Removal of optional indicators (?) for the return type of WP_Filesystem_*::dirlist() in accordance with the description in the documentation.

Notes:

  • WP_Filesystem_*::dirlist(): There are now two @phpstan-return, one added by the visitor using @type and one previously added via functionMap.php. There are two issues: the details provided by the new tag are slightly reduced (see type key), which should not be problematic from my perspective. Additionally, the array key is now specified as int|string, which I believe is incorrect; it should be string. Depending on how PHPStan handles duplicate entries, which I'm unsure of but assume to be based on the last entry, I would recommend retaining the PHPStan information from functionMap.php.
  • WP_Font_Face::generate_and_print(): The visitor no longer includes additions stemming from @type. I think this is because we cannot handle array[][]. Is array[][] a valid syntax?
  • wp_get_avif_info(): The visitor no longer includes additions stemming from @type, possibly due to incorrect indentation. This should be addressed in the core.
  • wp_enqueue_script_module(): See to wp_get_avif_info().

Concerning the idea of ceasing to add additional tags if a tag with the same name is already present (#163):

  • This implies that overriding tags added by the visitor before functionMap tags are applied is no longer possible. Consequently, we wouldn't be able to correct or refine these additions.
  • Conversely, if functionMap tags are added first, we may overlook whether the functionMap entry is still necessary or correct.
  • I suggest continuing to add all tags and did not implement any change to the current behavior of adding all additions.

@szepeviktor
Copy link
Member

Thank you Ian!
Could you please regenerate stubs for the latest tag without adding 6.5?

@szepeviktor
Copy link
Member

You know what?!

@szepeviktor szepeviktor merged commit 04e33fa into php-stubs:master Apr 14, 2024
2 checks passed
@IanDelMar
Copy link
Contributor Author

Thank you Ian! Could you please regenerate stubs for the latest tag without adding 6.5?

Sorry, didn't see this before. Anything you still want me to do?

@IanDelMar IanDelMar deleted the wp-65 branch April 14, 2024 21:03
@szepeviktor
Copy link
Member

No. Everything is released.

@swissspidy
Copy link
Contributor

@IanDelMar Thanks for working on this! Would you mind creating core trac tickets for those two functions?

@IanDelMar
Copy link
Contributor Author

@swissspidy Feel free to do it on my behalf 🙈

@szepeviktor
Copy link
Member

szepeviktor commented Apr 16, 2024

Feel free to do it on my behalf

After all Pascal is our secret connection to WordPress!

@swissspidy
Copy link
Contributor

  • wp_get_avif_info(): The visitor no longer includes additions stemming from @type, possibly due to incorrect indentation. This should be addressed in the core.
  • wp_enqueue_script_module(): See to wp_get_avif_info().

So I just looked into those. Unfortunately, this non-standard phpdoc format for arrays is part of the WordPress coding standards. It's not limited to these two function; just search the code base for @return array { and you'll find lots of examples. We'll have to work around this or make a proposal for core to change its standards or add @phpstan-* tags in addition to those 🤷 😞

@szepeviktor
Copy link
Member

add @phpstan-* tags

Yes. Please have core add ALL of our tags in functionMap.

@IanDelMar
Copy link
Contributor Author

IanDelMar commented Apr 16, 2024

We'll have to work around this

The visitor is aware of this notation for arrays! However, according to the WordPress coding standards, it should be indented by 4 spaces or a multiple thereof. This is what the visitor is seeking but can't find for these two functions. Therefore, it should be fixed in WP core.

search the code base for @return array { and you'll find lots of examples.

And in many of these cases, the phpstan tag is added correctly.

@swissspidy
Copy link
Contributor

Oh, ok! Let me take another look next week then

@swissspidy
Copy link
Contributor

Alright, https://core.trac.wordpress.org/changeset/58037 should fix this

@IanDelMar
Copy link
Contributor Author

Alright, https://core.trac.wordpress.org/changeset/58037 should fix this

These haven't made it into core yet, right?

@swissspidy
Copy link
Contributor

That‘s in core :) just not in a published release. That will be WP 6.6, due out this summer

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

Successfully merging this pull request may close these issues.

3 participants