Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Linter Laravel Package

memio/linter

Memio Linter provides a set of Memio Validator constraints to lint Memio models for syntax and structural issues. Use it standalone or as part of the Memio code generator to validate arguments, methods, contracts, objects, files, and collections.

View on GitHub
Deep Wiki
Context7

Memio's Linter

A set of Memio constraints that check Memio models for syntax errors and the likes.

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

Installation

Install it using Composer:

$ 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.

The atlernative would be to build manually the validator as follow:

<?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.

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:

make lib-init                        # Set up Docker environment
make phpspec arg='--format pretty'   # Run the specifications

Note: Run make or make help to see all available commands.

You can see the current and past versions using one of the following:

And finally some meta documentation:

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor