Skip to content

Add type hints in all classes#775

Merged
mblaney merged 7 commits intosimplepie:masterfrom
Art4:add-type-hints
Jan 31, 2023
Merged

Add type hints in all classes#775
mblaney merged 7 commits intosimplepie:masterfrom
Art4:add-type-hints

Conversation

@Art4
Copy link
Contributor

@Art4 Art4 commented Jan 24, 2023

This PR adds type hints to all methods in the SimplePie class where the arguments are documented. Thanks to type widening in PHP 7.2 this is not a breaking change.

There are also many methods where the parameters are not documented. This places should be be documented, but for BC they should trigger a deprecation warning, if a parameter has to be casted. The type declaration could be added in SimplePie 2.0.0 with a breaking change.

This will fix #773.

Copy link
Member

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

We can get even more with 'phpdoc_to_param_type' => true rule in PHP-CS-Fixer.

@Art4
Copy link
Contributor Author

Art4 commented Jan 24, 2023

Didn't know about this rule. I will try it. Thank you. 👍

@jtojnar
Copy link
Member

jtojnar commented Jan 24, 2023

Would be nice to be able to use phpdoc_to_return_type as well but we would need to limit it to just private functions (something like https://fekir.info/post/automate-git-interactive-add/ would allow this easily).

@Art4 Art4 mentioned this pull request Jan 24, 2023
48 tasks
@Art4 Art4 changed the title Add type hints in SimplePie class Add type hints in all classes Jan 24, 2023
@Art4
Copy link
Contributor Author

Art4 commented Jan 24, 2023

Would be nice to be able to use phpdoc_to_return_type as well but we would need to limit it to just private functions (something like https://fekir.info/post/automate-git-interactive-add/ would allow this easily).

I've added them manually. We don't have much private methods. 🙂

@jtojnar jtojnar mentioned this pull request Jan 28, 2023
@mblaney mblaney merged commit d894521 into simplepie:master Jan 31, 2023
@Art4 Art4 deleted the add-type-hints branch January 31, 2023 07:45
@Art4 Art4 added this to the 1.9.0 milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Uncaught TypeError: array_slice(): Argument #3 ($length) must be of type ?int

3 participants