API / Minn\Runtime / Notices

Notices final class

Minn\Runtime\Notices · public/minn/src/Minn/Runtime/Notices.php · 96 lines

The debugging notices plugins and the engine raise: a deprecated function, argument, hook, file, class or constructor, and a function called incorrectly. Each is heard by its action first; then, only under WP_DEBUG and while its own filter still says so, it is raised as a PHP notice worded as the reference words it. Every raised message passes wp_trigger_error_always_run, wp_trigger_error_trigger_error and wp_trigger_error_run, and keeps only links (http and https), line breaks, code and emphasis. Values reach the hooks exactly as they were given.

Constants and properties

privateMARKUP = array ( 'a' => array ( 0 => 'href', ), 'br' => array ( ), 'code' => array ( ), 'em' => array ( ), 'strong' => array ( ), )

The markup a raised notice keeps (each element with its attributes), and the protocols its links may use.

privatePROTOCOLS = array ( 0 => 'http', 1 => 'https', )
privateDEPRECATIONS = array ( 'function' => array ( 0 => 'deprecated_function_run', 1 => 'deprecated_function_trigger_error', 2 => 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 3 => 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 4 => false, ), 'argument' => array ( 0 => 'deprecated_argument_run', 1 => 'deprecated_argument_trigger_error', 2 => 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', 3 => 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', 4 => false, ), 'hook' => array ( 0 => 'deprecated_hook_run', 1 => 'deprecated_hook_trigger_error', 2 => 'Hook %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 3 => 'Hook %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 4 => true, ), 'file' => array ( 0 => 'deprecated_file_included', 1 => 'deprecated_file_trigger_error', 2 => 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 3 => 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 4 => true, ), 'class' => array ( 0 => 'deprecated_class_run', 1 => 'deprecated_class_trigger_error', 2 => 'Class %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 3 => 'Class %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 4 => false, ), )

Each kind of deprecation: the action that hears it, the filter that may silence it, its wording with an alternative and without one, and whether a closing note follows the wording (and is heard after the version).

Public

staticwanted(string $filter, mixed ...$args): bool#

Whether a notice is raised: only under WP_DEBUG, and only while its filter (handed true and anything else given) still says so.

staticdeprecated(string $kind, mixed $name, mixed $version, mixed $alternative = '', mixed $note = ''): void#

A deprecation of one kind (function, argument, hook, file or class): its name, the version that deprecated it, the alternative (for an argument, the message), and for a hook or a file a note added after the wording.

staticconstructor(mixed $class, mixed $version, mixed $parent = ''): void#

A class still constructed through its old PHP 4 style constructor, in its parent class when one is named.

staticdoingItWrong(mixed $function, mixed $message, mixed $version): void#

A function called incorrectly, with why, and the version that added the message.

staticmessage(mixed $function, mixed $message, mixed $level): ?string#

A notice's message as it would be raised, or null when it is not: wp_trigger_error_always_run hears every one; under WP_DEBUG, and unless wp_trigger_error_trigger_error silences it, wp_trigger_error_run hears it and it is cleaned to the markup a notice keeps.

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatenotify(string $message, int $level = Minn\Runtime\E_USER_NOTICE): void#

One of the engine's own notices, raised when it is wanted.