Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Throw exception when configuration can be parsed as yaml, but does not contain array #258

Merged

Conversation

localheinz
Copy link
Contributor

This PR

  • throws an exception when configuration can be parsed as yaml, but does not contain an array

Before

Running

$ touch foo.txt
$ php deptrac.php analyze foo.txt

yields

deptrac is alpha, not production ready.
please help us and report feedback / bugs.

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to SensioLabs\Deptrac\Configuration\Configuration::fromArray() must be of the type array, null given, called in /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Loader.php on line 30 and defined in /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Configuration.php:17
Stack trace:
#0 /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Loader.php(30): SensioLabs\Deptrac\Configuration\Configuration::fromArray(NULL)
#1 /Users/am/Sites/sensiolabs-de/deptrac/src/Console/Command/AnalyzeCommand.php(61): SensioLabs\Deptrac\Configuration\Loader->load('foo.txt')
#2 /Users/am/Sites/sensiolabs-de/deptrac/vendor/symfony/console/Command/Command.php(255): SensioLabs\Deptrac\Console\Command\AnalyzeCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/am/Sites/sensiolabs-de/deptrac/vendor/symfony/console/Application.php(921): Symfony\Component\Console\Command\Command->run(Object(Symfony\Compon in /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Configuration.php on line 17

Fatal error: Uncaught TypeError: Argument 1 passed to SensioLabs\Deptrac\Configuration\Configuration::fromArray() must be of the type array, null given, called in /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Loader.php on line 30 and defined in /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Configuration.php:17
Stack trace:
#0 /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Loader.php(30): SensioLabs\Deptrac\Configuration\Configuration::fromArray(NULL)
#1 /Users/am/Sites/sensiolabs-de/deptrac/src/Console/Command/AnalyzeCommand.php(61): SensioLabs\Deptrac\Configuration\Loader->load('foo.txt')
#2 /Users/am/Sites/sensiolabs-de/deptrac/vendor/symfony/console/Command/Command.php(255): SensioLabs\Deptrac\Console\Command\AnalyzeCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/am/Sites/sensiolabs-de/deptrac/vendor/symfony/console/Application.php(921): Symfony\Component\Console\Command\Command->run(Object(Symfony\Compon in /Users/am/Sites/sensiolabs-de/deptrac/src/Configuration/Configuration.php on line 17

After

Running

$ touch foo.txt
$ php deptrac.php analyze foo.txt

yields


deptrac is alpha, not production ready.
please help us and report feedback / bugs.


In ParsedYamlIsNotAnArrayException.php line 11:

  File "foo.txt" can be parsed as YAML, but the result is not an array.


analyze [--formatter-graphviz [FORMATTER-GRAPHVIZ]] [--formatter-graphviz-display [FORMATTER-GRAPHVIZ-DISPLAY]] [--formatter-graphviz-dump-image [FORMATTER-GRAPHVIZ-DUMP-IMAGE]] [--formatter-graphviz-dump-dot [FORMATTER-GRAPHVIZ-DUMP-DOT]] [--formatter-graphviz-dump-html [FORMATTER-GRAPHVIZ-DUMP-HTML]] [--formatter-console [FORMATTER-CONSOLE]] [--formatter-junit [FORMATTER-JUNIT]] [--formatter-junit-dump-xml [FORMATTER-JUNIT-DUMP-XML]] [--no-banner] [--no-progress] [--] [<depfile>]

@localheinz localheinz force-pushed the feature/parsed-yaml-is-not-an-array branch from ba08630 to b112b75 Compare August 21, 2019 07:18
@smoench smoench merged commit 7a1acb3 into qossmic:master Aug 21, 2019
@smoench
Copy link
Contributor

smoench commented Aug 21, 2019

Thank you, @localheinz!

@localheinz localheinz deleted the feature/parsed-yaml-is-not-an-array branch August 21, 2019 08:10
@localheinz
Copy link
Contributor Author

Thank you, @smoench!

@smoench smoench added this to the 0.6 milestone Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants