Closed Levivb closed 5 years ago
could you please provide your composer.json
file?
composer.json
autoload-dev
and not be parsed.composer.json
is as following:
{
"name": "laravel-modules/boilerplate",
"description": "",
"license": "proprietary",
"require": {
"php": ">=7.2.0",
"laravel-modules/core": "^4.0"
},
"require-dev": {
"codedungeon/phpunit-result-printer": "^0.24.1",
"internations/http-mock": "^0.12.1",
"jakub-onderka/php-console-highlighter": "^0.3.2",
"jakub-onderka/php-parallel-lint": "^1.0",
"localheinz/composer-normalize": "^1.1",
"maximum/code-sniffer-rules": "^2.0",
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.5",
"sensiolabs/security-checker": "^5.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
...
]
}
},
"autoload": {
"psr-4": {
"Modules\\Boilerplate\\": ""
}
},
"repositories": [
{
"type": "composer",
"url": "[FILTERED]",
"options": {
"http": {
"header": [
"X-TOKEN: [FILTERED]"
]
}
}
}
],
"scripts": {
"fix-style": "vendor/bin/phpcbf --standard=phpcs.xml",
"lint": "vendor/bin/parallel-lint --exclude vendor . --colors",
"security-checker": "vendor/bin/security-checker security:check composer.lock",
"style": "vendor/bin/phpcs --standard=phpcs.xml"
}
}
laravel-modules/core
is a company package with the following composer.json
:
{
"name": "laravel-modules/core",
"description": "",
"license": "proprietary",
"require": {
"php": ">=7.2.0",
"ext-json": "*",
"ext-simplexml": "*",
"dimsav/laravel-translatable": "^9.2",
"doctrine/dbal": "^2.7",
"guidocella/eloquent-insert-on-duplicate-key": "^2.2",
"guzzlehttp/guzzle": "^6.3",
"laracasts/utilities": "^3.0",
"laravel/framework": "5.7.*",
"laravel/horizon": "^3.0",
"laravel/telescope": "^1.0",
"maatwebsite/laravel-sidebar": "~2.1",
"maximum/laravel-modules": "^3.3",
"nanigans/single-table-inheritance": "^0.8.7",
"owen-it/laravel-auditing": "^8.0",
"predis/predis": "^1.1",
"renatomarinho/laravel-page-speed": "^1.8",
"rtconner/laravel-tagging": "^3.0",
"sentry/sentry-laravel": "^0.11",
"sofa/eloquence": "^5.6",
"spatie/laravel-analytics": "^3.6",
"stevenmaguire/laravel-middleware-csp": "~0.1",
"tymon/jwt-auth": "0.5.*",
"zizaco/entrust": "^1.9"
},
"require-dev": {
"codedungeon/phpunit-result-printer": "^0.24.1",
"internations/http-mock": "^0.12.1",
"jakub-onderka/php-console-highlighter": "^0.3.2",
"jakub-onderka/php-parallel-lint": "^1.0",
"localheinz/composer-normalize": "^1.1",
"maximum/code-sniffer-rules": "^2.0",
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.5",
"sensiolabs/security-checker": "^5.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
...
],
"aliases": {
...
}
}
},
"autoload": {
"psr-4": {
"Modules\\Core\\": ""
},
"files": [
"Helpers/global_functions.php"
]
},
"repositories": [
{
"type": "composer",
"url": "[FILTERED]",
"options": {
"http": {
"header": [
"X-TOKEN: [FILTERED]"
]
}
}
}
],
"scripts": {
"fix-style": "vendor/bin/phpcbf --standard=phpcs.xml",
"lint": "vendor/bin/parallel-lint --exclude vendor . --colors",
"security-checker": "vendor/bin/security-checker security:check composer.lock",
"style": "vendor/bin/phpcs --standard=phpcs.xml"
}
}
the package with the syntax error seems to be jakub-onderka/php-parallel-lint
The "Problem" in this case are the autoload sections. They cause composer-require-checker
to parse ALL files within the root directory.
There should be a subfolger with your php files, like "src" or whatever you like to call it, and your autoload-sections should only point to this directory.
"autoload": {
"psr-4": {
"Modules\\Boilerplate\\": ""
}
},
and
"autoload": {
"psr-4": {
"Modules\\Core\\": ""
},
"files": [
"Helpers/global_functions.php"
]
},
Thanks for getting back to me. Due to a holiday I wasn't able to respond any sooner.
It seems you'r right, putting files in a src
directory does fix the issue.
packages mentioned here are Modules loaded by nwidart/laravel-modules It's gonna be a bit of a challenge to get those packages working in a sub-directory, since they contain some legacy code with hardcoded paths (I know, I know) and I'm also not sure how the laravel-modules package will respond to those changes. I'll put it on my backlog for now since it's quite a major overhaul
Thanks for helping me understand this one anywaay!
This could be a duplicate of https://github.com/maglnet/ComposerRequireChecker/issues/54 I'll open a separate issue though in order to avoid cluttering or take over that issue
When running
composer-require-checker -vvv
I'm greeted with the following output after a few seconds:From the looks of it, it seems the error originates from the nikic/php-parser package. Unfortunately, the error doesn't tell which file is invalid. Given the fact that my code doesn't contain any syntax errors and the
nikic/php-parser
package due to it's wide adoption probably won't contain any obvious syntax errors as well, I figured the parser checks the vendor directory.After running
$ find . -name *.php -exec php -l {} \;
in my vendor directory and ignoring all syntactically valid files, I'm left with the following output:As I suspected, the vendor directory contains syntactically invalid files. Upon manually 'fixing' the first two errors in the vendor directory, a rerun of
composer-require-checker -vvv
got me the next error in line:Which confirms my initial theory. Unfortunately... there's little for me to do here. The third party packages are there to stay and most of these syntax errors originate from test files of the packages themselves. Hence they should contain syntax errors.
I did run
composer-require-checker -vvv --ignore-parse-errors
as well Which got me (after 5 minute of waiting) an insane list of 'soft' dependencies of which 99.9% isn't referred to in my code. Given the fact that all the files in the vendor directory are parsed, I presume all files in there are checked against my first partycomposer.json
Now, given release note
2.0.0
statesuse installed.json instead of composer.json
, the vendor directory should obviously exist. Removing it gives meThe composer dependencies have not been installed, run composer install/update first
.A few questions:
nikic/php-parser
)