Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.43 KB

File metadata and controls

42 lines (30 loc) · 1.43 KB

Annotations

The following annotations are available in the debug package.

Deprecated(string $message)

When declared on a class, the Deprecated annotation marks a class as deprecated and will log a notice, and a custom message, anytime the class is instantiated. The logger defined in Titon\Debug\Debugger will be used for logging.

To mark a class as deprecated, declare the annotation, and then wire it up in the constructor.

<<Deprecated('Please use Bar instead.')>>
class Foo {
    use Titon\Annotation\WiresAnnotations;

    public function __construct() {
        $this->wireClassAnnotation('Deprecated');
    }
}

Monitor([string $callback])

Similar to the Deprecated annotation, the Monitor annotation will log an informational message anytime the class is instantiated. This message will include a file path and line number for the location in which the instantiation occurred.

<<Monitor>>
class Foo {
    use Titon\Annotation\WiresAnnotations;

    public function __construct() {
        $this->wireClassAnnotation('Monitor');
    }
}

Furthermore, the Monitor annotation accepts an optional callback that will be triggered when the annotation is wired. This allows for userland code to hook into the monitoring process. The callback can either be a function, or a static class method.

<<Monitor('global_function')>>
<<Monitor('Foo::staticMethod')>>