Skip to content

Allow single-letter variable names in camelCase rule and update examples#70

Merged
Orrison merged 1 commit intomainfrom
issue-69
Aug 31, 2025
Merged

Allow single-letter variable names in camelCase rule and update examples#70
Orrison merged 1 commit intomainfrom
issue-69

Conversation

@Orrison
Copy link
Owner

@Orrison Orrison commented Aug 31, 2025

This pull request makes targeted improvements to the CamelCase variable name rule, clarifying documentation, adjusting the regex logic to be more permissive, and updating test fixtures to reflect the intended behavior. The main focus is ensuring that single-letter variable names are allowed, and the regex for variable name validation is updated accordingly.

Rule logic adjustment:

  • Updated the regex pattern in CamelCaseVariableNameRule.php to make the trailing group optional, allowing single-letter variable names to pass the validation.

Documentation update:

  • Added a comment in CamelCaseVariableName.md to explicitly state that single-letter variables (e.g., $i) are valid.

Test fixture update:

  • Added a single-letter variable assignment in ExampleClass.php to demonstrate and test that such variables are allowed.

Resolves #69

Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
@Orrison Orrison requested a review from Copilot August 31, 2025 02:53
@Orrison Orrison self-assigned this Aug 31, 2025
@Orrison Orrison added the bug Something isn't working label Aug 31, 2025
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 refines the CamelCase variable name rule to properly allow single-letter variable names like $i by making the regex pattern more permissive and updating documentation and test fixtures to reflect this intended behavior.

Key Changes

  • Updated regex pattern to make trailing camelCase groups optional, allowing single-letter variables
  • Added documentation clarifying that single-letter variables are valid
  • Enhanced test fixture with single-letter variable example

Reviewed Changes

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

File Description
src/Rules/CamelCaseVariableName/CamelCaseVariableNameRule.php Modified regex pattern to make trailing groups optional for single-letter variable support
docs/CamelCaseVariableName.md Added documentation example showing single-letter variables are valid
tests/Rules/CamelCaseVariableName/Fixture/ExampleClass.php Added test case with single-letter variable assignment

@Orrison Orrison merged commit c824159 into main Aug 31, 2025
5 checks passed
@Orrison Orrison deleted the issue-69 branch August 31, 2025 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CamelCaseVariableNameRule incorrectly considers variables like $i a violation

2 participants