PHPackages                             orklah/psalm-insane-comparison - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. orklah/psalm-insane-comparison

ActivePsalm-plugin

orklah/psalm-insane-comparison
==============================

Detects possible insane comparison ("string" == 0) to help migrate to PHP8

v2.4.0(1y ago)351.5M—3.4%4[1 PRs](https://github.com/orklah/psalm-insane-comparison/pulls)2MITPHPPHP ^7.3|^8.0

Since Dec 3Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/orklah/psalm-insane-comparison)[ Packagist](https://packagist.org/packages/orklah/psalm-insane-comparison)[ RSS](/packages/orklah-psalm-insane-comparison/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (15)Used By (2)

psalm-insane-comparison
=======================

[](#psalm-insane-comparison)

A [Psalm](https://github.com/vimeo/psalm) plugin to detect code susceptible to change behaviour with the introduction of [PHP RFC: Saner string to number comparisons](https://wiki.php.net/rfc/string_to_number_comparison)

Installation:

```
$ composer require --dev orklah/psalm-insane-comparison
$ vendor/bin/psalm-plugin enable orklah/psalm-insane-comparison
```

Usage:

Run your usual Psalm command:

```
$ vendor/bin/psalm
```

Explanation:

Before PHP8, comparison between a non-empty-string and the literal int 0 resulted in `true`. This is no longer the case with the [PHP RFC: Saner string to number comparisons](https://wiki.php.net/rfc/string_to_number_comparison).

```
$a = 'banana';
$b = 0;
if($a == $b){
    echo 'PHP 7 will display this';
}
else{
    echo 'PHP 8 will display this instead';
}
```

This plugin helps identify those case to check them before migrating.

You can solve this issue in a lot of ways:

- use strict equality:

```
$a = 'banana';
$b = 0;
if($a === $b){
    echo 'This is impossible';
}
else{
    echo 'PHP 7 and 8 will both display this';
}
```

- use a cast to make both operands the same type:

```
$a = 'banana';
$b = 0;
if((int)$a == $b){
    echo 'PHP 7 and 8 will both display this';
}
else{
    echo 'This is impossible';
}
```

```
$a = 'banana';
$b = 0;
if($a == (string)$b){
    echo 'This is impossible';
}
else{
    echo 'PHP 7 and 8 will both display this';
}
```

- Make psalm understand you're working with positive-ints when the int operand is not a literal:

```
$a = 'banana';
/** @var positive-int $b */
if($a == $b){
    echo 'This is impossible';
}
else{
    echo 'PHP 7 and 8 will both display this';
}
```

- Make psalm understand you're working with numeric-strings when the string operand is not a literal:

```
/** @var numeric-string $a */
$b = 0;
if($a == $b){
    echo 'PHP 7 and 8 will both display this depending on the value of $a';
}
else{
    echo 'PHP 7 and 8 will both display this depending on the value of $a';
}
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance58

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 72.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~126 days

Recently: every ~279 days

Total

13

Last Release

473d ago

Major Versions

v0.1.3 → v1.0.02020-12-04

v1.0.3 → v2.0.02022-01-10

PHP version history (2 changes)v0.1.0PHP ^7.3

v1.0.2PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e260f2252ede6d70aea471f0c0e0b0cf81f48c2edc3b22ff08abe1a74316fcca?d=identicon)[orklah](/maintainers/orklah)

---

Top Contributors

[![orklah](https://avatars.githubusercontent.com/u/9605520?v=4)](https://github.com/orklah "orklah (16 commits)")[![danog](https://avatars.githubusercontent.com/u/7339644?v=4)](https://github.com/danog "danog (5 commits)")[![maximal](https://avatars.githubusercontent.com/u/980679?v=4)](https://github.com/maximal "maximal (1 commits)")

### Embed Badge

![Health badge](/badges/orklah-psalm-insane-comparison/health.svg)

```
[![Health](https://phpackages.com/badges/orklah-psalm-insane-comparison/health.svg)](https://phpackages.com/packages/orklah-psalm-insane-comparison)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[php-standard-library/psalm-plugin

Psalm plugin for the PHP Standard Library

252.0M47](/packages/php-standard-library-psalm-plugin)[lctrs/psalm-psr-container-plugin

Let Psalm understand better psr11 containers

17648.1k13](/packages/lctrs-psalm-psr-container-plugin)[cspray/phinal

Enforce final on your classes!

14308.1k4](/packages/cspray-phinal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
