Skip to content

Minimum version changed to PHP 8.5 - #1

Merged
nilosoares merged 12 commits into
mainfrom
php85
Sep 11, 2026
Merged

nilosoares merged 12 commits into
mainfrom
php85

Conversation

@nilosoares

Copy link
Copy Markdown
Member

This pull request updates the CPF validation package to require PHP 8.5 or greater and improves type safety and test coverage. It also modernizes the codebase with stricter typing, updates documentation, and enhances test practices. The most important changes are summarized below:

PHP Version and Dependency Updates:

  • Increased the minimum required PHP version from 7.4 to 8.5 in both composer.json and documentation. Updated PHPUnit dependency to version 13.3. [1] [2]

Type Safety and Function Signatures:

  • Updated is_valid_cpf and assert_cpf functions to accept nullable string arguments (?string $cpf) and added declare(strict_types=1); for strict type enforcement in all PHP files. [1] [2]

Documentation Improvements:

  • Revised README.md to reflect new function signatures, PHP version requirements, and improved descriptions for clarity and accuracy. [1] [2] [3] [4]

Testing Enhancements:

  • Updated test cases to use the new nullable string signatures, added strict typing, and switched to PHPUnit attribute-based data providers for better modern PHP compatibility. [1] [2] [3]
  • Improved test data by including null as an invalid CPF and ensuring string casting where appropriate in test loops. [1] [2]

Internationalization and Consistency:

  • Updated package keywords and descriptions to use "brazil" instead of "brasil" and clarified the CPF acronym in both composer.json and documentation.

These changes modernize the codebase, improve reliability, and ensure better compatibility with recent PHP and PHPUnit versions.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The CPF assertion regex must be corrected to reject arbitrary text before or after a valid CPF.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates the CPF validation package to require PHP 8.5, modernizes typing and PHPUnit tests, and refreshes documentation and dependencies.

Changes:

  • Raises PHP and PHPUnit requirements.
  • Adds strict typing and nullable CPF signatures.
  • Updates tests, documentation, and dependency metadata.
File summaries
File Reviewed changes
tests/IsValidCpfTest.php Modernizes tests with strict typing and PHPUnit attributes.
tests/CpfTestCase.php Expands invalid input coverage, including null.
tests/AssertCpfTest.php Updates assertion tests with strict typing and attributes.
src/is_valid_cpf.func.php Adds strict typing and nullable input handling.
src/assert_cpf.func.php Adds nullable assertion typing. Critical (3 votes): the regex alternatives are not fully grouped and anchored, allowing arbitrary surrounding text.
README.md Documents PHP 8.5 requirements and updated signatures.
composer.lock Locks updated dependency versions.
composer.json Updates requirements and package metadata.
Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/assert_cpf.func.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No blocking issues were identified; only a minor wording nit remains.

Review details

Suppressed comments (1)

src/assert_cpf.func.php:11

  • Because this signature now explicitly permits null, assert_cpf(null) reaches the empty() branch, but the exception still says only that the CPF must not be an empty string. Update the validation branch and message to distinguish null and an empty string so callers can understand why nullable input was rejected.
function assert_cpf(?string $cpf): void {
    if (empty($cpf)) {
        throw new InvalidArgumentException('The CPF must not be an empty string.');
  • Files reviewed: 7/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved issues were identified.

Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@nilosoares
nilosoares merged commit 3f0eabe into main Sep 11, 2026
1 check passed
@nilosoares
nilosoares deleted the php85 branch September 11, 2026 20:25
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