code-lts / doctum

A php API documentation generator, fork of Sami
https://doctum.long-term.support/
MIT License
300 stars 32 forks source link

Deprecation exception on dynamic properties using PHP 8.2 on src/Doctum.php line 225 #62

Closed Abdillah closed 11 months ago

Abdillah commented 1 year ago

My configuration is as follows.

return new Doctum($iterator, [
    'title'                => 'PHP References',
    'language'             => 'en',
    'build_dir'            => __DIR__ . '/../build/php_refs',
    'cache_dir'            => __DIR__ . '/../build/php_refs/.cache',
]);

When language is removed, no errors occurs. But, generally this error occurs when unknown config key is supplied.

I think, it needs to limit what the config possible or handle it more gracefully.

Here is a snippet of the errors.

$ php doctum.phar parse config/doctum.php -vvv

In ErrorHandler.php line 53:

  [ErrorException]
  Deprecated: Creation of dynamic property Doctum\Doctum::$language is deprecated in phar:///path/to/binary/doctum.phar/src/Doctum.php line 225

Exception trace:
  at phar:///path/to/binary/doctum.phar/src/ErrorHandler.php:53
 Doctum\ErrorHandler->handle() at phar:///path/to/binary/doctum.phar/src/Doctum.php:225
 Doctum\Doctum->__construct() at /path/to/binary/config/doctum.php:15
 require() at phar:///path/to/binary/doctum.phar/src/Console/Command/Command.php:501
 Doctum\Console\Command\Command->loadDoctum() at phar:///path/to/binary/doctum.phar/src/Console/Command/Command.php:170
 Doctum\Console\Command\Command->initialize() at phar:///path/to/binary/doctum.phar/vendor/symfony/console/Command/Command.php:264
 Symfony\Component\Console\Command\Command->run() at phar:///path/to/binary/doctum.phar/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar:///path/to/binary/doctum.phar/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///path/to/binary/doctum.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///path/to/binary/doctum.phar/bin/doctum-binary.php:26
 include() at /path/to/binary/doctum.phar:16

parse [--only-version ONLY-VERSION] [--force] [--output-format OUTPUT-FORMAT] [--no-progress] [--ignore-parse-errors] [--print-frozen-errors] [--] <config>
williamdes commented 11 months ago

Thank you for this report, this is still on my TODO list but I hope to do it soon

williamdes commented 11 months ago

Seems like dc6cb2ea41f8a0e806150390228aaeb73d24fa04 fixed it, I added b88cd7f271e677f4f6b8cbe8238304a8235e473a to ensure this case is handled and 758d4722b043b266feb73506f8e7db4969b3a818 to ensure I did not break the language switcher

williamdes commented 11 months ago

I released the changes in 5.5.4, would you mind confirming that everything is okay for you @Abdillah ?