JordanRL / Roster

A PHP tool to generate templateable markdown documentation from the docblocks or type-hints of your codebase.
GNU General Public License v3.0
15 stars 0 forks source link

Bug found in: First Run Errors #8

Closed marioquartz closed 3 years ago

marioquartz commented 3 years ago

Describe the bug When using php vendor/bin/roster the code tries use and undefined $oldConfig

To Reproduce php vendor/bin/roster in a library for first time.

Expected behavior Documentation generated

PHP Version PHP 8.0.8 (cli)

Additional context Stack:

Warning: Undefined variable $oldConfig in /app/vendor/samsara/roster/src/Samsara/Roster/Roster.php on line 290

Fatal error: Uncaught Error: Call to a member function get() on null in /app/vendor/samsara/roster/src/Samsara/Roster/Roster.php:290
Stack trace:
#0 /app/vendor/symfony/console/Command/Command.php(299): Samsara\Roster\Roster->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /app/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /app/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand(Object(Samsara\Roster\Roster), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/samsara/roster/src/Samsara/Roster/App.php(32): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/samsara/roster/bin/roster(25): Samsara\Roster\App->run()
#6 {main}
  thrown in /app/vendor/samsara/roster/src/Samsara/Roster/Roster.php on line 290
JordanRL commented 3 years ago

Did you do this with a roster.json file?

marioquartz commented 3 years ago

I have not that file. Is need in the first time?

JordanRL commented 3 years ago

No, it shouldn't be needed. I'm debugging now, should have a patch shortly.

JordanRL commented 3 years ago

Alright, there were multiple issues with first time runs that have now been resolved. I successfully ran it on a repo that had no docs at all.

Fixed in v0.1.5

JordanRL commented 3 years ago

BTW @marioquartz I greatly appreciate this. I made a ton of changes since I released v0.1.0 and it's been hard actually testing all of the paths.

marioquartz commented 3 years ago

New bug. The process start, load templates, start processing files, and in the first file stop and show this:

Warning: Undefined array key 1 in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php on line 281

Fatal error: Uncaught TypeError: Samsara\Mason\DocBlockProcessor::pushTag(): Argument #1 ($tag) must be of type string, null given, called in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php on line 143 and defined in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php:192
Stack trace:
#0 /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php(143): Samsara\Mason\DocBlockProcessor->pushTag(NULL, '', '', '')
#1 /app/vendor/samsara/roster/src/Samsara/Roster/Processors/ClassProcessor.php(46): Samsara\Mason\DocBlockProcessor->__construct('/**\n * Class Ev...', false)
#2 /app/vendor/samsara/roster/src/Samsara/Roster/Roster.php(479): Samsara\Roster\Processors\ClassProcessor->__construct(Object(ReflectionClass))
#3 /app/vendor/symfony/console/Command/Command.php(299): Samsara\Roster\Roster->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand(Object(Samsara\Roster\Roster), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/vendor/samsara/roster/src/Samsara/Roster/App.php(32): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/vendor/samsara/roster/bin/roster(25): Samsara\Roster\App->run()
#9 {main}
  thrown in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php on line 192

There are a docs/roster-export/latest empty directory. And no new json.

JordanRL commented 3 years ago

This is actually a bug in Mason. Problem with regex.

Should be fixed. EDIT: To clarify, I pushed a patch and now it should be fixed.

marioquartz commented 3 years ago

I have update mason to v0.2.3 and I try again. The error is the same. And I think the file processed is this:

<?php

declare(strict_types=1);

namespace Marioquartz\MakingSessions;

/**
 * Class EventList
 * @package Marioquartz\MakingSessions
 * @method EventList orderList($list, $type, $inverse = false)
 */
class EventList extends ItemList
{
    public function order(): EventList
    {
        return self::orderList($this, 'Event');
    }
}

maybe the dockblock has something strange?

marioquartz commented 3 years ago

When removing the docblock of that class Roster works fine.

JordanRL commented 3 years ago

Yeah, regex is weird. It's probably the wrong options on the function call.

JordanRL commented 3 years ago

When removing the docblock of that class Roster works fine.

Do you have other docblocks that have a method tag in them?

marioquartz commented 3 years ago

Do you have other docblocks that have a method tag in them?

No, its the only class with that tag, but when I uses in a similar class (SessionList) gives the same error.

marioquartz commented 3 years ago

Updated to mason v0.2.4 gives the same error with different lines.

Warning: Undefined array key 1 in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php on line 283

Fatal error: Uncaught TypeError: Samsara\Mason\DocBlockProcessor::pushTag(): Argument #1 ($tag) must be of type string, null given, called in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php on line 144 and defined in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php:194
Stack trace:
#0 /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php(144): Samsara\Mason\DocBlockProcessor->pushTag(NULL, '', '', '')
#1 /app/vendor/samsara/roster/src/Samsara/Roster/Processors/ClassProcessor.php(46): Samsara\Mason\DocBlockProcessor->__construct('/**\n * Class Se...', false)
#2 /app/vendor/samsara/roster/src/Samsara/Roster/Roster.php(479): Samsara\Roster\Processors\ClassProcessor->__construct(Object(ReflectionClass))
#3 /app/vendor/symfony/console/Command/Command.php(299): Samsara\Roster\Roster->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand(Object(Samsara\Roster\Roster), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/vendor/samsara/roster/src/Samsara/Roster/App.php(32): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/vendor/samsara/roster/bin/roster(25): Samsara\Roster\App->run()
#9 {main}
  thrown in /app/vendor/samsara/mason/src/Samsara/Mason/DocBlockProcessor.php on line 194
JordanRL commented 3 years ago

Alright, I'm closing this and creating a bug in the mason repo: JordanRL/Mason#1

For now, I guess the method tags an unusable, though Roster doesn't currently document them, so it doesn't reduce functionality.