Skip to content

From 100x to 1000x faster#419

Open
Ostico wants to merge 45 commits intoklein:masterfrom
matecat:master
Open

From 100x to 1000x faster#419
Ostico wants to merge 45 commits intoklein:masterfrom
matecat:master

Conversation

@Ostico
Copy link

@Ostico Ostico commented Oct 23, 2025

Version 3.2.0

Features

  • Lightning fast routing! From 100x to 1000x faster dispatch. Big performance improvements for large route collections with radix Tree routing. Benchmarks
  • 100% Code Coverage
  • Breaking changes, see UPGRADING.md

Ostico and others added 30 commits October 14, 2025 17:37
- Updated Phpunit to 9.6
- Implicitly marking parameter $app_context as nullable is deprecated
Removed version specification from the project description.
- Radix Tree creation by url tokens instead of characters
Improved: Radix Index backwards lookup.
@Ostico Ostico changed the title From 100x to 100x faster From 100x to 1000x faster Oct 24, 2025
mocked with PHPUnit >= 12

Because of their decision to not allow methods named "method" to be
mocked (throw Exception), we must introduce a big breaking change.

sebastianbergmann/phpunit#5415
Reorganized namespaces from `Klein\Tests` to `Matecat\Tests\Klein` for consistency. Introduced new benchmarks and optimized route validation methods for improved performance and clarity. Removed unused files and applied coding standards across classes.
Fixed 20 PHPStan errors across the codebase to improve type safety and code
quality. All changes maintain backward compatibility and existing functionality.

Changes by file:

* HeaderDataCollection.php:
  - Add PHPDoc type hint for constructor array parameter

* Klein.php:
  - Fix $requestMethod parameter type in filterMatchingRoutes() (string instead of string|array)
  - Refactor boolean expression to avoid "always true" warning by separating
    method matching logic from route URI assignment

* Route.php:
  - Remove nullable type from $regex property (never assigned null)
  - Change @type to @var annotations for PHPStan compatibility
  - Initialize $regexMatchingParams array property with default empty array
  - Remove unnecessary null coalescing operators on $namespace property
  - Add PHPStan suppressions for defensive runtime checks (is_array validation
    and nested array exception)

* RouteRegexCompiler.php:
  - Fix private constant access by using self:: instead of static::

* RadixRouteIndex.php:
  - Add complete PHPDoc type hints for constructor parameters
  - Update property types to support recursive array references in radix tree
  - Fix preg_split offset access with proper false handling
  - Add PHPStan suppressions for recursive array structure and type inference
    edge cases in loop logic

Result: PHPStan analysis now passes with zero errors.
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

Comments