Skip to content

[refactor] type safety and edge case tests#4

Merged
ordinary9843 merged 13 commits intomasterfrom
refactor/type-safety-and-edge-case-tests
Apr 17, 2026
Merged

[refactor] type safety and edge case tests#4
ordinary9843 merged 13 commits intomasterfrom
refactor/type-safety-and-edge-case-tests

Conversation

@ordinary9843
Copy link
Copy Markdown
Owner

Summary

  • Add declare(strict_types=1) to all src/ files
  • Replace __call delegation with explicit typed proxy methods in Ghostscript.php
  • Replace string-concat class lookup in HandlerFactory with explicit map array
  • Fix nullable type annotations (BaseException $previous?BaseException $previous)
  • Fix wrong docblock in ConfigTrait (@param int $tmpPath@param string $tmpPath)

Bug fixes

  • SplitHandler: range(0, N-1) returned part_0.pdfpart_{N-1}.pdf but GS outputs part_1.pdfpart_N.pdf
  • MergeHandler / GetTotalPagesHandler: $file undefined in catch block if exception thrown before assignment
  • MergeHandler / SplitHandler / ToImageHandler: missing parent::__construct() call
  • BaseHandler::isPdf(): calling mime_content_type() on non-existent file emitted E_WARNING
  • MergeHandler: empty $files after filtering caused GS to hang; now throws HandlerException
  • ToImageHandler: invalid image type silently passed to GS; now validated against allowed types

New edge case tests (+34 tests, 123 total)

  • BaseHandlerEdgeCaseTest — empty string / non-existent path / directory path, tmp file ops, options format
  • ConvertHandlerEdgeCaseTest — empty file path
  • GuessHandlerEdgeCaseTest — no version header, empty path
  • MergeHandlerEdgeCaseTest — empty array, all-invalid files, single valid file
  • SplitHandlerEdgeCaseTest — verifies output starts at part_1.pdf, files actually exist
  • ToImageHandlerEdgeCaseTest — invalid image type (bmp) throws exception
  • GetTotalPagesHandlerEdgeCaseTest — empty path, non-existent file
  • HandlerFactoryEdgeCaseTestgetTotalPages handler, case-sensitive type check
  • PathHelperEdgeCaseTest — empty string, backslashes, mixed separators, spaces in path

Workflow

  • Add pull_request trigger to build.yml so CI runs on PRs across PHP 7.1–8.4

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@ordinary9843 ordinary9843 merged commit 1141bc7 into master Apr 17, 2026
11 checks passed
@ordinary9843 ordinary9843 deleted the refactor/type-safety-and-edge-case-tests branch April 17, 2026 21:04
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.

1 participant