Deprecation
class Deprecation (View source)
Handles raising an notice when accessing a deprecated method, class, configuration, or behaviour.
Sometimes we want to mark that a method will be deprecated in some future version and shouldn't be used in new code, but not forbid in the current version - for instance when that method is still heavily used in framework or cms.
See https://docs.silverstripe.org/en/contributing/release_process/#deprecation
Constants
SCOPE_METHOD |
|
SCOPE_CLASS |
|
SCOPE_GLOBAL |
|
SCOPE_CONFIG |
|
Methods
Enable throwing deprecation warnings. By default, this excludes warnings for deprecated code which is called by core Silverstripe modules.
Used to wrap deprecated methods and deprecated config get()/set() called from the vendor dir that projects have no ability to change.
Used to wrap deprecated methods and deprecated config get()/set() called from the vendor dir that projects have no ability to change.
Given a backtrace, get the method name from the immediate parent caller (the caller of #notice)
Check whether a file (path to file) is in a supported module
If true, any E_USER_DEPRECATED errors should be treated as coming directly from this class.
Determine whether deprecation warnings should be included in HTTP responses.
Determine whether deprecation warnings should be included in CLI responses.
If true, deprecation warnings should be included in HTTP responses.
If true, deprecation warnings should be included in CLI responses.
If true, deprecation warnings will be shown for deprecated code which is called by core Silverstripe modules.
Set whether deprecation warnings will be shown for deprecated code which is called by core Silverstripe modules.
Raise a notice indicating the method is deprecated if the version passed as the second argument is greater than or equal to the check version set via ::notification_version
Shorthand method to create a suppressed notice for something with no immediate replacement.
Details
static void
enable(bool $showNoReplacementNotices = false)
Enable throwing deprecation warnings. By default, this excludes warnings for deprecated code which is called by core Silverstripe modules.
This will be overriden by the SS_DEPRECATION_ENABLED environment variable if present.
static void
disable()
Disable throwing deprecation warnings.
This will be overriden by the SS_DEPRECATION_ENABLED environment variable if present.
static mixed
withNoReplacement(callable $func)
deprecated
deprecated
Used to wrap deprecated methods and deprecated config get()/set() called from the vendor dir that projects have no ability to change.
static mixed
withSuppressedNotice(callable $func)
Used to wrap deprecated methods and deprecated config get()/set() called from the vendor dir that projects have no ability to change.
static protected string
get_called_method_from_trace($backtrace, $level = 1)
Given a backtrace, get the method name from the immediate parent caller (the caller of #notice)
static bool
fileIsInSupportedModule(string $file)
Check whether a file (path to file) is in a supported module
static bool
isEnabled()
No description
static bool
isTriggeringError()
If true, any E_USER_DEPRECATED errors should be treated as coming directly from this class.
static void
setShouldShowForHttp(bool $value)
Determine whether deprecation warnings should be included in HTTP responses.
Does not affect logging.
This will be overriden by the SS_DEPRECATION_SHOW_HTTP environment variable if present.
static void
setShouldShowForCli(bool $value)
Determine whether deprecation warnings should be included in CLI responses.
Does not affect logging.
This will be overriden by the SS_DEPRECATION_SHOW_CLI environment variable if present.
static bool
shouldShowForHttp()
If true, deprecation warnings should be included in HTTP responses.
Does not affect logging.
static bool
shouldShowForCli()
If true, deprecation warnings should be included in CLI responses.
Does not affect logging.
static bool
getShowNoticesCalledFromSupportedCode()
If true, deprecation warnings will be shown for deprecated code which is called by core Silverstripe modules.
static void
setShowNoticesCalledFromSupportedCode(bool $value)
Set whether deprecation warnings will be shown for deprecated code which is called by core Silverstripe modules.
static void
outputNotices()
No description
static
notice(string $atVersion, string $string = '', int $scope = Deprecation::SCOPE_METHOD)
Raise a notice indicating the method is deprecated if the version passed as the second argument is greater than or equal to the check version set via ::notification_version
static void
noticeWithNoReplacment(string $atVersion, string $message = '', int $scope = Deprecation::SCOPE_METHOD)
Shorthand method to create a suppressed notice for something with no immediate replacement.
If $message is empty, then a standardised message will be used