zircote / swagger-php

A php swagger annotation and parsing library
http://zircote.github.io/swagger-php/
Apache License 2.0
5.08k stars 933 forks source link

Error: Error: Interface "PHP_CodeSniffer\Sniffs\Sniff" not found #1600

Closed DFournierIT closed 4 months ago

DFournierIT commented 4 months ago

Command issued: ./vendor/bin/openapi . -o openapi.yaml

Error: Error: Error: Interface "PHP_CodeSniffer\Sniffs\Sniff" not found in /var/www/html/my_app/vendor/cakephp/cakephp-codesniffer/CakePHP/Sniffs/Classes/ReturnTypeHintSniff.php:23

Stack trace:
#0 /var/www/html/my_app/vendor/composer/ClassLoader.php(576): include()
#1 /var/www/html/my_app/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/var/www/html/B...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('CakePHP\\Sniffs\\...')
#3 /var/www/html/my_app/vendor/zircote/swagger-php/src/Analysers/ReflectionAnalyser.php(87): class_exists('CakePHP\\Sniffs\\...')
#4 /var/www/html/my_app/vendor/zircote/swagger-php/src/Analysers/ReflectionAnalyser.php(62): OpenApi\Analysers\ReflectionAnalyser->analyzeFqdn('CakePHP\\Sniffs\\...', Object(OpenApi\Analysis), Array)
#5 /var/www/html/my_app/vendor/zircote/swagger-php/src/Generator.php(495): OpenApi\Analysers\ReflectionAnalyser->fromFile('./vendor/cakeph...', Object(OpenApi\Context))
#6 /var/www/html/my_app/vendor/zircote/swagger-php/src/Generator.php(455): OpenApi\Generator->scanSources(Object(Symfony\Component\Finder\Finder), Object(OpenApi\Analysis), Object(OpenApi\Context))
#7 /var/www/html/my_app/vendor/zircote/swagger-php/bin/openapi(233): OpenApi\Generator->generate(Object(Symfony\Component\Finder\Finder))
#8 /var/www/html/my_app/vendor/bin/openapi(119): include('/var/www/html/B...')
#9 {main}

composer.json

"require": {
    "php": ">=7.2",
    "cakephp/cakephp": "^4.4",
    "cakephp/migrations": "^3.0",
    "cakephp/plugin-installer": "^1.3",
    "erwane/cakephp-token": "^2.0",
    "lorenzo/audit-stash": "3.*",
    "mobiledetect/mobiledetectlib": "^2.8",
    "muffin/footprint": "2.0.3",
    "phpoffice/phpspreadsheet": "^1.18",
    "zircote/swagger-php": "^4.7"
},
"require-dev": {
    "cakephp/bake": "2.8.3",
    "cakephp/cakephp-codesniffer": "~4.2.0",
    "cakephp/debug_kit": "^4.4",
    "josegonzalez/dotenv": "^3.2",
    "php-webdriver/webdriver": "^1.15",
    "phpunit/phpunit": "~8.5.0 || ^9.3",
    "phpunit/phpunit-selenium": "^9.0",
    "psy/psysh": "@stable"
},
DerManoMann commented 4 months ago

Hard to tell without seeing some of the project structure and/or files. Some thoughts, though:

DFournierIT commented 4 months ago

Hard to tell without seeing some of the project structure and/or files. Some thoughts, though:

  • you are scanning . - i.e. the project root. That might include the vendor folder and probably other folders/files that are not relevant and might break things. Reducing this to the folders that do actually contain code with annotations might be enough (you can specify multiple files/folder)
  • The code in question does a xxx_exists() check. Failing this usually means there is no (or incorrect) autoloading set up

Appreciate your reply!

I think the first point was my issue. I changed the path to point to src/Controller (I have a CakePHP project) and it went through fine.