Skip to content

DeprecatedIniOptions ​

warning on by default

Group: Compatibility · PhpStorm name: DeprecatedIniOptionsInspection

Reading, changing or restoring an ini directive that the targeted PHP version has deprecated or removed is either a no-op or a future breakage. Point out such directives, naming the version and the replacement when there is one.

Example ​

Target PHP 5.6:

php
<?php
$enc = ini_get('mbstring.http_output');
ini_set("SAFE_MODE", '0');
ini_alter('mbstring.script_encoding', 'UTF-8');
\ini_restore("always_populate_raw_post_data");
ini_set('asp_tags', '1');
ini_set('track_errors', '1');
ini_set('memory_limit', '64M');
$key = 'safe_mode';
ini_get($key);

Reported:

  • line 2: Ini directive 'mbstring.http_output' is deprecated since PHP 5.6.0; use default_charset.
  • line 3: Ini directive 'safe_mode' no longer exists since PHP 5.4.0.
  • line 4: Ini directive 'mbstring.script_encoding' no longer exists since PHP 5.4.0; use zend.script_encoding.
  • line 5: Ini directive 'always_populate_raw_post_data' is deprecated since PHP 5.6.0.

Configure ​

In custos.json:

json
{
  "rules": {
    "DeprecatedIniOptions": {
      "enabled": false
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file), either of:

php
// @custos-ignore DeprecatedIniOptions

/**
 * @noinspection DeprecatedIniOptionsInspection
 */

Released under the MIT License. Rule catalogue modelled on Php Inspections (EA Extended); independent clean-room implementation.