psalm: No way to prevent psalter adding backwards-incompatible changes for packages that extend your classes
This is probably more of a question than an error report.
We have our own legacy framework that we use as a composer package in many projects. I’d like to improve type hints using psalter
but the problem is that psalter
adds return types even when that is not safe.
For example, psalter
will add native void
return types. Unfortunately, some of those methods will be overridden in the project and return something.
Basically, my question is: Can the code base be marked as a library? In that case psalter
should not add native type hints to code that can be overridden. I’d still like to have native type hints for final
classes or private
methods.
I realize this is probably not a common use case, feel free to close this if you think it’s not worth it.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (8 by maintainers)
Commits related to this issue
- [InvalidReturnType] Add test for #1622 — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from add native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from adding native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from adding native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from adding native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from adding native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from adding native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
- Fix #1622 - add allow-backwards-incompatible-changes flag to psalter The flag prevents psalter from adding native return types — committed to iluuu1994/psalm by iluuu1994 5 years ago
No worries mate. I’ll create a PR soon 👍
It’s definitely a workaround, but there are no plans to drop support for 5.6-compatible replacements.
To your broader point, sorry for not grasping what you were asking for earlier.
This is not a priority to fix, but you’re very welcome to open a PR.
It might look like
--allow-backwards-incompatible-changes=false
, with commensurate checks inReturnTypeAnalyzer
for final/private methodsThis is a bug - Psalter should never add non-docblock types when they’d conflict with an inherited type.