Giter VIP home page Giter VIP logo

phplint's Introduction

PHPLint

`phplint` is a tool that can speed up linting of php files by running several lint processes at once.

Release Status Latest Stable Version Total Downloads License FOSSA Status

Version Status Requirements
9.1 Active development PHP >= 8.1
9.0 Active support PHP >= 8.0
6.x Active support PHP >= 8.2
5.x Active support PHP >= 8.1
4.x End Of Life PHP >= 8.0
3.x End Of Life PHP >= 7.4

NOTE if you have an older version of PHP lower than 8.0, we recommend to use the latest version 3.4.0

Version 9.1 is based on 9.0 code but did not support anymore PHP 8.0 that reached End-Of-Life.

Major version 9.0 is a full code rewrites that have the same source code (main branch) for all PHP 8.x versions (4.x, 5.x or 6.x), with a lot of improvement, full documentation, and full unit code tested.

Table of Contents

  1. Installation
    1. Requirements
    2. PHAR
    3. Docker
    4. Phive
    5. Composer
  2. Usage
  3. Configuration
  4. Upgrading
  5. Contributing
  6. Architecture

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT

phplint's People

Contributors

backendtea avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar eclipxe13 avatar fossabot avatar funivan avatar gdubicki avatar hemberger avatar hnczy avatar jeroeny avatar koenigmathieu avatar ktamas77 avatar kubawerlos avatar llaville avatar ltscommerce avatar lzhang avatar matheusab avatar myks92 avatar overtrue avatar rmrhz avatar sarcastron avatar scrutinizer-auto-fixer avatar srt4rulez avatar summerblue avatar ttomdewit avatar tuupola avatar vkryklyvenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phplint's Issues

composer require overtrue/phplint失败

我执行composer require overtrue/phplint好长时间,终端一直卡在加载界面,尝试是composer.json权限问题,于是修改权限777,还是不行,最后还是手动修改composer.json解决的

The path specified in the config file isn't loaded anymore

Hey :) !

PHPLint has a regression since its 1.2.2 version because of this exact line change ^^ : src/Command/LintCommand.php on line 404.

The command isn't able to load the path from the config file anymore, but still works as expected when it is provided via the CLI argument x) !

Version identifier for 2.0.0 release marked as 1.2.5 in package

My composer.json is pulling version 2.0 for the current phplint package:

"overtrue/phplint": "^2.0",

In the library, the version is reflected as 1.2.5:

/var/www $ vendor/bin/phplint --version
phplint 1.2.5

Should be a simple bug/fix. Wanted to point it out so future issues and documentation can be properly reported.

JUnit output

Is there a plan to extend this great tool to produce JUnit standard XML output for reporting tools?
Or is there an easy way to convert the available json output to JUnit XML?

Syntax Error in 7.4

There seems to be a syntax error on the 7.4-branch:

PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /root/.composer/vendor/overtrue/phplint/src/Linter.php on line 21

Available as a PHAR?

Is this available as a standalone PHAR? If not could it be, under Releases I can see source code downloads but if a standalone package was to be distributed that would be a good place to store it under?

Read configuration file

It would be better if the project can provide an option where it will a configuration file to read in linting specific folders or files instead of explicitly define them over the cli.

cache store whould only be called once

I think the line where cache is stored $cache && Cache::put($newCache); shoud be outside the loop.

As it is inside the main loop (while there are still ending files or running processes) the action of persist the cache array is called several times.

The main loop in Linter::lint exits after all files has been linted, and it populates the arrays $errors, $newCache. Once the loop is over then the cache must be persisted.

Please consider move $cache && Cache::put($newCache); outside the main loop.

Bug not reflecting the right error message

Hi, I did a scan and i see bugs error returning this

home/vagrant/Code/helixtap/app/Analytic.php: {
file: "/home/vagrant/Code/helixtap/app/Analytic.php",
error: "Usage: php-fpm7.0 [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F [-O]]",
line: 0
},

Am i missing something?

Exit with 0 on empty files

We're running phplint like this:

git whatchanged --name-only --pretty="" origin..HEAD | sort | uniq | xargs ~/.composer/vendor/bin/phplint

Would it be possible to return 0 if no files are linted?

Making symfony/console 3.2.0 the minimal requirement breaks some Laravel projects

