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

tidyNode properties’ types are inaccurate #2855

Closed
2 tasks
zopsicle opened this issue Feb 20, 2020 · 5 comments
Closed
2 tasks

tidyNode properties’ types are inaccurate #2855

zopsicle opened this issue Feb 20, 2020 · 5 comments
Assignees
Labels
easy problems Issues that can be fixed without background knowledge of Psalm good first issue internal stubs/callmap

Comments

@zopsicle
Copy link
Contributor

The tidyNode class has two properties attribute and child. In Psalm these are both given the type array.

First of all, both properties could have a NULL value. See the example below. Secondly, the types could be more strict, by telling about the array element types.

Proposal

  • Make the attribute property of type ?array<string,string>.
  • Make the child property of type ?array<tidyNode>.

Example

$tidy = new tidy();
$tidy->parseString('hello');

// $text is of type tidyNode
$text = $tidy->body()->child[0];

assert($text->attribute === NULL);
assert($text->child === NULL);
@psalm-github-bot
Copy link

Hey @chloekek, can you reproduce the issue on https://psalm.dev ?

@zopsicle
Copy link
Contributor Author

I should add: the nullabilities and exact types are unfortunately not documented in the PHP manual for the Tidy extension. I will look into contributing a documentation f ix.

@orklah
Copy link
Collaborator

orklah commented Oct 23, 2021

Please provide a PR :)

@orklah orklah added easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap labels Oct 23, 2021
@AndrolGenhald AndrolGenhald self-assigned this Feb 18, 2022
@othercorey
Copy link
Contributor

@orklah The current property map looks correct

'attribute' => 'array|null',

@orklah
Copy link
Collaborator

orklah commented Feb 6, 2023

yeah, null was added by #8000.

I'll close this, if someone wants to make the extra mile and precise the type inside the array, they're welcome!

@orklah orklah closed this as completed Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy problems Issues that can be fixed without background knowledge of Psalm good first issue internal stubs/callmap
Projects
None yet
Development

No branches or pull requests

4 participants