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 numeric-string type #3161

Closed
vv12131415 opened this issue Apr 12, 2020 · 6 comments
Closed

add numeric-string type #3161

vv12131415 opened this issue Apr 12, 2020 · 6 comments

Comments

@vv12131415
Copy link

Feature request

I found that phpstan doesn't understand psalms numeric-string type (see https://psalm.dev/docs/annotating_code/type_syntax/scalar_types/#numeric-string)
It would be nice to support it.

here is playground link
https://phpstan.org/r/9e26dfae-706f-4e3a-bcfe-8a5ba327e393

also there are psalm one (with some errors on psalms side)
https://psalm.dev/r/d1a036f1f4

@clxmstaab
Copy link
Contributor

also ran over this.

our real-world use-case is in the db abstraction layer.. pdo - when not configured properly - return every value as a string, no matter we already know it can only be an int

@ondrejmirtes
Copy link
Member

@clxmstaab Can you post an example on phpstan.org?

@clxmstaab
Copy link
Contributor

clxmstaab commented Apr 27, 2020

pdo returns always strings, when you don't use mysqlnd driver, or things are somehow misconfigured (PDO::ATTR_EMULATE_PREPARES or PDO::ATTR_STRINGIFY_FETCHES)

https://stackoverflow.com/a/20123337

so my use-case is:

  • have a pdo datasource which returns strings, even for your e.g. "int" typed columns
  • type them with numeric-string as I cannot type them int (and typing them as string feels like we are loosing a lot of room a static analysis tool could work with)

@henanwuyanzu
Copy link

功能要求

我发现phpstan无法理解psalms的数字字符串类型(请参阅https://psalm.dev/docs/annotating_code/type_syntax/scalar_types/#numeric-string)
很好地支持它。

这是游乐场链接
https://phpstan.org/r/9e26dfae-706f-4e3a-bcfe-8a5ba327e393

也有一个诗篇(在诗篇方面有一些错误)
https://psalm.dev/r/d1a036f1f4

hello Handsome guy

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpstan-src@1d27c61

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants