PHPackages                             samsonasik/is-deprecated - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. samsonasik/is-deprecated

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

samsonasik/is-deprecated
========================

Check PHP user and core function is deprecated

3.0.0(6y ago)216MITPHPPHP ^7.0

Since Feb 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/samsonasik/IsDeprecated)[ Packagist](https://packagist.org/packages/samsonasik/is-deprecated)[ Docs](https://github.com/samsonasik/IsDeprecated)[ RSS](/packages/samsonasik-is-deprecated/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

IsDeprecated
============

[](#isdeprecated)

[![Latest Version](https://camo.githubusercontent.com/1cc9e0d175eb8707fc66ca81ecb861abe0255ec74b39c39a885f8f1aec1874d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73616d736f6e6173696b2f4973446570726563617465642e7376673f7374796c653d666c61742d737175617265)](https://github.com/samsonasik/IsDeprecated/releases)[![Build Status](https://camo.githubusercontent.com/2f20dc6081ade228adff948bbef1c60c816c1ba79510f2d51ad38011ea91dcb2/68747470733a2f2f7472617669732d63692e6f72672f73616d736f6e6173696b2f4973446570726563617465642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/samsonasik/IsDeprecated)[![Coverage Status](https://camo.githubusercontent.com/e7ef2457a651bec565364288e0c75d9f646b57ea76023d6d95bbb5cf7ce5bc91/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73616d736f6e6173696b2f4973446570726563617465642f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/samsonasik/IsDeprecated?branch=master)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)[![Downloads](https://camo.githubusercontent.com/1eb5bfb11cd051bd010595b1e9902c3f36025ccc75d41bc04c19555f76a0487b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616d736f6e6173696b2f69732d646570726563617465642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/samsonasik/is-deprecated)

Introduction
------------

[](#introduction)

IsDeprecated is PHP7 Helper that can help you detect if your function is deprecated with E\_USER\_DEPRECATED and E\_DEPRECATED level.

Features
--------

[](#features)

- Detect on independent function (E\_USER\_DEPRECATED)
- Detect on function inside class (E\_USER\_DEPRECATED)
- Detect on core php function (E\_DEPRECATED)

Installation
------------

[](#installation)

Require uses [composer](https://getcomposer.org/):

```
composer require samsonasik/is-deprecated
```

Usage
-----

[](#usage)

There are 2 functions:

*1. For user defined function*

```
/**
 * @param  string|array $function the "functionName" or ["ClassName" or object, "functionName"] or "ClassName::functionName"
 * @throws InvalidArgumentException when trigger_error found but the error is not E_USER_DEPRECATED
 * @throws InvalidArgumentException when trigger_error and E_USER_DEPRECATED found but misplaced
 * @return bool
 */
function isDeprecatedUser($function): bool
```

> Note: when trigger\_error E\_USER\_DEPRECATED inside condition, you need to use `actual` call with signature:

```
/**
 * @param  callable $function callable function
 * @return bool
 */
function isDeprecatedWithActualCall(callable $function)
```

*2. For core PHP function*

```
/**
 * @param  callable $function callable function
 * @return bool
 */
function isDeprecatedCore(callable $function): bool
```

**Example On independent function**

```
include 'vendor/autoload.php'; // autoload may already handled by your framework

use function IsDeprecated\isDeprecatedUser;
use function IsDeprecated\isDeprecatedWithActualCall;

function foo()
{
    trigger_error('this method has been deprecated.', E_USER_DEPRECATED);
    echo 'foo' . PHP_EOL;
}

function foonotdeprecated()
{
    echo 'foo' . PHP_EOL;
}

function fooDeprecatedWithCondition()
{
    if (1 === 1) {
        trigger_error('this method has been deprecated.', E_USER_DEPRECATED);
        echo 'foo' . PHP_EOL;
    }
}

// deprecated
var_dump(isDeprecatedUser('foo')); // true  OR for deprecate with condition
var_dump(isDeprecatedWithActualCall(function () {
    fooDeprecatedWithCondition();
})); // true

// not deprecated
var_dump(isDeprecatedUser('foonotdeprecated')); // false

// Usage Example:
if (isDeprecatedUser('foo')) {
    foonotdeprecated();;
} else {
    foo();
}
```

**Example On function inside class**

```
include 'vendor/autoload.php'; // autoload may already handled by your framework

use function IsDeprecated\isDeprecatedUser;
use function IsDeprecated\isDeprecatedWithActualCall;

class Aclass
{
    function foo()
    {
        trigger_error('this method has been deprecated.', E_USER_DEPRECATED);
        echo 'foo' . PHP_EOL;
    }

    function foodeprecatedWithCondition()
    {
        if (1 === 1) {
            trigger_error('this method has been deprecated.', E_USER_DEPRECATED);
        }
        echo 'foo' . PHP_EOL;
    }

    function foonotdeprecated()
    {
        echo 'foo' . PHP_EOL;
    }

    // you may call inside the class
    // with $this as first index of array parameter
    function execute()
    {
        if (isDeprecatedUser([$this, 'foo'])) {
            $this->foonotdeprecated();
            return;
        }

        $this->foo();
    }
}

// deprecated
var_dump(isDeprecatedUser(['Aclass', 'foo'])); // true OR
var_dump(isDeprecatedUser([new \Aclass(), 'foo'])); // true OR
var_dump(isDeprecatedUser('Aclass::foo')); // true OR for deprecate with condition

var_dump(isDeprecatedWithActualCall(function () { // true
    new \Aclass()->foo();
}));

// not deprecated
var_dump(isDeprecatedUser(['Aclass', 'foonotdeprecated'])); // false OR
var_dump(isDeprecatedUser([new \Aclass, 'foonotdeprecated'])); // false OR
var_dump(isDeprecatedUser('Aclass::foonotdeprecated')); // false

// Usage Example:
if (isDeprecatedUser(['Aclass', 'foo'])) {
    (new \Aclass())->foonotdeprecated();;
} else {
    (new \Aclass())->foo();;
}
```

**Example On core PHP function**

```
include 'vendor/autoload.php'; // autoload may already handled by your framework

use function IsDeprecated\isDeprecatedCore;

$function = function () {
    mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
};

//on php 7.1
var_dump(isDeprecatedCore($function)); // true

//on php 7.0
var_dump(isDeprecatedCore($function)); // false

// Usage Example:
if (isDeprecatedCore($function)) {
    // alternative function, eg: openssl ...
} else {
    $function();
}
```

Limitation
----------

[](#limitation)

For Core PHP Functions or user function with condition (T\_IF or T\_SWITCH token), the function passed actually need to be called. It ensure that we don't get error during call deprecated function, and we can use alternative function if the `isDeprecatedCore()` returns true with call of `isDeprecatedWithActualCall`.

Contributing
------------

[](#contributing)

Contributions are very welcome. Please read [CONTRIBUTING.md](https://github.com/samsonasik/IsDeprecated/blob/master/CONTRIBUTING.md)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~187 days

Recently: every ~427 days

Total

12

Last Release

1373d ago

Major Versions

1.0.0 → 2.0.02018-01-18

2.0.8 → 3.0.02020-01-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/19076b7688ca1c8ee79ab3ac6fa6acdd7b96012973aba3b1a06cbb3154d7f3e5?d=identicon)[samsonasik](/maintainers/samsonasik)

---

Top Contributors

[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (75 commits)")

---

Tags

deprecateddeprecation-checkerhandlerlaminasphpphpcheckdeprecated

### Embed Badge

![Health badge](/badges/samsonasik-is-deprecated/health.svg)

```
[![Health](https://phpackages.com/badges/samsonasik-is-deprecated/health.svg)](https://phpackages.com/packages/samsonasik-is-deprecated)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k4.9k](/packages/shlinkio-shlink)[limingxinleo/hyperf-utils

Utils for Hyperf.

29136.4k3](/packages/limingxinleo-hyperf-utils)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21422.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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