overtrue / phplint

:bug: A tool that can speed up linting of php files by running several lint processes at once.
MIT License
988 stars 89 forks source link

[PHAR version] Improve build with BOX v4 by adding a manifest #173

Closed llaville closed 1 year ago

llaville commented 1 year ago

Keep compatibility between PHP 8.0 and PHP 8.1 or greater with BOX project is very hard !

BOX (v3) and now v4 (recommended) is a great tool, but it suffer of a cool missing feature (add a manifest with dependency list embedded).

Even, if I've tried it in past to include it in core of BOX project, this feature is available with my project https://github.com/llaville/box-manifest

In context of writing major version 9.0 (see https://github.com/overtrue/phplint/issues/171), I think it may be a good opportunity to improve build-phar process

@overtrue Are you agree ?

Here is a preview of what we can get.

Box version 4.2.0@afc3a47

// Loading the configuration file "/usr/src/box.json".

🔨 Building the PHAR "/usr/src/bin/phplint.phar"

? Registering compactors

No recommendation found. No warning found.

// PHAR: 402 files (1.89MB) // You can inspect the generated PHAR with the "info" command.

// Memory usage: 55.37MB (peak: 104.89MB), time: 8secs



- Try it (BOX v4 requires PHP 8.1) but PHAR version built may run on PHP 8.0 too 

![v9-phar-php8](https://user-images.githubusercontent.com/364342/212465487-cb5cc6be-0aed-46c8-8812-ba93d6553d6a.png)
overtrue commented 1 year ago

Just do it

Laurent Laville @.***>于2023年1月14日 周六17:33写道:

Keep compatibility between PHP 8.0 and PHP 8.1 or greater with BOX project https://github.com/box-project/box is very hard !

BOX (v3) and now v4 (recommended) is a great tool, but it suffer of a cool missing feature (add a manifest with dependency list embedded).

Even, if I've tried it in past to include it in core https://github.com/box-project/box/issues/605 of BOX project, this feature is available with my project https://github.com/llaville/box-manifest

In context of writing major version 9.0 (see #171 https://github.com/overtrue/phplint/issues/171), I think it may be a good opportunity to improve build-phar process https://github.com/overtrue/phplint/blob/main/.github/workflows/build-phar.yml

@overtrue https://github.com/overtrue Are you agree ?

Here is a preview of what we can get.

  • Run command : docker run --rm -it -u "$(id -u):$(id -g)" -v $(pwd):/usr/src ghcr.io/llaville/box-manifest:v2 compile -c /usr/src/box.json
  • And get following output :


    / )__ _ __

    / / | |/_/

    / // / // /> <

//\//|_|

Box version @.***

// Loading the configuration file "/usr/src/box.json".

🔨 Building the PHAR "/usr/src/bin/phplint.phar"

? Registering compactors

  • KevinGH\Box\Compactor\PhpScoper

? Adding main file: /usr/src/bin/phplint

? Adding requirements checker

? Adding binary files

> No file found

? Auto-discover files? Yes

? Exclude dev files? Yes

? Adding files

> 369 file(s)

? Generating new stub

  • Using shebang line: #!/usr/bin/env php

  • Using banner:

    This file is part of the overtrue/phplint

    (c) overtrue @.***>

    This source file is subject to the MIT license that is bundled

    with this source code in the file LICENSE.

? Setting metadata

  • Using composer.json : /usr/src/composer.json

  • Using composer.lock : /usr/src/composer.lock

  • overtrue/phplint: @.***

    requires php ^8.0: 8.1.7

    requires ext-json *: 8.1.7

    requires (for development) bamarni/composer-bin-plugin ^1.4: 1.8.2

    requires (for development) brainmaestro/composer-git-hooks ^2.8.5 || 3.0.0-alpha.1: v3.0.0-alpha.1

    uses composer/pcre : 3.1.0

    uses composer/semver : 3.3.2

    uses composer/xdebug-handler : 3.0.3

    uses doctrine/annotations : 1.14.2

    uses doctrine/deprecations : v1.0.0

    uses doctrine/instantiator : 1.5.0

    uses doctrine/lexer : 2.1.0

    requires (for development) friendsofphp/php-cs-fixer ^3.4.0: v3.13.2

    requires (for development) jetbrains/phpstorm-stubs ^2021.3 || ^2022.3: v2022.3

    uses myclabs/deep-copy : 1.11.0

    uses nikic/php-parser : v4.15.2

    uses phar-io/manifest : 2.0.3

    uses phar-io/version : 3.2.1

    uses php-parallel-lint/php-console-color : v1.0.1

    requires (for development) php-parallel-lint/php-console-highlighter ^1.0: v1.0.0

    uses phpunit/php-code-coverage : 9.2.23

    uses phpunit/php-file-iterator : 3.0.6

    uses phpunit/php-invoker : 3.1.1

    uses phpunit/php-text-template : 2.0.4

    uses phpunit/php-timer : 5.0.3

    requires (for development) phpunit/phpunit ^9.5: 9.5.27

    uses psr/cache : 3.0.0

    uses psr/container : 2.0.2

    uses psr/event-dispatcher : 1.0.0

    uses psr/log : 3.0.0

    uses sebastian/cli-parser : 1.0.1

    uses sebastian/code-unit : 1.0.8

    uses sebastian/code-unit-reverse-lookup : 2.0.3

    uses sebastian/comparator : 4.0.8

    uses sebastian/complexity : 2.0.2

    uses sebastian/diff : 4.0.4

    uses sebastian/environment : 5.1.4

    uses sebastian/exporter : 4.0.5

    uses sebastian/global-state : 5.0.5

    uses sebastian/lines-of-code : 1.0.3

    uses sebastian/object-enumerator : 4.0.4

    uses sebastian/object-reflector : 2.0.4

    uses sebastian/recursion-context : 4.0.4

    uses sebastian/resource-operations : 3.0.3

    uses sebastian/type : 3.2.0

    uses sebastian/version : 3.0.2

    requires symfony/cache ^5.4 || ^6.0: v6.0.18

    uses symfony/cache-contracts : v3.0.2

    requires symfony/console ^5.4 || ^6.0: v6.0.17

    uses symfony/deprecation-contracts : v3.0.2

    requires symfony/event-dispatcher ^5.4 || ^6.0: v6.0.17

    uses symfony/event-dispatcher-contracts : v3.0.2

    uses symfony/filesystem : v6.0.13

    requires symfony/finder ^5.4 || ^6.0: v6.0.17

    requires symfony/options-resolver ^5.4 || ^6.0: v6.0.3

    uses symfony/polyfill-ctype : v1.27.0

    uses symfony/polyfill-intl-grapheme : v1.27.0

    uses symfony/polyfill-intl-normalizer : v1.27.0

    uses symfony/polyfill-mbstring : v1.27.0

    uses symfony/polyfill-php80 : v1.27.0

    uses symfony/polyfill-php81 : v1.27.0

    requires symfony/process ^5.4 || ^6.0: v6.0.11

    uses symfony/service-contracts : v3.0.2

    uses symfony/stopwatch : v6.0.13

    uses symfony/string : v6.0.17

    uses symfony/var-exporter : v6.0.17

    requires symfony/yaml ^5.4 || ^6.0: v6.0.17

    uses theseer/tokenizer : 1.2.1

? Dumping the Composer autoloader

? Removing the Composer dump artefacts

? No compression

? Setting file permissions to 0700

  • Done.

No recommendation found.

No warning found.

// PHAR: 402 files (1.89MB)

// You can inspect the generated PHAR with the "info" command.

// Memory usage: 55.37MB (peak: 104.89MB), time: 8secs

  • Try it (BOX v4 requires PHP 8.1) but PHAR version built may run on PHP 8.0 too

[image: v9-phar-php8] https://user-images.githubusercontent.com/364342/212465487-cb5cc6be-0aed-46c8-8812-ba93d6553d6a.png

— Reply to this email directly, view it on GitHub https://github.com/overtrue/phplint/issues/173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALHOYBUMFBGF3UFQDVFI3TWSJXE3ANCNFSM6AAAAAAT3FVYNA . You are receiving this because you were mentioned.Message ID: @.***>

llaville commented 1 year ago

Don't be afraid if one day you want to drop usage of my box manifest builder project. Fallback is simple and easy. Metadata is consider as simple text line by standard BOX project v4

Answer in image

box-v4_standard

llaville commented 1 year ago

To conclude implementation of this feature, I've added with commit https://github.com/overtrue/phplint/commit/6bf1a26b7e6723fc8f1ddf7eaad713efccbac446 ability to display manifest of PHP Linter PHAR version with a single --manifest option. This is what I apply on all my projects that have a CLI version (and of course PHAR distribution).

Here is a preview (part of screenshot that is too long, because lot of dependency) of what we can get :

v9-phar-php8