2017 © Pedro PelĆ”ez
 

library linter

Memio's linter, a set of constraint that check models for syntax errors

image

memio/linter

Memio's linter, a set of constraint that check models for syntax errors

  • Friday, March 2, 2018
  • by gnupat
  • Repository
  • 1 Watchers
  • 2 Stars
  • 118,267 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 8 % Grown

The README.md

Memio's Linter

A set of Memio constraints that check Memio models for syntax errors and the likes., (*1)

Note: This package is part of Memio, a highly opinionated PHP code generator. Have a look at the main repository., (*2)

Installation

Install it using Composer:, (*3)

$ composer require memio/linter:^3.0

Example

Usually we'd have to install Memio and use its Build::linter() method to get a linter validator., (*4)

The atlernative would be to build manually the validator as follow:, (*5)

<?php

require __DIR__.'/vendor/autoload.php';

use Memio\Validator\Constraint\ArgumentCannotBeScalar;
use Memio\Validator\Constraint\CollectionCannotHaveNameDuplicates;
use Memio\Validator\Constraint\ConcreteObjectMethodsCannotBeAbstract;
use Memio\Validator\Constraint\ContractMethodsCanOnlyBePublic;
use Memio\Validator\Constraint\ContractMethodsCannotBeFinal;
use Memio\Validator\Constraint\ContractMethodsCannotBeStatic;
use Memio\Validator\Constraint\ContractMethodsCannotHaveBody;
use Memio\Validator\Constraint\MethodCannotBeAbstractAndHaveBody;
use Memio\Validator\Constraint\MethodCannotBeBothAbstractAndFinal;
use Memio\Validator\Constraint\MethodCannotBeBothAbstractAndPrivate;
use Memio\Validator\Constraint\MethodCannotBeBothAbstractAndStatic;
use Memio\Validator\Constraint\ObjectArgumentCanOnlyDefaultToNull;
use Memio\Validator\ModelValidator\ArgumentValidator;
use Memio\Validator\ModelValidator\CollectionValidator;
use Memio\Validator\ModelValidator\MethodValidator;
use Memio\Validator\ModelValidator\ContractValidator;
use Memio\Validator\ModelValidator\ObjectValidator;
use Memio\Validator\ModelValidator\FileValidator;
use Memio\Validator\Validator;

$argumentValidator = new ArgumentValidator();
$argumentValidator->add(new ArgumentCannotBeScalar());

$collectionValidator = new CollectionValidator();
$collectionValidator->add(new CollectionCannotHaveNameDuplicates());

$methodValidator = new MethodValidator($argumentValidator, $collectionValidator);
$methodValidator->add(new MethodCannotBeAbstractAndHaveBody());
$methodValidator->add(new MethodCannotBeBothAbstractAndFinal());
$methodValidator->add(new MethodCannotBeBothAbstractAndPrivate());
$methodValidator->add(new MethodCannotBeBothAbstractAndStatic());

$contractValidator = new ContractValidator($collectionValidator, $methodValidator);
$contractValidator->add(new ContractMethodsCanOnlyBePublic());
$contractValidator->add(new ContractMethodsCannotBeFinal());
$contractValidator->add(new ContractMethodsCannotBeStatic());
$contractValidator->add(new ContractMethodsCannotHaveBody());

$objectValidator = new ObjectValidator($collectionValidator, $methodValidator);
$objectValidator->add(new ConcreteObjectMethodsCannotBeAbstract());
$objectValidator->add(new ObjectArgumentCanOnlyDefaultToNull());

$fileValidator = new FileValidator($contractValidator, $objectValidator);

$linter = new Validator();
$linter->add($argumentValidator);
$linter->add($collectionValidator);
$linter->add($methodValidator);
$linter->add($contractValidator);
$linter->add($objectValidator);
$linter->add($fileValidator);

$linter->validator($anyModels);

Have a look at the main respository to discover the full power of Medio., (*6)

Want to know more?

Memio uses phpspec, which means the tests also provide the documentation. Not convinced? Then clone this repository and run the following commands:, (*7)

$ composer install
$ ./vendor/bin/phpspec run -n -f pretty

You can see the current and past versions using one of the following:, (*8)

And finally some meta documentation:, (*9)

The Versions

02/03 2018

dev-master

9999999-dev http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

02/03 2018

v2.0.3

2.0.3.0 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

27/09 2016

dev-version-2

dev-version-2 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

27/09 2016

v2.0.0-alpha2

2.0.0.0-alpha2 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

27/09 2016

v2.0.0

2.0.0.0 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

25/09 2016

v2.0.0-alpha1

2.0.0.0-alpha1 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

01/12 2015

v1.0.2

1.0.2.0 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

29/04 2015

v1.0.1

1.0.1.0 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator

20/04 2015

v1.0.0

1.0.0.0 http://memio.github.io/memio

Memio's linter, a set of constraint that check models for syntax errors

  Sources   Download

MIT

The Requires

 

The Development Requires

php code generator