Skip to content

Print stacktrace when included bootstrap-file throws#51

Merged
ondrejmirtes merged 1 commit intophpstan:masterfrom
staabm:patch-1
Apr 12, 2020
Merged

Print stacktrace when included bootstrap-file throws#51
ondrejmirtes merged 1 commit intophpstan:masterfrom
staabm:patch-1

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Dec 11, 2019

Closes phpstan/phpstan#2210

note: since I cannot build phpstan locally, I wasnt able to test this change (see #50)

@staabm staabm changed the title Print stacktrace when including bootstrap-files throws Print stacktrace when including bootstrap-file throws Dec 11, 2019
@staabm staabm changed the title Print stacktrace when including bootstrap-file throws Print stacktrace when included bootstrap-file throws Dec 13, 2019
@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Dec 15, 2019

just verified the changes on a different workstation.
the following examples use a bootstrap-file, in which a Exception is thrown:

// a file included from phpstan-bootstrap.php
throw new Exception('boom!');

without this change (current master 4c85ff6):
no matter we use the --debug flag or not

$ php ../phpstan-src/bin/phpstan analyze
Note: Using configuration file C:\xampp7.3\htdocs\redaxo\phpstan.neon.dist.
boom!

After this change

$ php ../phpstan-src/bin/phpstan analyze
Note: Using configuration file C:\xampp7.3\htdocs\redaxo\phpstan.neon.dist.
Exception thrown in C:\xampp7.3\htdocs\redaxo\redaxo\src\addons\metainfo\extensions\extension_cleanup.php on line 13: boom!

After this change, when using the additional --debug flag

$ php ../phpstan-src/bin/phpstan analyze --debug
Note: Using configuration file C:\xampp7.3\htdocs\redaxo\phpstan.neon.dist.
Exception thrown in C:\xampp7.3\htdocs\redaxo\redaxo\src\addons\metainfo\extensions\extension_cleanup.php on line 13: boom!
#0 C:\xampp7.3\htdocs\redaxo\phpstan-bootstrap.php(25): require_once()
#1 C:\xampp7.3\htdocs\phpstan-src\src\Command\CommandHelper.php(311): require_once('C:\\xampp7.3\\htd...')
#2 C:\xampp7.3\htdocs\phpstan-src\src\Command\CommandHelper.php(312): PHPStan\Command\CommandHelper::PHPStan\Command\{closure}(Object(SplFileInfo))
#3 C:\xampp7.3\htdocs\phpstan-src\src\Command\AnalyseCommand.php(82): PHPStan\Command\CommandHelper::begin(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutpu
t), Array, NULL, NULL, NULL, 'C:\\xampp7.3\\htd...', 0, false)
#4 C:\xampp7.3\htdocs\phpstan-src\vendor\symfony\console\Command\Command.php(255): PHPStan\Command\AnalyseCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Out
put\ConsoleOutput))
#5 C:\xampp7.3\htdocs\phpstan-src\vendor\symfony\console\Application.php(934): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\
Output\ConsoleOutput))
#6 C:\xampp7.3\htdocs\phpstan-src\vendor\symfony\console\Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(Symfony\Component\Console\Input\
ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 C:\xampp7.3\htdocs\phpstan-src\vendor\symfony\console\Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Ou
tput\ConsoleOutput))
#8 C:\xampp7.3\htdocs\phpstan-src\bin\phpstan(60): Symfony\Component\Console\Application->run()
#9 C:\xampp7.3\htdocs\phpstan-src\bin\phpstan(61): {closure}()
#10 {main}

@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Dec 21, 2019

@ondrejmirtes any Feedback?

@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Dec 28, 2019

Psalm implemented a similar feature
https://github.com/vimeo/psalm/pull/2418/files

@clxmstaab
Copy link
Copy Markdown
Contributor

@ondrejmirtes anything I can do to push this forward?

@clxmstaab
Copy link
Copy Markdown
Contributor

today stumbled over this problem while setting up a new application with phpstan.

bootstrap throws (because of missing constants in the bootstrap before including files) and its really hard to debug because of a missing stacktrace

@ondrejmirtes ondrejmirtes force-pushed the master branch 2 times, most recently from 0786c63 to 9395d76 Compare February 27, 2020 02:48
@ondrejmirtes ondrejmirtes force-pushed the master branch 5 times, most recently from dc2e229 to 1d0d3ad Compare March 17, 2020 14:14
@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Apr 12, 2020

@ondrejmirtes any feedback on this one?

Copy link
Copy Markdown
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two points and it will be good to merge 👍

@ondrejmirtes
Copy link
Copy Markdown
Member

Please fix the conflicts and squash your changes into a single commit rebased on top of master.

@staabm staabm force-pushed the patch-1 branch 2 times, most recently from 02829dc to fe466ac Compare April 12, 2020 09:47
@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Apr 12, 2020

squashed and rebased

@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@ondrejmirtes ondrejmirtes merged commit 9560504 into phpstan:master Apr 12, 2020
@staabm staabm deleted the patch-1 branch April 12, 2020 12:11
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.

provide stacktrace on fatal errors

3 participants