Skip to content

Conversation

@spaze
Copy link
Owner

@spaze spaze commented Dec 9, 2025

This will make it easier to use those in projects where SecurityTxt as a name is already a thing, to avoid at least some conflicts.

Better naming as a bonus: add "parameter" suffix to "charset" where it makes sense:
"Charset" is just utf-8, while "charset parameter" is the whole string charset=utf-8 as per RFC 9110.

Follow-ups:

This will make it easier to use those in projects where `SecurityTxt` as a name is already a thing, to avoid at least some conflicts.
@spaze spaze self-assigned this Dec 9, 2025
Copilot AI review requested due to automatic review settings December 9, 2025 02:06
Copy link

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 refactors Content-Type header constants by moving them from the SecurityTxt class to a new dedicated SecurityTxtContentType class. This separation helps avoid naming conflicts in projects where SecurityTxt is already used. The PR also improves naming clarity by distinguishing between "charset" (the value utf-8) and "charset parameter" (the full parameter string charset=utf-8), aligning with RFC 9110 terminology.

Key changes:

  • Created new SecurityTxtContentType class with refined constants: CONTENT_TYPE, CHARSET, CHARSET_PARAMETER, and MEDIA_TYPE
  • Renamed internal SecurityTxtContentType class to SecurityTxtFetchHostContentType to avoid naming conflicts
  • Updated all references throughout the codebase to use the new class and improved naming

Reviewed changes

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

Show a summary per file
File Description
src/SecurityTxtContentType.php New class containing Content-Type related constants with improved naming (CHARSET vs CHARSET_PARAMETER)
src/SecurityTxt.php Removed Content-Type constants now hosted in dedicated class
src/Fetcher/SecurityTxtFetchHostContentType.php Renamed from SecurityTxtContentType; updated property and method names from "charset" to "charsetParameter"
src/Fetcher/SecurityTxtFetcherFetchHostResult.php Updated type hints and instantiation to use renamed SecurityTxtFetchHostContentType class
src/Fetcher/SecurityTxtFetcher.php Updated imports and references to use SecurityTxtContentType constants and renamed getter methods
src/Violations/SecurityTxtContentTypeInvalid.php Updated imports and constant references to use new SecurityTxtContentType class
src/Violations/SecurityTxtContentTypeWrongCharset.php Updated imports, parameter names, and constant references to align with new naming conventions
tests/Fetcher/SecurityTxtFetcherTest.phpt Updated test imports and constant references to use new SecurityTxtContentType class
tests/Fetcher/SecurityTxtFetcherFetchHostResultTest.phpt Updated test to call renamed getLowercaseCharsetParameter() method
README.md Updated documentation to reflect new constant names and added CHARSET_PARAMETER to the list

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

@spaze
Copy link
Owner Author

spaze commented Dec 9, 2025

Interesting thing spotted in the agent session log:

These descriptions look accurate. However, I notice line 115 (which is NOT in the diff) still says "SecurityTxt constants" when it should say "SecurityTxtContentType constants", but since that line isn't part of the changes, I cannot comment on it.

Too bad it cannot comment on it, because that would be a valid comment. Changed in the following commit.

"Charset" is just `utf-8`, while "charset parameter" is the whole string `charset=utf-8`.
@spaze spaze merged commit 56175df into main Dec 9, 2025
16 checks passed
@spaze spaze deleted the spaze/charset branch December 9, 2025 02:48
spaze added a commit that referenced this pull request Dec 9, 2025
spaze added a commit that referenced this pull request Dec 9, 2025
spaze added a commit that referenced this pull request Dec 10, 2025
It's not like these would change, ever. Also helps in IDEs when they show the constant value on hover for example, then you'd like to see the actual value, not what it's concatenated of.

Follow-up to #47
spaze added a commit that referenced this pull request Dec 10, 2025
It's not like these would change, ever. Also helps in IDEs when they show the constant value on hover for example, then you'd like to see the actual value, not what it's concatenated of.

Follow-up to #47
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