Skip to content

Modernise: native types, multi-engine CI, static analysis, Testbench#2

Merged
glennjacobs merged 7 commits into
mainfrom
maintenance/modernise
Jun 1, 2026
Merged

Modernise: native types, multi-engine CI, static analysis, Testbench#2
glennjacobs merged 7 commits into
mainfrom
maintenance/modernise

Conversation

@glennjacobs
Copy link
Copy Markdown
Contributor

Maintenance pass now that the package is Lunar-maintained. All commits are scoped one-per-change for review.

What's in here

Change Notes
Fix NestedSet::isNode() It inspected object properties ((array)$node) instead of used traits, so it returned false for every genuine node. Now uses class_uses_recursive(); regression test added.
Laravel Pint Laravel preset, codebase formatted, format/lint composer scripts.
Orchestra Testbench Replaced the hand-rolled Capsule bootstrap so the package is exercised through a real Laravel app. Tests/models namespaced under PSR-4. Service-provider Blueprint macros (nestedSet()/dropNestedSet()) now covered.
Native type declarations Params/returns/typed properties across src/; ~430 lines of redundant docblocks removed. Corrected several inaccurate upstream docblocks (e.g. moveNode returns bool, columnPatch returns Expression). No behavioural change.
Larastan Level 5 with a baseline for PHPStan's known trait-in-isolation false positives. analyse script + CI job.
CI matrix Tests now run against SQLite, MySQL and PostgreSQL + a coverage job.
Docs README Contributing section, CONTRIBUTING.md, CHANGELOG.md.
composer.lock Removed stray local copy (already gitignored).

Notably

Testing across all three engines wasn't just box-ticking — PostgreSQL surfaced a real latent test bug (a test ordered categories by a non-existent title column; SQLite/MySQL silently tolerate it, Postgres rejects it). Fixed in the CI commit. Validated locally against MySQL 8 and PostgreSQL 16 via Docker.

Verification

  • 87 tests / 232 assertions green on SQLite, MySQL and PostgreSQL
  • Pint clean
  • PHPStan clean

Out of scope (deliberately)

  • bigInteger for _lft/_rgt — left as-is per discussion.
  • Publishable example migration — not needed for Lunar.

🤖 Generated with Claude Code

glennjacobs and others added 7 commits June 1, 2026 14:07
`(array)$node` casts an object to its properties, not its used traits,
so isNode() returned false for genuine nodes. Use class_uses_recursive()
with strict comparison instead. Add a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adopt the Laravel preset via pint.json and apply it across src/ and
tests/. Add composer format/lint scripts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-rolled Capsule bootstrap with Orchestra Testbench so the
package is exercised through a real Laravel application: service provider
registration, the database layer, and connection config.

- Namespace tests and models under Lunar\Nestedset\Tests (PSR-4 autoload-dev)
- Add a base TestCase that configures sqlite/mysql/pgsql connections from
  env vars, ready for a multi-engine CI matrix
- Reset Postgres sequences after seeding rows with explicit ids
- Add ServiceProviderTest covering the nestedSet()/dropNestedSet() macros
- Drop phpunit.php; bootstrap from the Composer autoloader

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Run the suite across all three engines via service containers, and add a
dedicated coverage job (pcov + clover). Validated locally against MySQL 8
and PostgreSQL 16.

Fix a test that ordered categories by a non-existent `title` column: SQLite
and MySQL tolerate it, but PostgreSQL (correctly) rejects it. Order by
`name` instead — the assertions are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add parameter, return and property types throughout the library now that
the package requires PHP 8.3+, and remove docblocks made redundant by them.
No behavioural change.

Framework-override signatures are kept compatible with the installed
Laravel version (some params left untyped where the parent declares none).
A few inaccurate upstream docblocks were corrected to match real return
types (e.g. moveNode returns bool, columnPatch returns Expression,
getMissingParentQuery returns a base query builder).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Analyse src/ at level 5 with a baseline capturing the pre-existing
trait-analysis findings (PHPStan's known limitation when a trait is
analysed outside its host model). New code is held to level 5.

Add a composer `analyse` script and a CI static-analysis job that also
enforces Pint formatting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a Contributing section to the README covering the test/lint/analyse
scripts and multi-engine testing, plus CONTRIBUTING.md and CHANGELOG.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@glennjacobs glennjacobs merged commit bac990e into main Jun 1, 2026
6 checks passed
@glennjacobs glennjacobs deleted the maintenance/modernise branch June 1, 2026 14:50
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