Skip to content

Create new package for reusable utilities#35

Merged
juliolmuller merged 8 commits intomainfrom
feat/lacus-utils
Mar 11, 2026
Merged

Create new package for reusable utilities#35
juliolmuller merged 8 commits intomainfrom
feat/lacus-utils

Conversation

@juliolmuller
Copy link
Copy Markdown
Collaborator

@juliolmuller juliolmuller commented Mar 11, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new utilities library with five core utilities: HTML encoding/decoding, random sequence generation, type description, and URI component encoding/decoding.
  • Chores

    • Updated CI/CD workflows to latest versions
    • Expanded test matrix to include new utilities package
    • Added comprehensive test coverage for new utilities

@juliolmuller juliolmuller requested a review from a team as a code owner March 11, 2026 18:14
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new PHP utility package (packages/utils/) with classes for HTML escaping, random sequence generation, type descriptions, and URI encoding/decoding, alongside comprehensive tests and configuration. GitHub Actions workflows are updated to use newer action versions and include the new utils package in CI matrices.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Updates
.github/workflows/ci.yml, .github/workflows/license-update.yml, .github/workflows/subtrees-sync.yml, .github/workflows/subtrees-tags-sync.yml
Updated actions/checkout to v6.0.2 across all workflows; updated actions/cache to v5.0.3 in CI workflow; added "utils" package to test matrix.
Utils Package Configuration
packages/utils/LICENSE, packages/utils/README.md, packages/utils/composer.json, packages/utils/phpunit.xml
Added package metadata, MIT license, comprehensive documentation, Composer manifest with PHP 8.1+ requirement, and PHPUnit configuration for the new utils package.
Utils Package Source Classes
packages/utils/src/HtmlUtils.php, packages/utils/src/SequenceGenerator.php, packages/utils/src/SequenceType.php, packages/utils/src/TypeDescriber.php, packages/utils/src/UrlUtils.php
Introduced five utility classes: HtmlUtils for HTML entity escaping/unescaping, SequenceGenerator for random character sequences, SequenceType enum for sequence modes, TypeDescriber for JS-like type descriptions with complex array/object handling, and UrlUtils for URI component encoding/decoding.
Utils Package Tests
packages/utils/tests/HtmlUtilsTest.php, packages/utils/tests/SequenceGeneratorTest.php, packages/utils/tests/TypeDescriberTest.php, packages/utils/tests/UrlUtilsTest.php
Added comprehensive PHPUnit test suites covering HTML escaping, sequence generation consistency, type description accuracy across all value types including complex heterogeneous arrays, and URI encoding round-trips.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰✨ A new utils package hops into view,
With helpers for HTML, sequences too!
TypeDescriber knows what values are made,
While URL encoding secrets are weighed.
From workflows updated to tests that are sound,
Lacus Utils—let the logic abound! 🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Create new package for reusable utilities' accurately describes the primary change: adding a new packages/utils directory with utility classes (TypeDescriber, HtmlUtils, SequenceGenerator, UrlUtils) along with comprehensive tests and configuration files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/lacus-utils

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)

34-38: ⚠️ Potential issue | 🟠 Major

Cache keys are too coarse for this matrix.

Line 37 and Line 76 omit matrix.php-version, and the package cache never keys off the package’s own dependency definition. Since /packages/**/composer.lock is gitignored, a packages/<package>/composer.json change will keep reusing the old vendor cache. Include the PHP version and a per-package dependency hash in these keys.

Also applies to: 73-76

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 34 - 38, The cache key for the
actions/cache step is too coarse: update the cache key expression used in the
actions/cache run (the key currently like ${{ runner.os }}-php-${{
hashFiles('**/composer.lock') }}) to include the matrix.php-version variable and
a per-package dependency fingerprint so package-level changes bust the cache
(e.g. include matrix.php-version and hashFiles over package manifests such as
packages/**/composer.lock and packages/**/composer.json); apply the same change
to both occurrences of the actions/cache key in the workflow so the cache is
keyed by PHP version and per-package dependency hashes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/utils/README.md`:
- Around line 7-8: Update the two markdown badges that currently reference
"LacusSolutions/utils-php" so they point to the correct repository
"LacusSolutions/br-utils-php"; specifically replace the URL substrings in the
badge image/link markup (the occurrences of
https://github.com/LacusSolutions/utils-php and the license link to
.../utils-php/blob/main/LICENSE) with the corresponding
https://github.com/LacusSolutions/br-utils-php and
.../br-utils-php/blob/main/LICENSE so the Last Update and Project License badges
resolve to the correct repo.

In `@packages/utils/src/SequenceGenerator.php`:
- Around line 31-45: In SequenceGenerator::generate validate the $size argument
at the start and throw an InvalidArgumentException for negative values instead
of letting the loop be skipped; perform the check before selecting $chars (i.e.,
at the top of generate) and include a clear message (e.g., "Size must be
non-negative") so callers get a fast fail; leave zero allowed (returns empty) if
that behavior is desired.

In `@packages/utils/src/TypeDescriber.php`:
- Around line 28-31: The public static method describe currently exposes the
internal recursion flag $inArray; refactor by making describe(mixed $value):
string the public API and moving the boolean parameter into a private helper
(e.g., private static function describeInternal(mixed $value, bool $inArray):
string). Implement describe to delegate to describeInternal($value, false), and
update the internal caller that previously used describe(..., true) to call
describeInternal(..., true) instead (search for calls to describe passing true).
Ensure all logic that depended on $inArray remains in describeInternal and
remove the boolean from the public signature.

---

Outside diff comments:
In @.github/workflows/ci.yml:
- Around line 34-38: The cache key for the actions/cache step is too coarse:
update the cache key expression used in the actions/cache run (the key currently
like ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}) to include the
matrix.php-version variable and a per-package dependency fingerprint so
package-level changes bust the cache (e.g. include matrix.php-version and
hashFiles over package manifests such as packages/**/composer.lock and
packages/**/composer.json); apply the same change to both occurrences of the
actions/cache key in the workflow so the cache is keyed by PHP version and
per-package dependency hashes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 71bdaf98-528c-4273-8ec4-b731a4bf5e69

📥 Commits

Reviewing files that changed from the base of the PR and between 9c5e8c1 and 8816441.

📒 Files selected for processing (17)
  • .github/workflows/ci.yml
  • .github/workflows/license-update.yml
  • .github/workflows/subtrees-sync.yml
  • .github/workflows/subtrees-tags-sync.yml
  • packages/utils/LICENSE
  • packages/utils/README.md
  • packages/utils/composer.json
  • packages/utils/phpunit.xml
  • packages/utils/src/HtmlUtils.php
  • packages/utils/src/SequenceGenerator.php
  • packages/utils/src/SequenceType.php
  • packages/utils/src/TypeDescriber.php
  • packages/utils/src/UrlUtils.php
  • packages/utils/tests/HtmlUtilsTest.php
  • packages/utils/tests/SequenceGeneratorTest.php
  • packages/utils/tests/TypeDescriberTest.php
  • packages/utils/tests/UrlUtilsTest.php

Comment thread packages/utils/README.md
Comment thread packages/utils/src/SequenceGenerator.php
Comment thread packages/utils/src/TypeDescriber.php
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.

1 participant