overtrue / phplint

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

New autoloader does not respect custom "vendor-dir" configuration #206

Closed tleilax closed 1 month ago

tleilax commented 1 month ago

New Issue

Diagnose

Output of `composer show` command ``` algo26-matthias/idna-convert v4.0.2 A library for encoding and decoding internationalized domain names behat/gherkin v4.9.0 Gherkin DSL parser for PHP caxy/php-htmldiff v0.1.15 A library for comparing two HTML files/snippets and highlighting the differen... codeception/codeception 5.1.2 BDD-style testing framework codeception/lib-asserts 2.1.0 Assertion methods used by Codeception core and Asserts module codeception/module-asserts 3.0.0 Codeception module containing various assertions codeception/stub 4.1.3 Flexible Stub wrapper for PHPUnit's Mock Builder defuse/php-encryption v2.4.0 Secure PHP Encryption Library edu-sharing/auth-plugin 8.0.x-dev 4dc40c4 Plugin to provide authentification via Auth By App with a edu-sharing repository ezyang/htmlpurifier v4.17.0 Standards compliant HTML filter written in PHP fig/http-message-util 1.1.5 Utility classes and constants for use with PSR-7 (psr/http-message) graham-campbell/result-type v1.1.2 An Implementation Of The Result Type guzzlehttp/psr7 2.6.2 PSR-7 message implementation that also provides common utility methods jakeasmith/http_build_url 1.0.1 Provides functionality for http_build_url() to environments without pecl_http. jasig/phpcas 1.5.0 Provides a simple API for authenticating users against a CAS server jumbojett/openid-connect-php v1.0.0 Bare-bones OpenID Connect client ksubileau/color-thief-php v2.0.1 Grabs the dominant color or a representative color palette from an image. laravel/serializable-closure v1.3.3 Laravel Serializable Closure provides an easy and secure way to serialize clo... lcobucci/jwt 5.2.0 A simple library to work with JSON Web Token and JSON Web Signature league/event 2.2.0 Event package league/oauth2-server 8.5.4 A lightweight and powerful OAuth 2.0 authorization and resource server librar... league/uri 7.4.1 URI manipulation library league/uri-interfaces 7.4.1 Common interfaces and classes for URI representation and interaction maennchen/zipstream-php 2.1.0 ZipStream is a library for dynamically streaming dynamic zip files from PHP w... markbaker/complex 3.0.2 PHP Class for working with complex numbers markbaker/matrix 3.0.1 PHP Class for working with matrices monolog/monolog 2.9.1 Sends your logs to files, sockets, inboxes, databases and various web services myclabs/deep-copy 1.11.1 Create deep copies (clones) of your objects myclabs/php-enum 1.7.7 PHP Enum implementation neomerx/cors-psr7 v2.0.2 Framework agnostic (PSR-7) CORS implementation (www.w3.org/TR/cors/) neomerx/json-api v4.0.1 Framework agnostic JSON API (jsonapi.org) implementation nikic/fast-route v1.3.0 Fast request router for PHP nikic/php-parser v5.0.2 A PHP parser written in PHP okvpn/clock-lts 1.0.0 Adding support for a wider range of PHP versions to lcobucci/clock opis/json-schema 1.1.0 Json Schema Validator overtrue/phplint 9.2.0 `phplint` is a tool that can speed up linting of php files by running several... paragonie/constant_time_encoding v2.6.3 Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16) paragonie/random_compat v9.99.100 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7 phar-io/manifest 2.0.4 Component for reading phar.io manifest information from a PHP Archive (PHAR) phar-io/version 3.2.1 Library for handling version information and constraints phootwork/collection v2.1.3 The phootwork library fills gaps in the php language and provides better solu... phootwork/lang v2.1.3 Missing PHP language constructs php-di/invoker 2.0.0 Generic and extensible callable invoker php-di/php-di 7.0.0 The dependency injection container for humans php-http/httplug 2.3.0 HTTPlug, the HTTP client abstraction for PHP php-http/promise 1.1.0 Promise used for asynchronous HTTP requests phpoffice/phpspreadsheet 2.1.0 PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spread... phpoption/phpoption 1.9.2 Option Type for PHP phpowermove/docblock v2.0.1 PHP Docblock parser and generator. An API to read and write Docblocks. phpseclib/phpseclib 3.0.37 PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH... phpstan/phpstan 1.11.0 PHPStan - PHP Static Analysis Tool phpunit/php-code-coverage 10.1.14 Library that provides collection, processing, and rendering functionality for... phpunit/php-file-iterator 4.1.0 FilterIterator implementation that filters files based on a list of suffixes. phpunit/php-invoker 4.0.0 Invoke callables with a timeout phpunit/php-text-template 3.0.1 Simple template engine. phpunit/php-timer 6.0.0 Utility class for timing phpunit/phpunit 10.5.20 The PHP Unit Testing framework. phpxmlrpc/extras 1.0.0-beta2 A collection of server-side addons that might be of use for development of xm... phpxmlrpc/phpxmlrpc 4.10.0 A php library for building xmlrpc clients and servers psr/cache 3.0.0 Common interface for caching libraries psr/clock 1.0.0 Common interface for reading the clock. psr/container 1.1.2 Common Container Interface (PHP FIG PSR-11) psr/event-dispatcher 1.0.0 Standard interfaces for event handling. psr/http-client 1.0.1 Common interface for HTTP clients psr/http-factory 1.0.2 Common interfaces for PSR-7 HTTP message factories psr/http-message 1.1 Common interface for HTTP messages psr/http-server-handler 1.0.1 Common interface for HTTP server-side request handler psr/http-server-middleware 1.0.1 Common interface for HTTP server-side middleware psr/log 1.1.4 Common interface for logging libraries psr/simple-cache 1.0.1 Common interfaces for simple caching psy/psysh v0.12.3 An interactive shell for modern PHP. ralouphie/getallheaders 3.0.3 A polyfill for getallheaders. scssphp/scssphp v1.12.1 scssphp is a compiler for SCSS written in PHP. sebastian/cli-parser 2.0.1 Library for parsing CLI options sebastian/code-unit 2.0.0 Collection of value objects that represent the PHP code units sebastian/code-unit-reverse-lookup 3.0.0 Looks up which function or method a line of code belongs to sebastian/comparator 5.0.1 Provides the functionality to compare PHP values for equality sebastian/complexity 3.2.0 Library for calculating the complexity of PHP code units sebastian/diff 5.1.1 Diff implementation sebastian/environment 6.1.0 Provides functionality to handle HHVM/PHP environments sebastian/exporter 5.1.2 Provides the functionality to export PHP variables for visualization sebastian/global-state 6.0.2 Snapshotting of global state sebastian/lines-of-code 2.0.2 Library for counting the lines of code in PHP source code sebastian/object-enumerator 5.0.0 Traverses array structures and object graphs to enumerate all referenced objects sebastian/object-reflector 3.0.0 Allows reflection of object attributes, including inherited and non-public ones sebastian/recursion-context 5.0.0 Provides functionality to recursively process PHP variables sebastian/type 4.0.0 Collection of value objects that represent the types of the PHP type system sebastian/version 4.0.1 Library that helps with managing the version number of Git-hosted PHP projects slim/psr7 1.6.1 Strict PSR-7 implementation slim/slim 4.13.0 Slim is a PHP micro framework that helps you quickly write simple yet powerfu... spomky-labs/otphp 11.2.2 A PHP library for generating one time passwords according to RFC 4226 (HOTP A... symfony/cache v6.4.7 Provides extended PSR-6, PSR-16 (and tags) implementations symfony/cache-contracts v3.5.0 Generic abstractions related to caching symfony/console v6.4.7 Eases the creation of beautiful and testable command line interfaces symfony/css-selector v6.4.7 Converts CSS selectors to XPath expressions symfony/deprecation-contracts v3.5.0 A generic function and convention to trigger deprecation notices symfony/event-dispatcher v6.4.7 Provides tools that allow your application components to communicate with eac... symfony/event-dispatcher-contracts v3.5.0 Generic abstractions related to dispatching event symfony/finder v6.4.7 Finds files and directories via an intuitive fluent interface symfony/options-resolver v6.4.7 Provides an improved replacement for the array_replace PHP function symfony/polyfill-ctype v1.29.0 Symfony polyfill for ctype functions symfony/polyfill-intl-grapheme v1.29.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-normalizer v1.29.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-php82 v1.29.0 Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions symfony/polyfill-php83 v1.29.0 Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions symfony/process v6.4.7 Executes commands in sub-processes symfony/service-contracts v3.5.0 Generic abstractions related to writing services symfony/string v6.4.7 Provides an object-oriented API to strings and deals with bytes, UTF-8 code p... symfony/var-dumper v6.4.7 Provides mechanisms for walking through any arbitrary PHP variable symfony/var-exporter v6.4.7 Allows exporting any serializable PHP data structure to plain PHP code symfony/yaml v6.4.7 Loads and dumps YAML files tecnickcom/tcpdf 6.7.5 TCPDF is a PHP class for generating PDF documents and barcodes. theseer/tokenizer 1.2.3 A small library for converting tokenized PHP source code into XML and potenti... tuupola/callable-handler 1.1.0 Compatibility layer for PSR-7 double pass and PSR-15 middlewares. tuupola/cors-middleware 1.4.3 PSR-7 and PSR-15 CORS middleware tuupola/http-factory 1.4.0 Lightweight autodiscovering PSR-17 HTTP factories vlucas/phpdotenv v5.6.0 Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER`... willdurand/negotiation 3.1.0 Content Negotiation tools for PHP provided as a standalone library. woohoolabs/yang 3.0.0 Woohoo Labs. Yang ```

Summary

The new autoloader introduced in 8939870de45288fe48a763128fa4727c697f8009 now hardcodes the vendor directory to vender. But this is customizable in composer.json as such:

{
    "config": {
        "vendor-dir": "composer"
    }
}

Expected behaviour

That phplint respects the customized vendor directory.

Actual behaviour

Even the execution of composer exec phplint results in an error:

PHP Fatal error:  Uncaught RuntimeException: Unable to find "vendor/autoload.php" in "./composer/overtrue/phplint", ".k" paths. in ./composer/overtrue/phplint/autoload.php:58
Stack trace:
#0 ./composer/overtrue/phplint/autoload.php(29): Overtrue\PHPLint\Autoload::getAutoloadFile()
#1 ./composer/overtrue/phplint/phplint.php(24): Overtrue\PHPLint\Autoload::load('Symfony\\Compone...')
#2 ./composer/overtrue/phplint/bin/phplint(7): require_once('/Users/tleilax/...')
#3 ./composer/bin/phplint(119): include('/Users/tleilax/...')
#4 {main}
  thrown in ./composer/overtrue/phplint/autoload.php on line 58
llaville commented 1 month ago

v9.3.0 is already planned, and I will include a fix for this issue.

llaville commented 1 month ago

FYI: it's not a regression, because it was hard-coded since v9.1 (https://github.com/overtrue/phplint/blob/9.1/config/bootstrap.php#L17)

llaville commented 1 month ago

Tests executed with

{
    "config": {
        "vendor-dir": "composer"
    },
    "require": {
        "overtrue/phplint": "9.3.x-dev"
    }
}

Work fine for me.

v9.3 is on way ...

llaville commented 1 month ago

Release 9.3.0 is now available

tleilax commented 1 month ago

Works like a charm. Thank you. 👍