#44

this breaks projects that use Laravel 5.2 or lower

    - laravel/framework v5.2.45 requires symfony/console 2.8.*|3.0.* -> satisfiable by symfony/console[v3.0.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.35, v2.8.36, v2.8.37, v2.8.38, v2.8.39, v2.8.4, v2.8.40, v2.8.41, v2.8.42, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8].

#14

can this be translate to English?

Identify warnings, as well as errors

The following code gives a warning during linting, but phplint does not notify the user of that.

<?php

class Foo
{
    private function bar(object $a) {
        while (true) {
            switch($a) {
                case 'b': 
                    continue;
            }
        }
    }
}

Running php -l on the file gives the following output:

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in a.php on line 9

I'd like to be able to see the warnings as well, perhaps with an additional flag to preserve the 'old behavior.

Github Action

A GitHub Action + support for GitHub annotation would be great.

"Inappropriate ioctl for device" when used as composer script

Hi,
first of all thank you for this great tool! Simple yet effective, just does what it's supposed to!

I noticed a small issue when being used as a script in composer.json. Running the phplint from the /vendor/bin directory directly works as expected:

phplint 0.2.4 by overtrue and contributors.

Loaded config from "/~/.phplint.yml"

Using cache.
E

Time: < 1 sec, Memory: 2.0 MiBMB

FAILURES!
Files: 6, Failures: 1

There was 1 errors:
1. /~/tests/Unit/Controller/ControllerTest.php:18
 unexpected '$service' (T_VARIABLE) in line 18

However, running it as a composer script (e.g. composer lint:syntax) will display stty warnings:

> ./vendor/bin/phplint
phplint 0.2.4 by overtrue and contributors.

Loaded config from "/~/.phplint.yml"

Using cache.
stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
E

Time: < 1 sec, Memory: 2.0 MiBMB

FAILURES!
Files: 6, Failures: 1

There was 1 errors:
1. /~/tests/Unit/Controller/ControllerTest.php:18
 unexpected '$service' (T_VARIABLE) in line 18
Script ./vendor/bin/phplint handling the lint:syntax event returned with error code 1

The script is defined in composer.json as follows:

"lint:syntax": "./vendor/bin/phplint"

I am using phplint 0.2.4 with PHP 7.2 and composer 1.5.6 on Ubuntu 17.10.

It is noteworthy that colors are working when running phplint directly (./vendor/bin/phplint) but not when being run from composer (composer lint:syntax). I guess that the stty error messages are related to the coloring of the phplint output.

Also note that I am successfully using composer scripts for other similar tools like phpcs, phpmd and phpunit, and no such error messages appear in any of these. Colors in phpunit are also working when being run through composer scripts.

If you need any additional information or I can do anything to resolve this issue, let me know.

Thanks!

$processCallback accessed before initialization

I've encountered an issue with version 3.0.2 upgrading from version 2.3.5 (using PHP 8.0.6):

Error: Typed property Overtrue\PHPLint\Linter::$processCallback must not be accessed before initialization

/smr/vendor/overtrue/phplint/src/Linter.php:37

This occurs with the following code:

        $paths = [ROOT];
        $excludes = ['vendor'];
        $linter = new Linter($paths, $excludes, warning: true);
        $linter->setProcessLimit(8); // multiprocessing

        // get errors
        $errors = $linter->lint();

Perhaps an isset($this->processCallback) check is needed in addition to the is_callable check on this line?

