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

Most upvoted comments

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 in ReturnTypeAnalyzer for final/private methods

This is a bug - Psalter should never add non-docblock types when they’d conflict with an inherited type.