-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added command
- Loading branch information
Showing
267 changed files
with
14,088 additions
and
488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/.idea/ | ||
/codecoverage/ | ||
/vendor/ | ||
/var/ | ||
php-analyzer.phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: php | ||
|
||
php: | ||
- '7.1' | ||
- '7.2' | ||
- '7.3' | ||
- '7.4snapshot' # beta1 | ||
#- nightly #8 (symfony does not support php 8 yet) | ||
|
||
before_install: | ||
- travis_retry composer install --no-interaction --prefer-source --dev | ||
|
||
script: | ||
- vendor/bin/phpunit --testsuite=unit,integration --coverage-clover=coverage.xml | ||
|
||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) | ||
|
||
notifications: | ||
email: | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# How to contribute | ||
|
||
Thanks for considering to contribute to `php-analyzer`. While doing so please follow these guidelines: | ||
|
||
- You must follow the `isfett-coding-standard` ([link](https://www.github.com/isfett/coding-standard)). Add the phpcs and phpmd settings to your ide. If you use PhpStorm import the inspections.xml also. | ||
- All non trivial features or bugfixes must have an associated issue for discussion. If you want to work on an issue that is already created, please leave a comment on it indicating that you are working on it. | ||
- Add tests for features or bugfixes touching `src` code if you want to increase the chance of your contribution being merged. | ||
- You must use [feature / topic branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows) to ease the merge of your contribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Christopher Stenke | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
php-analyzer | ||
[![Build Status](https://img.shields.io/travis/isfett/php-analyzer/master?style=flat-square)](https://travis-ci.org/isfett/php-analyzer) | ||
[![codecov](https://img.shields.io/codecov/c/github/isfett/php-analyzer?style=flat-square)](https://codecov.io/gh/isfett/php-analyzer) | ||
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/) | ||
[![Latest Stable Version](https://poser.pugx.org/isfett/php-analyzer/v/stable)](https://packagist.org/packages/isfett/php-analyzer) | ||
[![Total Downloads](https://poser.pugx.org/isfett/php-analyzer/downloads)](https://packagist.org/packages/isfett/php-analyzer) | ||
# PHP-Analyzer | ||
|
||
`php-analyzer` is a tool that aims to help you for different tasks. Mostly I found that I want to resolve them while doing my job. For details check the documented commands below. | ||
|
||
## Installation | ||
Run | ||
``` | ||
$ composer global require isfett/php-analyzer | ||
``` | ||
or download the latest phar from [this repository](https://github.com/isfett/php-analyzer/releases). | ||
|
||
## Usage | ||
For usages of the commands, check the documentation of each command. | ||
|
||
## Information | ||
This tool uses [a php parser written in php](https://github.com/nikic/PHP-Parser), ignoring different code-style or whitespaces. | ||
|
||
## Commands | ||
- [Most used conditions](docs/MostUsedConditions.md) Helps to check which conditions are used the most in your project. Just want to check if's? Or ternaries? No Problem! You can also split by logical operators, or split isset functions for each parameter. Including post-processing your conditions, flip-checking etc. You can find many examples within the link. | ||
|
||
## Planned | ||
- Magic Number Detector | ||
- Magic String Detector | ||
- Find duplicate code (ignoring codestyle, just checking statements) | ||
|
||
## Contributing | ||
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information. | ||
|
||
## License | ||
The MIT License (MIT). Please see [LICENSE](LICENSE) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
use Symfony\Component\Finder\Finder; | ||
use Isfett\PhpAnalyzer\Kernel; | ||
|
||
// The php.ini setting phar.readonly must be set to 0 | ||
$pharFilename = 'php-analyzer.phar'; | ||
|
||
// clean up | ||
if (file_exists($pharFilename)) { | ||
unlink($pharFilename); | ||
} | ||
|
||
// Make vendor with no dev requirements | ||
shell_exec('composer update --no-dev --quiet'); | ||
|
||
// delete cache+logs | ||
shell_exec('rm -R var'); | ||
|
||
// Build container | ||
$kernel = new Kernel('prod', false); | ||
$kernel->boot(); | ||
|
||
$finder = (new Finder()) | ||
->files() | ||
->in(dirname(__DIR__)) | ||
->notName('phar.php') | ||
->exclude(['codecoverage', 'docs', 'tests']); | ||
|
||
// create phar | ||
$phar = new Phar($pharFilename); | ||
|
||
// creating our library using whole directory | ||
$phar->buildFromIterator($finder->getIterator(), dirname(__DIR__)); | ||
|
||
// pointing main file which requires all classes | ||
$phar->setStub( | ||
"#!/usr/bin/env php | ||
<?php | ||
putenv('APPLICATION_ENV=prod'); | ||
Phar::mapPhar('$pharFilename'); | ||
require 'phar://$pharFilename/bin/php-analyzer.php'; | ||
__HALT_COMPILER();" | ||
); | ||
|
||
// reset vendor with dev requirements | ||
shell_exec('composer update --quiet'); | ||
|
||
echo sprintf('%s successfully created', $pharFilename) . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require 'php-analyzer.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@echo off | ||
|
||
if "%PHP_PEAR_PHP_BIN%" neq "" ( | ||
set PHPBIN=%PHP_PEAR_PHP_BIN% | ||
) else set PHPBIN=php | ||
|
||
"%PHPBIN%" "%~dp0\php-analyzer.php" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php'; | ||
|
||
use Isfett\PhpAnalyzer\Kernel; | ||
use Isfett\PhpAnalyzer\Console\Application; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
||
$environment = $_SERVER['APPLICATION_ENV'] ?? 'dev'; | ||
if (false !== getenv('APPLICATION_ENV')) { | ||
$environment = getenv('APPLICATION_ENV'); | ||
} | ||
$isDebug = 'dev' === $environment; | ||
|
||
require_once 'vendor/autoload.php'; | ||
$dispatcher = new EventDispatcher(); | ||
$kernel = new Kernel($environment, $isDebug); | ||
$kernel->boot(); | ||
|
||
$application = new Application(); | ||
$application->run(); | ||
$container = $kernel->getContainer(); | ||
$application = $container->get(Application::class); | ||
$application->setDispatcher($dispatcher); | ||
$application->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.