PHPackages                             thecodingmachine/phpstan-safe-rule - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. thecodingmachine/phpstan-safe-rule

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

thecodingmachine/phpstan-safe-rule
==================================

A PHPStan rule to detect safety issues. Must be used in conjunction with thecodingmachine/safe

v1.4.7(1w ago)6210.3M↓29.8%25[3 issues](https://github.com/thecodingmachine/phpstan-safe-rule/issues)20MITPHPPHP ^8.1CI passing

Since Sep 6Pushed 1w ago5 watchersCompare

[ Source](https://github.com/thecodingmachine/phpstan-safe-rule)[ Packagist](https://packagist.org/packages/thecodingmachine/phpstan-safe-rule)[ RSS](/packages/thecodingmachine-phpstan-safe-rule/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (12)Versions (24)Used By (20)

[![Latest Stable Version](https://camo.githubusercontent.com/e7e18f842d77688d8860401cc714d206f5fd2843babe835cd01eae319324f091/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f7068707374616e2d736166652d72756c652f762f737461626c65)](https://packagist.org/packages/thecodingmachine/phpstan-safe-rule)[![Total Downloads](https://camo.githubusercontent.com/493d50d6adeb308987f386ec3e027d9da777769dba66de6930dd41b07cac09f8/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f7068707374616e2d736166652d72756c652f646f776e6c6f616473)](https://packagist.org/packages/thecodingmachine/phpstan-safe-rule)[![Latest Unstable Version](https://camo.githubusercontent.com/e9755146c9bd24964f1924fba460eedd7e536a05cc139570860f306b44179a6a/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f7068707374616e2d736166652d72756c652f762f756e737461626c65)](https://packagist.org/packages/thecodingmachine/phpstan-safe-rule)[![License](https://camo.githubusercontent.com/f8f79e3d1264fdbb3b6715021ba3269afe5cf9c0a32e031ff3f76090f7546643/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f7068707374616e2d736166652d72756c652f6c6963656e7365)](https://packagist.org/packages/thecodingmachine/phpstan-safe-rule)[![Build Status](https://camo.githubusercontent.com/72f64bd5b4913590d0f06729c344c8d89e644ccdbb90c31b048c50f4fa841fa7/68747470733a2f2f7472617669732d63692e6f72672f746865636f64696e676d616368696e652f7068707374616e2d736166652d72756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/thecodingmachine/phpstan-safe-rule)[![Coverage Status](https://camo.githubusercontent.com/7a4171e2e4385ab738de83670b78097212f2ecff2855f043a98b9043971f77d0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f746865636f64696e676d616368696e652f7068707374616e2d736166652d72756c652f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/thecodingmachine/phpstan-safe-rule?branch=master)

PHPStan rules for thecodingmachine/safe
=======================================

[](#phpstan-rules-for-thecodingmachinesafe)

The [thecodingmachine/safe](https://github.com/thecodingmachine/safe) package provides a set of core PHP functions rewritten to throw exceptions instead of returning `false` when an error is encountered.

This PHPStan rule will help you detect unsafe function call and will propose you to use the `thecodingmachine/safe` variant instead.

Please read [thecodingmachine/safe documentation](https://github.com/thecodingmachine/safe) for details about installation and usage.

###  Health Score

74

—

ExcellentBetter than 100% of packages

Maintenance97

Actively maintained with recent releases

Popularity60

Solid adoption and visibility

Community47

Growing community involvement

Maturity81

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~167 days

Recently: every ~109 days

Total

18

Last Release

13d ago

Major Versions

v0.1.4 → v1.0.0-beta12019-12-04

PHP version history (4 changes)v0.1.0PHP ^7.1

v1.0.1PHP ^7.1 || ^8.0

v1.3.0PHP ^7.4 || ^8.0

v1.4.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

![](https://avatars.githubusercontent.com/u/1847918?v=4)[TheCodingMachine](/maintainers/thecodingmachine)[@thecodingmachine](https://github.com/thecodingmachine)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (37 commits)")[![shish](https://avatars.githubusercontent.com/u/40659?v=4)](https://github.com/shish "shish (19 commits)")[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (13 commits)")[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (13 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (6 commits)")[![Khartir](https://avatars.githubusercontent.com/u/5592420?v=4)](https://github.com/Khartir "Khartir (4 commits)")[![dbrekelmans](https://avatars.githubusercontent.com/u/9531344?v=4)](https://github.com/dbrekelmans "dbrekelmans (4 commits)")[![mvhirsch](https://avatars.githubusercontent.com/u/573047?v=4)](https://github.com/mvhirsch "mvhirsch (2 commits)")[![Tobion](https://avatars.githubusercontent.com/u/610090?v=4)](https://github.com/Tobion "Tobion (2 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (1 commits)")[![mRoca](https://avatars.githubusercontent.com/u/4746261?v=4)](https://github.com/mRoca "mRoca (1 commits)")[![sanmai](https://avatars.githubusercontent.com/u/139488?v=4)](https://github.com/sanmai "sanmai (1 commits)")[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (1 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (1 commits)")[![tigitz](https://avatars.githubusercontent.com/u/1524501?v=4)](https://github.com/tigitz "tigitz (1 commits)")[![vkill](https://avatars.githubusercontent.com/u/610852?v=4)](https://github.com/vkill "vkill (1 commits)")[![clxmstaab](https://avatars.githubusercontent.com/u/47448731?v=4)](https://github.com/clxmstaab "clxmstaab (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/thecodingmachine-phpstan-safe-rule/health.svg)

```
[![Health](https://phpackages.com/badges/thecodingmachine-phpstan-safe-rule/health.svg)](https://phpackages.com/packages/thecodingmachine-phpstan-safe-rule)
```

###  Alternatives

[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k28.9M2.4k](/packages/infection-infection)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k101.8M2.2k](/packages/behat-behat)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M91](/packages/shipmonk-dead-code-detector)[phparkitect/phparkitect

Enforce architectural constraints in your PHP applications

9224.3M28](/packages/phparkitect-phparkitect)

PHPackages © 2026

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