Skip to content

Deprecate Director::is_cli()? #11989

Description

@maxime-rainville

Module version(s) affected

6.x-dev

Description

Minorish thing, but I just noticed that Director::is_cli() is basically just an alias for Environment::isCli(). I'm thinking it probably makes sense to deprecate Director::is_cli() and remove it in the next major release.

/**
* Returns true if this script is being run from the command line rather than the web server.
*
* @return bool
*/
public static function is_cli()
{
return Environment::isCli();
}

/**
* Returns true if this script is being run from the command line rather than the web server
*
* @return bool
*/
public static function isCli()
{
if (Environment::$isCliOverride !== null) {
return Environment::$isCliOverride;
}
return in_array(strtolower(php_sapi_name() ?? ''), ['cli', 'phpdbg']);
}

How to reproduce

Look at the code with your eyes.

Possible Solution

No response

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

Kitchen sink CI (green - all PRs below used in run of recipe-kitchen-sink)

PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions