ramsey / conventional-commits

:yo_yo: A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook plugin!
MIT License
182 stars 21 forks source link

Fix PHPStan (and Psalm) issues #64

Closed hussainweb closed 1 year ago

hussainweb commented 1 year ago

Description

PHPStan reports errors when run manually or during a CI run. I saw this first when working on https://github.com/ramsey/conventional-commits/pull/58 but then I reproduced this on the main branch as well. That is the reason I am creating a new issue and a PR.

Motivation and context

The issue is described in #63.

How has this been tested?

I ran this manually on my machine using composer dev:analyze:phpstan and composer dev:analyze:psalm.

Types of changes

PR checklist

hussainweb commented 1 year ago

After my first set of changes, I noticed that the fix I needed to do to solve a PHPStan error resulted in a Psalm error. I think the Psalm error is a false positive and it happens because it (probably) cannot detect the logic within the if (is_int(...)) block. However, rather than suppressing the error, I stored the value in a temporary variable as you can see.

If you prefer the suppression instead, let me know.