$processCallback = is_callable($this->processCallback) ? $this->processCallback : function () {

How to detect undefined parameters or variables

Hi @overtrue, is this package able to capture errors for undefined/uninitialized variables? For example

// $user = Auth::user(); <-- commented this out so $user is not initialized in next lin
$user->notify(new NewTicketPurchase());

will the package discover that the $user in second line is not initialized?

-q 指令的使用场景和检测结果的一次性输出需求

你好,
我在将这个工具集成到 capistrano 自动化部署的过程中,发现一个小小的问题

phplint 在输出检测结果的时候是动态输出的,这会导致 pty 将其认为是多次输出,从而将中间过程不停的输出到屏幕上

2016-08-15 2 53 27

使用 -q 参数后,所有的输出都没有了(包括报错),phplint 也没有输出到日志的设置,有点不理解 -q 的使用场景

PS: 是否考虑对 laravel 再多一点兼容,允许使用 php artisan phplint 来调用命令

似乎不支持 Laravel 5.1 😂

Laravel 5.1 的依赖:

    "require": {
        //...
        "symfony/console": "2.7.*",
    },

phplint:

  "require": {
    "php": ">=5.5.9",
    "symfony/console": "3.0.*|3.1.*",
    "symfony/finder": "3.0.*|3.1.*",
    "symfony/process": "3.0.*|3.1.*",
    "symfony/yaml": "3.0.*|3.1.*"
  },

于是 5.1 就装不上了

I ran against a magento repo

I ran the following

./vendor/bin/phplint ./app/code -j 10 -w

Is this linter suppose to catch an undefined variable?
I use vscode and it warns that my variable is undefined using intelephsense.
Is this linter suppose to pick that up?

Compatibility with PHP 8

While this package appears to be compatible with PHP 8 from a dependency perspective, it does not seem to work within my GitHub Actions.

It's failing with a syntax error for the new match statement.

    33|         $suffix = match ($this->code) {
  > 34|             3 => 'composer',
    35|             11 => 'branch',
    36|             default => 'generic',
    37|         };
 unexpected '=>' (T_DOUBLE_ARROW) in line 34

This may simply be a configuration issue, but my job is running PHP 8.0 via the shivammathur/setup-php@v2 step. Any guidance for ensuring this step uses PHP 8 would be appreciated. Thanks.

PHP Warning: proc_open() expects parameter 1 to be string

I am running int this warning that appears to halt execution. Running PHP 7.1.26. I'm using the yml file contents from the README, only with a modification to point to my project path.

After running into the error the first time, I did modify the code to var_dump() the contents of $commandline, which is the referenced argument in the error message.

$ ./vendor/bin/phplint -vvv
phplint 1.0.2 by overtrue and contributors.

Loaded config from "/vagrant/.phplint.yml"

Options: {"jobs":10,"exclude":["vendor"],"extensions":["php","module","inc"],"path":".\/public","configuration":"\/vagrant\/.phplint.yml","verbose":true}

/vagrant/vendor/symfony/process/Process.php:294:
array(5) {
  [0] =>
  string(12) "/usr/bin/php"
  [1] =>
  string(24) "-d error_reporting=E_ALL"
  [2] =>
  string(20) "-d display_errors=On"
  [3] =>
  string(2) "-l"
  [4] =>
  string(54) "/vagrant/public/includes/filetransfer/filetransfer.inc"
}
PHP Warning:  proc_open() expects parameter 1 to be string, array given in /vagrant/vendor/symfony/process/Process.php on line 296
PHP Stack trace:
PHP   1. {main}() /vagrant/vendor/overtrue/phplint/bin/phplint:0
PHP   2. Overtrue\PHPLint\Console\Application->run() /vagrant/vendor/overtrue/phplint/bin/phplint:32
PHP   3. Overtrue\PHPLint\Console\Application->doRun() /vagrant/vendor/symfony/console/Application.php:122
PHP   4. Overtrue\PHPLint\Console\Application->doRunCommand() /vagrant/vendor/symfony/console/Application.php:215
PHP   5. Overtrue\PHPLint\Command\LintCommand->run() /vagrant/vendor/symfony/console/Application.php:858
PHP   6. Overtrue\PHPLint\Command\LintCommand->execute() /vagrant/vendor/symfony/console/Command/Command.php:240
PHP   7. Overtrue\PHPLint\Command\LintCommand->executeLint() /vagrant/vendor/overtrue/phplint/src/Command/LintCommand.php:191
PHP   8. Overtrue\PHPLint\Linter->lint() /vagrant/vendor/overtrue/phplint/src/Command/LintCommand.php:280
PHP   9. Overtrue\PHPLint\Process\Lint->start() /vagrant/vendor/overtrue/phplint/src/Linter.php:106
PHP  10. proc_open() /vagrant/vendor/symfony/process/Process.php:296

                                                          
  [Symfony\Component\Process\Exception\RuntimeException]  
  Unable to launch a new process.                         
                                                          

Exception trace:
 () at /vagrant/vendor/symfony/process/Process.php:299
 Symfony\Component\Process\Process->start() at /vagrant/vendor/overtrue/phplint/src/Linter.php:106
 Overtrue\PHPLint\Linter->lint() at /vagrant/vendor/overtrue/phplint/src/Command/LintCommand.php:280
 Overtrue\PHPLint\Command\LintCommand->executeLint() at /vagrant/vendor/overtrue/phplint/src/Command/LintCommand.php:191
 Overtrue\PHPLint\Command\LintCommand->execute() at /vagrant/vendor/symfony/console/Command/Command.php:240
 Symfony\Component\Console\Command\Command->run() at /vagrant/vendor/symfony/console/Application.php:858
 Symfony\Component\Console\Application->doRunCommand() at /vagrant/vendor/symfony/console/Application.php:215
 Symfony\Component\Console\Application->doRun() at /vagrant/vendor/symfony/console/Application.php:122
 Symfony\Component\Console\Application->run() at /vagrant/vendor/overtrue/phplint/bin/phplint:32

phplint [--exclude EXCLUDE] [--extensions EXTENSIONS] [-j|--jobs JOBS] [-c|--configuration CONFIGURATION] [--no-configuration] [--no-cache] [--cache CACHE] [--no-progress] [--json [JSON]] [--] [<path>]...

Any help would be appreciated.

-j/--jobs parameter description or behaviour wrong

Using /phplint src --no-cache --no-ansi --no-interaction -j=1 will hang the process (indefinitely, as far as I can tell, although I only gave it ~10 Minutes). Using /phplint src --no-cache --no-ansi --no-interaction -j 1 instead (without the = in front of the number) appears to not only not hang, but actually take the 1 as a parameter - I end up with 11 seconds with -j 1 and 3 seconds with -j 4. So I'd say either the help printout in the readme is wrong or the parsing code is wrong.

PHP7 parsing error

When you are testing a php 7 on a php 5.6.3 system, of course there will be blood. I found this out with the spaceship operator.

      return $item2['title'] <=> $item1['title'];

This causes a parse error which stops phplint. Probably not a bug since it's user error to test a php7 codebase with an older version of php, but still wanted to pass this along just the same. Thanks!

Uncaught Error: Typed property Overtrue\PHPLint\Linter::$processCallback

For PHP 8.0.8 with parameter --no-progress:

$ vendor/bin/phplint --no-cache --no-progress

phplint 3.0 by overtrue and contributors.

Loaded config from "/app/.phplint.yml"

Checking...PHP Fatal error:  Uncaught Error: Typed property Overtrue\PHPLint\Linter::$processCallback must not be accessed before initialization in /app/vendor/overtrue/phplint/src/Linter.php:37
Stack trace:
#0 /app/vendor/overtrue/phplint/src/Command/LintCommand.php(277): Overtrue\PHPLint\Linter->lint(Array, false)
#1 /app/vendor/overtrue/phplint/src/Command/LintCommand.php(163): Overtrue\PHPLint\Command\LintCommand->executeLint(Object(Overtrue\PHPLint\Linter), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 274)
#2 /app/vendor/symfony/console/Command/Command.php(299): Overtrue\PHPLint\Command\LintCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /app/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand(Object(Overtrue\PHPLint\Command\LintCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/overtrue/phplint/bin/phplint(32): Symfony\Component\Console\Application->run()
#7 {main}
  thrown in /app/vendor/overtrue/phplint/src/Linter.php on line 37

Fatal error: Uncaught Error: Typed property Overtrue\PHPLint\Linter::$processCallback must not be accessed before initialization in /app/vendor/overtrue/phplint/src/Linter.php:37
Stack trace:
#0 /app/vendor/overtrue/phplint/src/Command/LintCommand.php(277): Overtrue\PHPLint\Linter->lint(Array, false)
#1 /app/vendor/overtrue/phplint/src/Command/LintCommand.php(163): Overtrue\PHPLint\Command\LintCommand->executeLint(Object(Overtrue\PHPLint\Linter), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 274)
#2 /app/vendor/symfony/console/Command/Command.php(299): Overtrue\PHPLint\Command\LintCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /app/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand(Object(Overtrue\PHPLint\Command\LintCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/overtrue/phplint/bin/phplint(32): Symfony\Component\Console\Application->run()
#7 {main}
  thrown in /app/vendor/overtrue/phplint/src/Linter.php on line 37

Without parameter --no-progress its ok.

Can't display the value scope error

Can't display the value scope error, code as below:

<?php

function test() {

  $isok=false;

  if ($isok ) {
    $v = array(1,2,3);
    print("true\n");
    print( "v=". json_encode($v));

  } else {
    print("false\n");

    print( "v=". json_encode($v));  // here is no value v
  }
}

test();

but this report success:

phplint 2.0.2 by overtrue and contributors.

No config file loaded.

.

Time: < 1 sec   Memory: 2.0 MiB Cache: Yes

OK! (Files: 1, Success: 1)

Only lint files changed compared to master

For local developement on a large code base, sometimes running code lint across the whole codebase in unnecessary but running across a diff of files changes compared to say master.

This may be a useful feature, I may come back and create a PR soon.

Path from config file not used

Hi,

after upgrading to 2.0.0 the path variable in my .phplint.yml stopped working.
Contents of my yml file:

path: ./app/
jobs: 10
cache: var/tmp/phplint.cache
extensions:
  - php

When I add the path variable to the CLI command, it works.
Could this be caused by this commit?
0e94dae

best regards
Peter

phplint.cache No Such file or directory

This happened on my windows box. If build folder isn't present in the root directory it will display the error

PHP Warning: file_put_contents(/build/phplint.cache): failed to open stream: No such file or directory in \vendor\overtrue\phplint\src\Cache.php on line 65

So an inquiry. should Cache.php check if the build folder exists and is writable before writable? If not. Display a notification or continue without caching.

More than one lint error in one file

Hi 👋,

Given the following (Laravel) PHP code:

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use HasFactory, Notifiable;ee

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'email',
        'password',eeee
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',ee
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];eeeee
}

