Skip to content

Conversation

@simonLeary42
Copy link
Collaborator

No description provided.

Copy link
Contributor

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 introduces a new str2int() utility function to replace direct calls to intval(). The function provides stricter validation by throwing a ValueError exception when the input is not numeric, rather than silently converting invalid inputs to 0 or issuing warnings.

Key changes:

  • Added str2int() function in resources/lib/utils.php that validates numeric strings before conversion
  • Replaced intval() calls with str2int() in three locations across the codebase
  • Updated contribution guidelines and test configuration to enforce the use of str2int() over intval()

Reviewed changes

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

Show a summary per file
File Description
resources/lib/utils.php Added new str2int() function that validates input with is_numeric() before calling intval(), throwing ValueError for non-numeric inputs
webroot/panel/account.php Replaced manual regex validation and intval() with str2int() for SSH key deletion index
webroot/api/content/index.php Changed line wrap parameter parsing from intval() to str2int() with string literal "80" as default
resources/lib/UnityLDAP.php Replaced intval() with str2int() for parsing UID numbers from CSV mappings
test/assert-utils-used.bash Added assertion to enforce str2int() usage instead of intval()
.pre-commit-config.yaml Extended exclusion pattern for utils assertion test to exclude test files
CONTRIBUTING.md Added documentation stating intval() should not be used directly

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

@simonLeary42 simonLeary42 marked this pull request as ready for review December 17, 2025 01:02
@simonLeary42 simonLeary42 merged commit 8348ca7 into main Dec 17, 2025
2 of 3 checks passed
@simonLeary42 simonLeary42 deleted the post-get-cast-to-int branch December 17, 2025 01:02
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