Projets perso : JoliNotif et php7-checker

Sfpot - Loïck Piera - Septembre 2015

Projets perso : JoliNotif et php7-checker

Sfpot - Loïck Piera - Septembre 2015

Coucou, moi c'est Loïck Piera

JoliNotif

PHP

PHP dans la console

Process long ?

Desktop notification

Mac OS Linux Windows
Growl notify-send Notifu (Windows 7)
terminal-notifier Toaster (Windows 8+)
AppleScript (Mac OS X 10.8+)

Evidemment chacun a ses propres syntaxes et options

JoliNotif

« Fait voir du code »

/** @var \Joli\JoliNotif\Notifier|null $notifier */
$notifier = Joli\JoliNotif\NotifierFactory::create();
if ($notifier) {
    $notification =
        (new Joli\JoliNotif\Notification())
        ->setBody('The notification body')
        ->setTitle('The notification title')
        ->setIcon(__DIR__.'/Resources/icons/success.png');
    ;

    $notifier->send($notification);
}

Démo

Projets utilisant JoliNotif

php7-checker

C'est quoi ?

AST


echo 'Hi', 'World';
hello\world('foo', 'bar' . 'baz');
array(
    0: Stmt_Echo(
        exprs: array(
            0: Scalar_String(
                value: Hi
            )
            1: Scalar_String(
                value: World
            )
        )
    )
    1: Expr_FuncCall(
        name: Name(
            parts: array(
                0: hello
                1: world
            )
        )
        args: array(
            0: Arg(
                value: Scalar_String(
                    value: foo
                )
                byRef: false
            )
            1: Arg(
                value: Expr_Concat(
                    left: Scalar_String(
                        value: bar
                    )
                    right: Scalar_String(
                        value: baz
                    )
                )
                byRef: false
            )
        )
    )
)

Visiteurs

Visiteurs

namespace PhpParser\NodeVisitor;

interface NodeVisitor {
    public function beforeTraverse(array $nodes) {}

    public function enterNode(Node $node) {}

    public function leaveNode(Node $node) {}

    public function afterTraverse(array $nodes) {}
}

Exemple de visiteur

class NewAssignmentByReferenceChecker extends AbstractChecker
{
    public function leaveNode(Node $node)
    {
        if ($node instanceof Node\Expr\AssignRef) {
            if ($node->expr instanceof Node\Expr\New_) {
                $this->errorCollection->add(new Error(
                    $this->parserContext->getFilename(),
                    $node->getLine(),
                    'New objects cannot be assigned by reference.'
                ));
            }
        }
    }
}

Checks

Démo

Collaborer c'est mieux :)

Merci de votre attention

https://pyrech.github.io/sfpot-septembre-2015

Des questions ?