Please notice the additional es at line 12, 22, 32 and 42.

When running PHPLint it generates the following JSON output:

{
    "status": "success",
    "options": {
        "jobs": 5,
        "path": [
            ".\/"
        ],
        "exclude": [
            "vendor"
        ],
        "extensions": [
            "php"
        ],
        "warning": false,
        "no-cache": true,
        "json": "phplint.json"
    },
    "errors": {
        "\/Users\/tdewit\/projects\/code-quality-test\/app\/Models\/User.php": {
            "file": "\/Users\/tdewit\/projects\/code-quality-test\/app\/Models\/User.php",
            "file_name": "app\/Models\/User.php",
            "error": "unexpected 'ee' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in line 12",
            "line": 12
        }
    },
    "time_usage": "1 sec",
    "memory_usage": "0 B",
    "using_cache": false,
    "files_count": 55
}

I'd expect multiple errors on the same file. Is this even possible? And if so, would it be a worthwhile addition? I'd PR this but I'll have to figure out the inner workings of the Linter itself.

Kind regards,

Tom

PHP 7.4 array functions support

Hi,

Thanks for the package. I wonder if you have any plans to support PHP closures. I have a CI configured with your docker, and it generates errors like:

5. /builds/XXX/app/Providers/NovaServiceProvider.php:24
    21|     {
    22|         parent::boot();
    23| 
  > 24|         Nova::createUserUsing(fn($command) => [
    25|             $command->ask('Username'),
    26|             $command->ask('Email Address'),
    27|             $command->secret('Password'),
 unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in line 24

Thanks

[REQUEST] Add flag to show full or short name

Hi 👋,

Thanks for all you do for the PHP community!

Would it be in the scope of this project to allow printing short filenames in the output?

For example, the current output is as follows:

{
    "status": "success",
    "options": {
        "jobs": 5,
        "exclude": [],
        "extensions": [
            "php"
        ],
        "json": "phplint.json",
        "path": [
            "app"
        ]
    },
    "errors": {
        "\/var\/www\/html\/app\/Class.php": {
            "file": "\/var\/www\/html\/app\/Class.php",
            "error": "unexpected 'public' (T_PUBLIC), expecting ',' or ';' in line 22",
            "line": 22
        }
    },
    "time_usage": "< 1 sec",
    "memory_usage": "2.0 MiB",
    "using_cache": true,
    "files_count": 23
}

What I'd personally need is as follows:

{
    "status": "success",
    "options": {
        "jobs": 5,
        "exclude": [],
        "extensions": [
            "php"
        ],
        "json": "phplint.json",
        "path": [
            "app"
        ]
    },
    "errors": {
        "app\/Class.php": {
            "file": "app\/Class.php",
            "error": "unexpected 'public' (T_PUBLIC), expecting ',' or ';' in line 22",
            "line": 22
        }
    },
    "time_usage": "< 1 sec",
    "memory_usage": "2.0 MiB",
    "using_cache": true,
    "files_count": 23
}

The changes I'm requesting can be found at errors -> filename -> file.

Thank you for your time.

Tom

Problem with symbolic links

I am using phplint from gitlab with repositories that contain symbolic links where targets are not inside the repository.
phplint seems not to be able to handle this and dies with exception. Version is 1.2.1.

Config is:

path: ./
jobs: 10
cache: .phplint-cache
extensions:
  - php
exclude:
  - vendor
 There was 1 errors:
1. 0:0
PHP Warning:  file(0): failed to open stream: No such file or directory in /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php on line 314
PHP Stack trace:
PHP   1. {main}() /builds/my-project/vendor/overtrue/phplint/bin/phplint:0
PHP   2. Symfony\Component\Console\Application->run() /builds/my-project/vendor/overtrue/phplint/bin/phplint:32
PHP   3. Symfony\Component\Console\Application->doRun() /builds/my-project/vendor/symfony/console/Application.php:130
PHP   4. Symfony\Component\Console\Application->doRunCommand() /builds/my-project/vendor/symfony/console/Application.php:228
PHP   5. Symfony\Component\Console\Command\Command->run() /builds/my-project/vendor/symfony/console/Application.php:874
PHP   6. Overtrue\PHPLint\Command\LintCommand->execute() /builds/my-project/vendor/symfony/console/Command/Command.php:264
PHP   7. Overtrue\PHPLint\Command\LintCommand->showErrors() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:207
PHP   8. Overtrue\PHPLint\Command\LintCommand->getHighlightedCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:298
PHP   9. Overtrue\PHPLint\Command\LintCommand->getCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:347
PHP  10. file() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:314
PHP Warning:  array_slice() expects parameter 1 to be array, boolean given in /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php on line 318
PHP Stack trace:
PHP   1. {main}() /builds/my-project/vendor/overtrue/phplint/bin/phplint:0
PHP   2. Symfony\Component\Console\Application->run() /builds/my-project/vendor/overtrue/phplint/bin/phplint:32
PHP   3. Symfony\Component\Console\Application->doRun() /builds/my-project/vendor/symfony/console/Application.php:130
PHP   4. Symfony\Component\Console\Application->doRunCommand() /builds/my-project/vendor/symfony/console/Application.php:228
PHP   5. Symfony\Component\Console\Command\Command->run() /builds/my-project/vendor/symfony/console/Application.php:874
PHP   6. Overtrue\PHPLint\Command\LintCommand->execute() /builds/my-project/vendor/symfony/console/Command/Command.php:264
PHP   7. Overtrue\PHPLint\Command\LintCommand->showErrors() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:207
PHP   8. Overtrue\PHPLint\Command\LintCommand->getHighlightedCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:298
PHP   9. Overtrue\PHPLint\Command\LintCommand->getCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:347
PHP  10. array_slice() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:318
PHP Warning:  end() expects parameter 1 to be array, null given in /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php on line 319
PHP Stack trace:
PHP   1. {main}() /builds/my-project/vendor/overtrue/phplint/bin/phplint:0
PHP   2. Symfony\Component\Console\Application->run() /builds/my-project/vendor/overtrue/phplint/bin/phplint:32
PHP   3. Symfony\Component\Console\Application->doRun() /builds/my-project/vendor/symfony/console/Application.php:130
PHP   4. Symfony\Component\Console\Application->doRunCommand() /builds/my-project/vendor/symfony/console/Application.php:228
PHP   5. Symfony\Component\Console\Command\Command->run() /builds/my-project/vendor/symfony/console/Application.php:874
PHP   6. Overtrue\PHPLint\Command\LintCommand->execute() /builds/my-project/vendor/symfony/console/Command/Command.php:264
PHP   7. Overtrue\PHPLint\Command\LintCommand->showErrors() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:207
PHP   8. Overtrue\PHPLint\Command\LintCommand->getHighlightedCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:298
PHP   9. Overtrue\PHPLint\Command\LintCommand->getCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:347
PHP  10. end() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:319
PHP Warning:  key() expects parameter 1 to be array, null given in /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php on line 320
PHP Stack trace:
PHP   1. {main}() /builds/my-project/vendor/overtrue/phplint/bin/phplint:0
PHP   2. Symfony\Component\Console\Application->run() /builds/my-project/vendor/overtrue/phplint/bin/phplint:32
PHP   3. Symfony\Component\Console\Application->doRun() /builds/my-project/vendor/symfony/console/Application.php:130
PHP   4. Symfony\Component\Console\Application->doRunCommand() /builds/my-project/vendor/symfony/console/Application.php:228
PHP   5. Symfony\Component\Console\Command\Command->run() /builds/my-project/vendor/symfony/console/Application.php:874
PHP   6. Overtrue\PHPLint\Command\LintCommand->execute() /builds/my-project/vendor/symfony/console/Command/Command.php:264
PHP   7. Overtrue\PHPLint\Command\LintCommand->showErrors() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:207
PHP   8. Overtrue\PHPLint\Command\LintCommand->getHighlightedCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:298
PHP   9. Overtrue\PHPLint\Command\LintCommand->getCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:347
PHP  10. key() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:320
PHP Warning:  Invalid argument supplied for foreach() in /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php on line 323
PHP Stack trace:
PHP   1. {main}() /builds/my-project/vendor/overtrue/phplint/bin/phplint:0
PHP   2. Symfony\Component\Console\Application->run() /builds/my-project/vendor/overtrue/phplint/bin/phplint:32
PHP   3. Symfony\Component\Console\Application->doRun() /builds/my-project/vendor/symfony/console/Application.php:130
PHP   4. Symfony\Component\Console\Application->doRunCommand() /builds/my-project/vendor/symfony/console/Application.php:228
PHP   5. Symfony\Component\Console\Command\Command->run() /builds/my-project/vendor/symfony/console/Application.php:874
PHP   6. Overtrue\PHPLint\Command\LintCommand->execute() /builds/my-project/vendor/symfony/console/Command/Command.php:264
PHP   7. Overtrue\PHPLint\Command\LintCommand->showErrors() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:207
PHP   8. Overtrue\PHPLint\Command\LintCommand->getHighlightedCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:298
PHP   9. Overtrue\PHPLint\Command\LintCommand->getCodeSnippet() /builds/my-project/vendor/overtrue/phplint/src/Command/LintCommand.php:347
 Could not open input file:

`exclude` option seems to be relative only

Given the I have the directory structure:

  • src
  • tests
    • fixtures

I wanted to exclude the test/fixtures folder, so I set the option exclude=tests/fixtures. However, these files were still included.

After some toying around, I passed exclude=fixtures and there were properly excluded.

However, given I was running the phplint from the project root, I would expect the former to work.

Problem with lint in PHP7.4

When I run lint using PHP7.4 the problem occurred to recognize the typing in the variables.
image
image

Is there some setting to solve this?

Undefined variable

PHP Notice: Undefined index: cache in /home/developer/projects/BrowserDetector/vendor/overtrue/phplint/src/Command/LintCommand.php on line 157
PHP Stack trace:
PHP 1. {main}() /home/developer/projects/BrowserDetector/vendor/overtrue/phplint/bin/phplint:0
PHP 2. Overtrue\PHPLint\Console\Application->run() /home/developer/projects/BrowserDetector/vendor/overtrue/phplint/bin/phplint:32
PHP 3. Overtrue\PHPLint\Console\Application->doRun() /home/developer/projects/BrowserDetector/vendor/symfony/console/Application.php:143
PHP 4. Overtrue\PHPLint\Console\Application->doRunCommand() /home/developer/projects/BrowserDetector/vendor/symfony/console/Application.php:241
PHP 5. Overtrue\PHPLint\Command\LintCommand->run() /home/developer/projects/BrowserDetector/vendor/symfony/console/Application.php:865
PHP 6. Overtrue\PHPLint\Command\LintCommand->execute() /home/developer/projects/BrowserDetector/vendor/symfony/console/Command/Command.php:252

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.