Skip to content

Commit

Permalink
Adds first version
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jun 29, 2018
0 parents commit 8005d0d
Show file tree
Hide file tree
Showing 16 changed files with 409 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .gitattributes
@@ -0,0 +1,11 @@
/docs export-ignore
/tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
CHANGELOG.md export-ignore
CONTRIBUTING.md export-ignore
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
.idea/*
.idea/codeStyleSettings.xml
composer.lock
/vendor/
coverage.xml
23 changes: 23 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,23 @@
checks:
php:
code_rating: true
duplication: true

filter:
excluded_paths:
- tests/*

build:
environment:
php:
version: '7.2'
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
-
command: 'vendor/bin/phpunit --coverage-clover=coverage.clover'
coverage:
file: 'coverage.clover'
format: 'clover'
3 changes: 3 additions & 0 deletions .styleci.yml
@@ -0,0 +1,3 @@
preset: laravel
disabled:
- self_accessor
21 changes: 21 additions & 0 deletions .travis.yml
@@ -0,0 +1,21 @@
language: php

sudo: false

php:
- 7.1.3
- 7.2
- nightly

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- vendor/bin/phpstan analyse -l max src
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,8 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
- Adds first version
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,17 @@
CONTRIBUTING
============


Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests.


## Guidelines

* Please follow the [PSR-2 Coding Style Guide](http://www.php-fig.org/psr/psr-2/), enforced by [StyleCI](https://styleci.io/).
* Ensure that the current tests pass, and if you've added something new, add the tests where relevant.
* Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
* You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.
* If you are changing the behavior, or the public api, you may need to update the docs.
* Please remember that we follow [SemVer](http://semver.org/).

We have [StyleCI](https://styleci.io/) setup to automatically fix any code style issues.
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Nuno Maduro <enunomaduro@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
<p align="center">
<img src="https://raw.githubusercontent.com/laravel-code-analyse/master/docs/example.png" alt="Laravel Code Analyse Example" height="300">
</p>

<p align="center">
<a href="https://travis-ci.org/laravel-code-analyse"><img src="https://img.shields.io/travis/laravel-code-analyse/master.svg" alt="Build Status"></img></a>
<a href="https://scrutinizer-ci.com/g/laravel-code-analyse"><img src="https://img.shields.io/scrutinizer/g/laravel-code-analyse.svg" alt="Quality Score"></img></a>
<a href="https://scrutinizer-ci.com/g/laravel-code-analyse"><img src="https://img.shields.io/scrutinizer/coverage/g/laravel-code-analyse.svg" alt="Coverage"></img></a>
<a href="https://packagist.org/packages/laravel-code-analyse"><img src="https://poser.pugx.org/laravel-code-analyse/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel-code-analyse"><img src="https://poser.pugx.org/laravel-code-analyse/v/stable.svg" alt="Latest Version"></a>
<a href="https://packagist.org/packages/laravel-code-analyse"><img src="https://poser.pugx.org/laravel-code-analyse/license.svg" alt="License"></a>
</p>

## About Laravel Code Analyse

Laravel Code Analyse was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a [](https://github.com/phpstan/phpstan) wrapper for Laravel.

## Installation & Usage

> **Requires [PHP 7.1.3+](https://php.net/releases/)**
You may use [Composer](https://getcomposer.org) to install Laravel Code Analyse into your Laravel project:
```bash
composer require nunomaduro/laravel-code-analyse
```

Once you have installed Laravel Code Analyse, you may start analyzing your code using the `code:analyse` Artisan command.
```bash
php artisan code:analyse
```

## Contributing

Thank you for considering to contribute to Laravel Code Analyse. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).

You can have a look at the [CHANGELOG](CHANGELOG.md) for constant updates & detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: [@enunomaduro](https://twitter.com/enunomaduro)

## Support the development
**Do you like this project? Support it by donating**

- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
- Patreon: [Donate](https://www.patreon.com/nunomaduro)

## License

Laravel Code Analyse is an open-sourced software licensed under the [MIT license](LICENSE.md).
46 changes: 46 additions & 0 deletions composer.json
@@ -0,0 +1,46 @@
{
"name": "nunomaduro/laravel-code-analyse",
"description": "Laravel Code Analyse - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
"keywords": ["laravel", "php", "package", "static analysis", "code analysis", "code analyse"],
"license": "MIT",
"authors": [
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"require": {
"php": "^7.1.3",
"phpstan/phpstan": "^0.9",
"symfony/process": "^4.1",
"laravel/framework": "5.6.*",
"weebly/phpstan-laravel": "^1.1"
},
"require-dev": {
"orchestra/testbench": "^3.6",
"phpunit/phpunit": "^7.2"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"NunoMaduro\\LaravelCodeAnalyse\\": "src/"
}
},
"config": {
"sort-packages": true,
"preferred-install": "dist"
},
"extra": {
"laravel": {
"providers": [
"NunoMaduro\\LaravelCodeAnalyse\\LaravelCodeAnalyseServiceProvider"
]
}
}
}
Binary file added docs/example.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
58 changes: 58 additions & 0 deletions src/Console/CodeAnalyseCommand.php
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* This file is part of Laravel Code Analyse.
*
* (c) Nuno Maduro <enunomaduro@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace NunoMaduro\LaravelCodeAnalyse\Console;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

final class CodeAnalyseCommand extends Command
{
/**
* @var \Illuminate\Foundation\Application
*/
protected $laravel;

/**
* {@inheritdoc}
*/
protected $signature = 'code:analyse {level=max}';

/**
* {@inheritdoc}
*/
protected $description = 'Analyses source code';

/**
* {@inheritdoc}
*/
public function handle(): void
{
$params = [
'./phpstan',
'analyse',
'--level='.$this->argument('level'),
'--autoload-file='.$this->laravel->basePath('vendor/autoload.php'),
'--configuration='.$this->laravel->basePath('vendor/weebly/phpstan-laravel/extension.neon'),
$this->laravel['path'],
];

$process = new Process(implode(' ', $params), $this->laravel->basePath('vendor/bin'));
$process->setTty(true);
$process->start();

foreach ($process as $type => $data) {
$this->output->writeln($data);
}
}
}
30 changes: 30 additions & 0 deletions src/LaravelCodeAnalyseServiceProvider.php
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* This file is part of Laravel Code Analyse.
*
* (c) Nuno Maduro <enunomaduro@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace NunoMaduro\LaravelCodeAnalyse;

use Illuminate\Support\ServiceProvider;
use NunoMaduro\LaravelCodeAnalyse\Console\CodeAnalyseCommand;

final class LaravelCodeAnalyseServiceProvider extends ServiceProvider
{
/**
* {@inheritdoc}
*/
public function register(): void
{
if ($this->app->runningInConsole() && ! $this->app->runningUnitTests()) {
$this->commands(CodeAnalyseCommand::class);
}
}
}

0 comments on commit 8005d0d

Please sign in to comment.