Skip to content

Check empty sanitization string run-time#30

Merged
spaze merged 1 commit intomainfrom
spaze/empty-string
Apr 11, 2026
Merged

Check empty sanitization string run-time#30
spaze merged 1 commit intomainfrom
spaze/empty-string

Conversation

@spaze
Copy link
Copy Markdown
Owner

@spaze spaze commented Apr 11, 2026

Annotating with PHPStan is fine, but requires some work to be done by the caller to not pass empty strings. This is more friendly.

Partially reverts some work done in #28

@spaze spaze requested a review from Copilot April 11, 2026 17:05
@spaze spaze self-assigned this Apr 11, 2026
@spaze spaze mentioned this pull request Apr 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes addSanitization() resilient to being called with an empty string by adding a runtime no-op guard, preventing strtr() warnings and reducing caller burden (partially reverting stricter non-empty-string expectations introduced previously).

Changes:

  • Treat addSanitization('') as a no-op in SensitiveValueSanitizer.
  • Remove non-empty-string phpdoc annotations from addSanitization() in both SensitiveValueSanitizer and PhpInfo.
  • Add a regression test ensuring no warning/error occurs when an empty sanitization string is provided.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/SensitiveValueSanitizer.php Adds a guard to ignore empty sanitization keys, avoiding strtr() warnings.
src/PhpInfo.php Aligns PhpInfo::addSanitization() phpdoc expectations with the new runtime behavior.
tests/SensitiveValueSanitizerTest.phpt Adds coverage for the empty-string sanitization case (no warnings/errors).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Annotating with PHPStan is fine, but requires some work to be done by the caller to not pass empty strings. This is more friendly.

Partially reverts some work done in #28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spaze spaze merged commit 61ac829 into main Apr 11, 2026
28 checks passed
@spaze spaze deleted the spaze/empty-string branch April 11, 2026 17:16
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