romanzipp / Laravel-Model-Doc

📝 Generate PHPDoc comments for Laravel Models
MIT License
22 stars 6 forks source link

Object of class .... could not be converted to string #32

Open jesseyvanofferen-4s opened 1 month ago

jesseyvanofferen-4s commented 1 month ago

While attempting to run this package I noticed it's giving me errors on some other classes than models. For example I have a bunch of enum classes, reading the package readme i'm not expecting this to do anything with non-model php files.

The error i'm getting is Object of class App\Http\Enums\UserStatusses could not be converted to string.

This being an enum-class i'm not actually expecting it to do anything with this class. Would we have to exclude all non-model classes manually for this to not attempt to do anything with non-model classes?

Sadly due to the current structure that we're slowly migrating away from it's not possible to set a base-path.

romanzipp commented 1 month ago

could you provide me with the full stack trace?

jesseyvanofferen-4s commented 1 month ago
[2024-08-07 08:42:05] local.ERROR: () Object of class App\Http\Enums\TransportationTypes could not be converted to string /var/www/vendor/romanzipp/laravel-model-doc/src/Services/Do
#1 /var/www/vendor/romanzipp/laravel-model-doc/src/Services/DocumentationGenerator.php(351): romanzipp\ModelDoc\Services\DocumentationGenerator::getDefaultValue(Object(App\Http\Enum
#2 /var/www/vendor/romanzipp/laravel-model-doc/src/Services/DocumentationGenerator.php(152): romanzipp\ModelDoc\Services\DocumentationGenerator->getQueryScopeMethods(Object(Reflecti
#3 /var/www/vendor/romanzipp/laravel-model-doc/src/Services/DocumentationGenerator.php(72): romanzipp\ModelDoc\Services\DocumentationGenerator->generateModelDocBlock(Object(romanzip
#4 /var/www/vendor/romanzipp/laravel-model-doc/src/Console/Commands/GenerateModelDocumentationCommand.php(19): romanzipp\ModelDoc\Services\DocumentationGenerator->generate(Object(ro
#5 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): romanzipp\ModelDoc\Console\Commands\GenerateModelDocumentationCommand->handle(Object(romanzipp\Mod
#8 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array
#9 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NUL
#11 /var/www/vendor/symfony/console/Command/Command.php(326): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\Output
#12 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Obje
#13 /var/www/vendor/symfony/console/Application.php(1096): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output
#14 /var/www/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(romanzipp\ModelDoc\Console\Commands\GenerateModelDocumentationCo
#15 /var/www/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Co
#16 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput)
#18 {main}  /artisan(33): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

   Error 

  Object of class App\Http\Enums\TransportationTypes could not be converted to string

  at vendor/romanzipp/laravel-model-doc/src/Services/DocumentationGenerator.php:775

The actual enum class is as follow:

<?php

namespace App\Http\Enums;

enum TransportationTypes: string
{
    use EnumValuesTrait;

    case VESSEL = 'vessel';
    case TRUCK = 'truck';
}

Hope this helps!

jesseyvanofferen-4s commented 1 month ago

I was also wondering, but I get it it would be out-of-scope for the package, but I'm working on an old code-base. So as a standard models where created with the has Factory trait, however the factory was never created. Right now this will cause the script to stop running. Would it be possible to only output a warning for this? Perhaps even with an parameter to the command to avoid having to do 50-60 runs (We have roughly 200 models).