Comments (4)
The playground doesn't show files, or "in context of class ClassName", which is very confusing in this case. This is what local phpstan
shows:
------ ---------------------------------------------------------------------------------------------------
Line HasCategories.php (in context of class App\Service\Categories\BaseTest)
------ ---------------------------------------------------------------------------------------------------
10 Access to an undefined static property static(App\Service\Categories\BaseTest)::$category_prefix.
------ ---------------------------------------------------------------------------------------------------
with slighty different names.
from phpstan.
In this second case, the concrete class TestTwo really doesn't have the required static property, which would be a real PHP error: https://phpstan.org/r/5567595d-5e09-4111-ad9a-6fd71e162e99 But PHPStan doesn't detect it, because it's not "in context of BaseClass".
from phpstan.
Traits are analysed in context of each class that uses them. And it doesn't matter whether the class is abstract or not. Your code is dangerous. It's not obvious at all that class extending BaseTest should have this property.
You can switch to an abstract method. That's enforceable by the language and by static analysis.
from phpstan.
Why does dangerous matter? That's what stan is supposed to detect, right? But it doesn't detect the actual bug (TestTwo doesn't have the static property), and it does detect the non-bug. Seems like a bug, but okay, maybe it's an edge case of bad programming.
from phpstan.
Related Issues (20)
- empty constructor of final class should be pure HOT 2
- PHPDoc tag @var for constant with type string|null is not subtype of native type string HOT 2
- PHPStan not follow DNF Type Declaration Constraints (PHP 8.2+)
- Support trait abstract method docstring inheritance and validation
- Almost imposible to install because of the size ! HOT 5
- Updating an array in foreach is wrongly inferred when strict mode is used. HOT 10
- Using @var with backed enum case produces error HOT 5
- FP of generic inference when constructing an empty set datastructure and assigning with ??=
- offsetAccess.nonOffsetAccessible suppressed by isset HOT 5
- No warnings are emitted in custom rule tests HOT 1
- Internal error: Internal error: Interface "...\ReleaseWorkerInterface" not found while analysing file HOT 7
- Type mismatch with literal-string is reported on higher level than others HOT 1
- New callable param- tags should report invalid argument names
- param-closure-this should report an invalid type being used
- Incompatible usages of callable param- tags should be reported as errors HOT 1
- Typehint for $this in included file requires fully qualified name HOT 1
- Duplicate code does not generate a helpfull message
- Can't check if Iterator is empty HOT 1
- [False positive] "yield from" doesn't seem to be considered executed HOT 3
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 phpstan.