Repository navigation
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
60 catch (\Throwable) blocks across the transformer, docblock parser and runtime checkers discard the exception to stay fail-open. When one of them fires, a check is skipped or a file is left uninstrumented with no trace of why. Route every one of them through DebugLog::swallowed(), a no-op unless the TYPEPHP_DEBUG environment variable is truthy. When set, the exception class, message, throw site and catch site go to the PHP error log. Default behaviour is unchanged.
naxvog
force-pushed
the
feat/debug-swallowed-errors
branch
from
November 11, 2026 08:35
3d35b6a to
3db4b2a
Compare
Member
|
@naxvog Hello I made a lot of changes on Internal code on the library in my branch and this PR will cause a lot of of merge conflict.. I'm Going to close this PR for now and defer this feature after the next release.. |
Member
|
@naxvog Can you implement a recent version of this PR.. so this library can have feature for surfacing exceptions that this tool swallows.. |
Contributor
Author
|
Done, the new version is #144. It is rebuilt on current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
src/has 60catch (\Throwable)blocks (outside the CLI) that discard the exception so TypePHP stays fail-open: 45 have an empty body, 15 return a fallback. When one fires, a check is skipped or a whole file is left uninstrumented, and there is no way to find out why.StreamWrapper::transformSource()returning the untouched source after a parse error is one example.Change
New
TypePHP\Internal\Diagnostic\DebugLog::swallowed(\Throwable $e). It does nothing unless theTYPEPHP_DEBUGenvironment variable is truthy. When set, it writes the exception class, message, throw site and catch site to the PHP error log:Every one of the 60 catch blocks calls it as its first statement. Blocks that used
catch (\Throwable)now name the variable. No other logic is touched.New
Config::isDebugEnabled(), env only, read like the otherTYPEPHP_*flags.Default behaviour is unchanged. The extra cost is one static call on a path that already threw.
Verification
tests/Internal/Diagnostic/DebugLogTest.php: silent by default, logs when enabled, and reports an unparsable source file.Notes