Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.72 KB

event.md

File metadata and controls

45 lines (29 loc) · 1.72 KB

PHPLint uses the Symfony Event-Dispatcher Component to communicate with each internal element's by dispatching events and listening to them.

That's allow to easily add new Extension (like progress bar and meter widgets), but also new output formats.

UML Diagram

UML Diagram

Generated by bartlett/graph-uml package via the resources/graph-uml/build.php script.

The Dispatcher

The dispatcher is the central object of the event dispatcher system. It accepts a list of Extension objects that will extend PHPLint features (widgets, output formats, ...)

Each Extension that will add new listeners must implement the Symfony EventSubscriberInterface and also must implement one or more following PHPLint Event Interface:

  • BeforeCheckingInterface: called before lint begins to run
  • AfterCheckingInterface : called after lint is completed
  • BeforeLintFileInterface: called before a file has been checked
  • AfterLintFileInterface: called after a file has been checked

Example(s)

Default progress printer widget:

<?php
use Overtrue\PHPLint\Event\EventDispatcher;
use Overtrue\PHPLint\Extension\ProgressPrinter;

$extensions = [new ProgressPrinter()];

$dispatcher = new EventDispatcher($extensions);