Usage of the "@" character in the code - error suppression
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.7k
- Forks
- 579
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
Long story short, one of the PDF files I'm trying to parse throws an error - it basically cannot be parsed. Thing is that I cannot catch it with the standard try-catch block, because the parseFile() method from your package suppresses any errors thrown while parsing:
public function parseFile($filename)
{
$content = file_get_contents($filename);
return @$this->parseContent($content);
}
And the line in the Parser.php file: https://github.com/smalot/pdfparser/blob/master/src/Smalot/PdfParser/Parser.php#L74
I would say remove the @. And I would do it everywhere else you might have used it. What do you think?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/Smalot/PdfParser/Parser.php and inspect parseFile(), then search the project for other uses of PHP's @ error-suppression operator. Confirm the relevant parsing errors can propagate to the caller's try-catch handling without suppression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100