-
Notifications
You must be signed in to change notification settings - Fork 660
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
Avoid false positive about array which are non-callable #10935
Conversation
43162de
to
3b512ce
Compare
I get the point of this PR and it's good, the question is since the
|
The opposite question would be "Are we ok to return false positive for people using correctly the phpdoc in order to keep catching errors for people which used the wrong phpdoc". I would say NEVER. And if we're doing nothing we'll end with a lot of issue like #10936 which makes psalm unusable with Symfony/Twig. I agree catching a wrong method could be great, but first the false-positive need to be fixed. |
Agree, 2 things that come to my mind at this point:
|
Both are added in the last commit. |
Thanks! |
Would it be ok to make a new patch release @weirdan ? This PR fix a lot of false positive for symfony/twig users. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [vimeo/psalm](https://github.com/vimeo/psalm) | `5.24.0` -> `5.25.0` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/vimeo%2fpsalm/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/vimeo%2fpsalm/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/vimeo%2fpsalm/5.24.0/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/vimeo%2fpsalm/5.24.0/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>vimeo/psalm (vimeo/psalm)</summary> ### [`v5.25.0`](https://github.com/vimeo/psalm/releases/tag/5.25.0) [Compare Source](https://github.com/vimeo/psalm/compare/5.24.0...5.25.0) <!-- Release notes generated using configuration in .github/release.yml at 5.x --> #### What's Changed ##### Features - Casting int-range should keep literals by [@​kkmuffme](https://github.com/kkmuffme) in [https://github.com/vimeo/psalm/pull/10941](https://github.com/vimeo/psalm/pull/10941) - Update help panel by [@​llaville](https://github.com/llaville) in [https://github.com/vimeo/psalm/pull/11000](https://github.com/vimeo/psalm/pull/11000) - Add support for phpstan-pure by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10975](https://github.com/vimeo/psalm/pull/10975) - Precise preg_match_all return type by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10969](https://github.com/vimeo/psalm/pull/10969) ##### Fixes - Fix-[GH-10933](https://github.com/vimeo/psalm/issues/10933)-And-[GH-10951](https://github.com/vimeo/psalm/issues/10951) by [@​jack-worman](https://github.com/jack-worman) in [https://github.com/vimeo/psalm/pull/10953](https://github.com/vimeo/psalm/pull/10953) - redis: add possible types for `Redis#auth` method by [@​boesing](https://github.com/boesing) in [https://github.com/vimeo/psalm/pull/10934](https://github.com/vimeo/psalm/pull/10934) - Avoid false positive about array which are non-callable by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10935](https://github.com/vimeo/psalm/pull/10935) - Fix literal-string|non-empty-literal-string by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10930](https://github.com/vimeo/psalm/pull/10930) - Fix signature of Locale::canonicalize. by [@​ADmad](https://github.com/ADmad) in [https://github.com/vimeo/psalm/pull/11010](https://github.com/vimeo/psalm/pull/11010) #### New Contributors - [@​llaville](https://github.com/llaville) made their first contribution in [https://github.com/vimeo/psalm/pull/11000](https://github.com/vimeo/psalm/pull/11000) **Full Changelog**: vimeo/psalm@5.24.0...5.25.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Gashmob/project-templates). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
This PR did not fix the issue with setting protected function as callable. https://psalm.dev/r/3c405968f1 This code reports no error on psalm.dev, as it uses outdated version there. But with 5.24 and 5.25 it complains that
However setting a protected function this way is totally fine. The issue would be setting a private function |
I found these snippets: https://psalm.dev/r/3c405968f1<?php
class Command{
/**
* @param callable $code
*/
public function setCode(callable $code): static
{
return $this;
}
}
class Code extends Command{
public function __construct(){
parent::setCode([$this, 'runCode']);
}
protected function runCode(): void
{}
}
|
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [phpstan/phpstan](https://github.com/phpstan/phpstan) | `1.11.4` -> `1.11.5` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/phpstan%2fphpstan/1.11.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/phpstan%2fphpstan/1.11.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/phpstan%2fphpstan/1.11.4/1.11.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/phpstan%2fphpstan/1.11.4/1.11.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [phpunit/phpunit](https://phpunit.de/) ([source](https://github.com/sebastianbergmann/phpunit)) | `10.5.20` -> `10.5.24` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/phpunit%2fphpunit/10.5.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/phpunit%2fphpunit/10.5.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/phpunit%2fphpunit/10.5.20/10.5.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/phpunit%2fphpunit/10.5.20/10.5.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [vimeo/psalm](https://github.com/vimeo/psalm) | `5.24.0` -> `5.25.0` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/vimeo%2fpsalm/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/vimeo%2fpsalm/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/vimeo%2fpsalm/5.24.0/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/vimeo%2fpsalm/5.24.0/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>phpstan/phpstan (phpstan/phpstan)</summary> ### [`v1.11.5`](https://github.com/phpstan/phpstan/compare/1.11.4...1.11.5) [Compare Source](https://github.com/phpstan/phpstan/compare/1.11.4...1.11.5) </details> <details> <summary>sebastianbergmann/phpunit (phpunit/phpunit)</summary> ### [`v10.5.24`](https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.24): PHPUnit 10.5.24 [Compare Source](https://github.com/sebastianbergmann/phpunit/compare/10.5.23...10.5.24) ##### Changed - [#​5877](https://github.com/sebastianbergmann/phpunit/pull/5877): Use `array_pop()` instead of `array_shift()` for processing `Test` objects in `TestSuite::run()` and optimize `TestSuite::isEmpty()` *** [How to install or update PHPUnit](https://docs.phpunit.de/en/10.5/installation.html) ### [`v10.5.23`](https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.23): PHPUnit 10.5.23 [Compare Source](https://github.com/sebastianbergmann/phpunit/compare/10.5.22...10.5.23) ##### Changed - [#​5875](https://github.com/sebastianbergmann/phpunit/pull/5875): Also destruct `TestCase` objects early that use a data provider *** [How to install or update PHPUnit](https://docs.phpunit.de/en/10.5/installation.html) ### [`v10.5.22`](https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.22): PHPUnit 10.5.22 [Compare Source](https://github.com/sebastianbergmann/phpunit/compare/10.5.21...10.5.22) ##### Changed - [#​5871](https://github.com/sebastianbergmann/phpunit/pull/5871): Do not collect unnecessary information using `debug_backtrace()` *** [How to install or update PHPUnit](https://docs.phpunit.de/en/10.5/installation.html) ### [`v10.5.21`](https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.21): PHPUnit 10.5.21 [Compare Source](https://github.com/sebastianbergmann/phpunit/compare/10.5.20...10.5.21) ##### Changed - [#​5861](https://github.com/sebastianbergmann/phpunit/pull/5861): Destroy `TestCase` object after its test was run *** [How to install or update PHPUnit](https://docs.phpunit.de/en/10.5/installation.html) </details> <details> <summary>vimeo/psalm (vimeo/psalm)</summary> ### [`v5.25.0`](https://github.com/vimeo/psalm/releases/tag/5.25.0) [Compare Source](https://github.com/vimeo/psalm/compare/5.24.0...5.25.0) <!-- Release notes generated using configuration in .github/release.yml at 5.x --> #### What's Changed ##### Features - Casting int-range should keep literals by [@​kkmuffme](https://github.com/kkmuffme) in [https://github.com/vimeo/psalm/pull/10941](https://github.com/vimeo/psalm/pull/10941) - Update help panel by [@​llaville](https://github.com/llaville) in [https://github.com/vimeo/psalm/pull/11000](https://github.com/vimeo/psalm/pull/11000) - Add support for phpstan-pure by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10975](https://github.com/vimeo/psalm/pull/10975) - Precise preg_match_all return type by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10969](https://github.com/vimeo/psalm/pull/10969) ##### Fixes - Fix-[GH-10933](https://github.com/vimeo/psalm/issues/10933)-And-[GH-10951](https://github.com/vimeo/psalm/issues/10951) by [@​jack-worman](https://github.com/jack-worman) in [https://github.com/vimeo/psalm/pull/10953](https://github.com/vimeo/psalm/pull/10953) - redis: add possible types for `Redis#auth` method by [@​boesing](https://github.com/boesing) in [https://github.com/vimeo/psalm/pull/10934](https://github.com/vimeo/psalm/pull/10934) - Avoid false positive about array which are non-callable by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10935](https://github.com/vimeo/psalm/pull/10935) - Fix literal-string|non-empty-literal-string by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10930](https://github.com/vimeo/psalm/pull/10930) - Fix signature of Locale::canonicalize. by [@​ADmad](https://github.com/ADmad) in [https://github.com/vimeo/psalm/pull/11010](https://github.com/vimeo/psalm/pull/11010) #### New Contributors - [@​llaville](https://github.com/llaville) made their first contribution in [https://github.com/vimeo/psalm/pull/11000](https://github.com/vimeo/psalm/pull/11000) **Full Changelog**: vimeo/psalm@5.24.0...5.25.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/cerbos/cerbos-sdk-php). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjQxMy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhcmVhL2RlcHMiLCJib3RzIiwia2luZC9jaG9yZSJdfQ==--> Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [vimeo/psalm](https://github.com/vimeo/psalm) | `~5.24.0` -> `~5.25.0` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/vimeo%2fpsalm/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/vimeo%2fpsalm/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/vimeo%2fpsalm/5.24.0/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/vimeo%2fpsalm/5.24.0/5.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>vimeo/psalm (vimeo/psalm)</summary> ### [`v5.25.0`](https://github.com/vimeo/psalm/releases/tag/5.25.0) [Compare Source](https://github.com/vimeo/psalm/compare/5.24.0...5.25.0) <!-- Release notes generated using configuration in .github/release.yml at 5.x --> #### What's Changed ##### Features - Casting int-range should keep literals by [@​kkmuffme](https://github.com/kkmuffme) in [https://github.com/vimeo/psalm/pull/10941](https://github.com/vimeo/psalm/pull/10941) - Update help panel by [@​llaville](https://github.com/llaville) in [https://github.com/vimeo/psalm/pull/11000](https://github.com/vimeo/psalm/pull/11000) - Add support for phpstan-pure by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10975](https://github.com/vimeo/psalm/pull/10975) - Precise preg_match_all return type by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10969](https://github.com/vimeo/psalm/pull/10969) ##### Fixes - Fix-[GH-10933](https://github.com/vimeo/psalm/issues/10933)-And-[GH-10951](https://github.com/vimeo/psalm/issues/10951) by [@​jack-worman](https://github.com/jack-worman) in [https://github.com/vimeo/psalm/pull/10953](https://github.com/vimeo/psalm/pull/10953) - redis: add possible types for `Redis#auth` method by [@​boesing](https://github.com/boesing) in [https://github.com/vimeo/psalm/pull/10934](https://github.com/vimeo/psalm/pull/10934) - Avoid false positive about array which are non-callable by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10935](https://github.com/vimeo/psalm/pull/10935) - Fix literal-string|non-empty-literal-string by [@​VincentLanglet](https://github.com/VincentLanglet) in [https://github.com/vimeo/psalm/pull/10930](https://github.com/vimeo/psalm/pull/10930) - Fix signature of Locale::canonicalize. by [@​ADmad](https://github.com/ADmad) in [https://github.com/vimeo/psalm/pull/11010](https://github.com/vimeo/psalm/pull/11010) #### New Contributors - [@​llaville](https://github.com/llaville) made their first contribution in [https://github.com/vimeo/psalm/pull/11000](https://github.com/vimeo/psalm/pull/11000) **Full Changelog**: vimeo/psalm@5.24.0...5.25.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/open-feature/php-sdk). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
From discussion #10839 (comment)
This should be valid, cf https://3v4l.org/JZgNh