Comments (6)
No problem at all :) Such quick fixes, thank you so much for your time and effort!
Tag v2.11.16
shows no more false positives :D
from phpcs-variable-analysis.
If I may answer - see #297. If you're using this via composer, it'll help if you upgrade to 2.x-dev
. Otherwise just checkout the current code from 2.x
branch and it should work.
from phpcs-variable-analysis.
This will hopefully also be fixed by #298
from phpcs-variable-analysis.
This should be fixed now (it was due to the return types) but if you discover any more arrow functions behaving weird, please let me know!
from phpcs-variable-analysis.
$ composer info | grep phpcs-variable-analysis
sirbrillig/phpcs-variable-analysis v2.11.15 A PHPCS sniff to detect problems with variables.
$ composer style
> vendor/bin/phpcs --standard=phpcs.xml
....................................W.................W..... 60 / 62 (97%)
.. 62 / 62 (100%)
FILE: File1.php
--------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------
33 | WARNING | Variable $allowedReferrer is undefined.
--------------------------------------------------------------
FILE: File2.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
99 | WARNING | Variable $permissionName is undefined.
----------------------------------------------------------------------
Time: 2.26 secs; Memory: 28.98MB
Script vendor/bin/phpcs --standard=phpcs.xml handling the style event returned with error code 1
$ cat -n File1.php | grep -C 5 33
28
29 $this->allowedReferrers = array_map(
30 static fn (string $allowedReferrer) => str_replace(
31 ['\*\*', '\*'],
32 ['[a-z\d.-]{0,63}', '[a-z\d-]{0,63}'],
33 preg_quote($allowedReferrer, '~'),
34 ),
35 $this->allowedReferrers,
36 );
$ cat -n File2.php | grep -C 2 99
97 ->filter(
98 static fn (string $permissionName) => Str::startsWith($permissionName, self::CONFIG_START)
99 && $permissionName !== CustomPermission::ALL_CONFIG
100 )
I guess not 😅
from phpcs-variable-analysis.
Ugh, sorry, yeah, that's the same as #300. Arrow function scope is hard.
from phpcs-variable-analysis.
Related Issues (20)
- Inline if-clause with short-list false positive HOT 5
- Support of array desctructing HOT 2
- Incorrect warning for arguments to static methods that return "new static()" HOT 3
- Incorrect warning for arguments are thrown on static arrow functions HOT 1
- False-positive `UndefinedVariable` for static variable inside an anonymous function HOT 4
- Incorrect warning about redeclaration of function parameter as static variable HOT 2
- Variable $this is undefined in enum HOT 1
- Support constructor promotion with readonly properties (UnusedVariable) HOT 5
- method call called 'enum' causes an "Cannot find enum start at position" error HOT 2
- Unused function parameter in lambda function HOT 4
- Ternary operator inside arrow function HOT 3
- Undefined variable error introduced in v2.11.15 HOT 2
- Feature Request: don't report on unused parameters for deprecated functions
- Variable reported as unused on an assignment by reference HOT 2
- Assignment of an array element counts as a read
- `squizlabs/PHP_CodeSniffer` is abandoned - Replace with `PHPCSStandards/PHP_CodeSniffer` when the time is right HOT 3
- List assignment next to array causes unused variable warning HOT 5
- Assignment to array element reference does not count as a write
- Handle constructor promotion with Nullable types HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpcs-variable-analysis.