22h/code-analyser

v0.1 2017-09-12 18:57 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:27:14 UTC


README

此存储库为实验性。

使用此存储库,我想解决我自己的项目的一些问题。例如,单元测试中不正确的命名空间。

PHP Unit 不需要命名空间,因此它们通常都是错误的。

安装

你只需要 composer

composer require 22h/code-analyser --dev

命令

在所有自动加载文件夹中搜索异常

bin/code-analyser code-analyser:exceptions

递归搜索 vendor 文件夹中的异常

bin/code-analyser code-analyser:exceptions -d vendor

在自动加载文件夹中搜索不正确的命名空间

bin/code-analyser code-analyser:namespaces

示例输出命名空间

$ php code-analyser code-analyser:namespaces
 
Lookup autoload paths
---------------------
 
 ------ ------------------------------- --------
  env    namespace                       folder
 ------ ------------------------------- --------
  prod   TwentyTwo\CodeAnalyser\         src
  dev    TwentyTwo\CodeAnalyser\Tests\   tests
 ------ ------------------------------- --------
 
Search matching files
---------------------
 
 Find 11 matching files in directories
 
Search incorrect namespaces
---------------------------
 
 11/11 [============================] 100%
 
List incorrect namespaces
-------------------------
 
 ------------------- ------------------------------------
  File                tests/\Test\Wrang.php
  Current Namespace   TwentyTwo\CodeAnalyserA\Tests\Test
  New Namespace       TwentyTwo\CodeAnalyser\Tests\Test
 ------------------- ------------------------------------
 
 ------------------- -------------------------------
  File                tests/\Wrong.php
  Current Namespace   TwentyTwo\CodeAnalyser2\Tests
  New Namespace       TwentyTwo\CodeAnalyser\Tests
 ------------------- -------------------------------

示例输出异常

$ php code-analyser code-analyser:exceptions
 
Lookup autoload paths
---------------------
 
 ------ ------------------------------- --------
  env    namespace                       folder
 ------ ------------------------------- --------
  prod   TwentyTwo\CodeAnalyser\         src
  dev    TwentyTwo\CodeAnalyser\Tests\   tests
 ------ ------------------------------- --------
 
Search matching files
---------------------
 
 Find 12 matching files in directories
 
Search exceptions
-----------------
 
 12/12 [============================] 100%
 
List founded exceptions
-----------------------
 
 ------------------------------- ----------------------------------
  exception                       files
 ------------------------------- ----------------------------------
  ComposerFileNotFoundException   src\Composer.php
  ComposerFileNotFoundException   tests/\Test\Wrang.php
  FileNotFoundException           src\Autoload\CheckFile.php
  FileNotFoundException           src\FindExceptions\CheckFile.php
  Exception                       tests/\Test\Wrang.php
 ------------------------------- ----------------------------------
 
List grouped exceptions
-----------------------
 
 ------------------------------- -------
  exception                       count
 ------------------------------- -------
  ComposerFileNotFoundException   2
  FileNotFoundException           2
  Exception                       1
 ------------------------------- -------
 
 [OK] find 5 exceptions