1. Go to this page and download the library: Download glhd/laralint library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
glhd / laralint example snippets
class Foo
{
public function bar()
{
return 'baz';
}
}
(new TreeMatcher())
// (1) Find a method declaration where the method name is "bar"
->withChild(function(MethodDeclaration $node) {
return 'bar' === $node->getName();
})
// (2) Find any return statement
->withChild(ReturnStatement::class)
// (3) Find a string literal that matches the string "baz"
->withChild(function(StringLiteral $node) {
return 'baz' === $node->getStringContentsText();
})
->onMatch(function(Collection $all_matched_nodes) {
// Create a linting result using the matched nodes.
// LaraLint will automatically map the AST nodes to line
// numbers when printing the results.
});