Fix route matching, typed input, and test tooling in 0.4
This PR fixes several cases where Hypervel accepted a request or value through one path and handled it differently through another. The most visible changes are in routing, typed input, and Artisan’s test commands.
Routing
Allowed methods
If the route cache contains GET /users and the application adds POST /users at runtime, a DELETE /users request now advertises GET, HEAD, and POST. A generated OPTIONS response uses the same combined list.
Custom HTTP methods
An uncached route that accepts only a custom method such as PROPFIND now returns a 405 with that method in Allow when the path is requested with the wrong verb.
Listener ports and generated URLs
Route::port() now matches the port on which the server received the request. This matters behind a proxy, where public HTTPS traffic may arrive on listener 8000. Generated links and signatures use the public origin. Applications that publish listeners at different origins can map them with URL::formatHostUsing().
Cached route precedence
The compiled matcher selects routes for the receiving listener before matching the path. A route on another listener can no longer hide an eligible wildcard or contribute a method to Allow. Matcher data is shared across listeners wherever the routes are identical.
Cached misses
Once the compiled matcher rules out a path, only runtime registrations need checking. This avoids scanning the cache again and preserves the 404 when a compiled route condition fails.
Explicit fallbacks
A matching runtime route can still take precedence over a cached fallback. An automatic OPTIONS response can no longer displace an explicit cached fallback and discard its bound parameters.
Helpers and collections
Global helper signatures
Collections, Support, and Foundation helpers now declare their parameter and return types. Generic PHPDoc still describes results that depend on the caller’s input, including the element returned by head() and last(), or false for an empty array. Calls outside the declared contract, such as passing a non-array to head(), can now raise TypeError.
Collection construction
The signatures for collect(), the eager and lazy constructors, and Enumerable::make() cover the scalar, enum, object, and iterable inputs the implementations already accept. PHPStan keeps key and element types for typed iterables. For a single enum case, collect() infers that case as the sole item at key zero. Custom implementations of Enumerable::make() with a narrower parameter need to widen it.
Exception reporting in rescue()
A callable reporting predicate is evaluated with the exception. An array callable that returns false now suppresses reporting as requested. Coroutine cancellation still propagates.
Return type of transform()
The inferred return type follows the same blank-value check as the implementation. For example, zero goes through the callback, so PHPStan should infer the callback’s result.
Typed values
Strict numeric input
Strict integer reads check the original float for an exact, in-range integer. Previously 434.99999999999994 could round to 435 before validation. Lightweight data objects apply the same check and keep their existing exception behavior. Strict float reads preserve the precision of finite native floats.
Permissive integer casts
The integer input getter and form-request integer casts truncate ordinary floats, clamp finite overflow to the platform limits, and return zero for NaN and infinities. This avoids a PHP 8.5 cast warning becoming an exception.
Cached integers
Cache::integer() now rejects a cached fractional float and accepts large whole floats that fit in an integer. Numeric strings, Stringable values, and missing-key defaults keep their existing behavior.
Pagination
The page resolver uses the strict request integer getter. A fractional JSON page number now falls back to page one. Valid query-string page numbers still work.
Boolean input
Native floating-point zero and one are recognized as boolean tokens by value. A fraction close to one no longer rounds to true. Request getters, validated form casts, lightweight data objects, and Passport keep their own handling for unrecognized input. Hypervel Data retains its separate weak scalar conversions.
Testing tools
PHPUnit and ParaTest
Artisan runs PHPUnit for serial tests and ParaTest for parallel tests. The generators produce PHPUnit tests. This removes Pest detection, --pest, Pest stubs, and the remaining Testbench integration. Applications can continue to use --test or --phpunit for companion tests. The documentation examples now use PHPUnit.
Model and controller companion tests
make:model Foo --controller --phpunit now creates tests for both the model and the controller. Previously the controller generator never received the request to create its test.
Database CI
The nightly MySQL Innovation suite runs over a Unix socket, with a separate native schema dump over TCP. The regular MySQL 8.4 and PostgreSQL 18 jobs retain full TCP coverage on both PHP versions, including PostgreSQL password authentication.
Backlog cleanup
Base skeleton development command
The base skeleton already starts the server watcher and Vite through composer dev. This closes the old entry.
Configuration getters
Nullable getters and the migration to typed configuration reads are already in 0.4. The corresponding entries have been removed.
Pathless HTTP requests
The path and query parsing issue reproduces in Symfony HttpFoundation. It is tracked upstream.
Verification
Checked formatting and static analysis, the affected routing, generator, helper, cache, pagination, and request tests, and Testbench through its package command. The numeric regressions were exercised on PHP 8.4 and 8.5. The MySQL Innovation suite and native dump were exercised against a live database over the intended transports.
Summary by cubic
Fixes several cases where Hypervel handled the same request or value differently depending on code path, covering routing, typed input, and Artisan's test tooling.
Routing
- Route matching now filters compiled routes by the receiving listener's port, so a route on another listener can't shadow an eligible wildcard or add methods to
Allow;Route::port()matchesSERVER_PORT, while generated links and signatures use the public origin. - Explicit custom methods like
PROPFINDyield a 405 withAllowlisting that method,Allowmerges cached and runtime methods, an automaticOPTIONSresponse no longer displaces a cached explicit fallback, and post-cache misses only check runtime registrations.
Input handling and testing
- Strict integer reads require an exactly integral float in range; permissive casts truncate, clamp finite overflow, and return zero for non-finite values;
parse_boolean()compares native floats by value. Cache::integer()rejects fractional cached floats, pagination uses the strict integer getter, andrescue()honors callable reporting predicates.- Collections, Support, and Foundation global helpers declare native parameter and return types;
collect()preserves inferred enum element types. - Removed Pest detection,
--pest, Pest stubs, and Testbench Pest integration; Artisan runs PHPUnit serially and ParaTest in parallel. make:model --controller --phpunitgenerates tests for both the model and the controller, and nightly MySQL Innovation tests run over a Unix socket with a separate native schema dump over TCP.
Also cleans up completed backlog items: base skeleton composer dev script, nullable config getters, and the upstream-tracked pathless HTTP request issue.
[!NOTE]
Fix route matching, typed input, and test tooling in 0.4
- Fix compiled route matching to select matcher tables by the request's
SERVER_PORT, check runtime dynamic routes on method-not-allowed and fallback results, and merge compiled and runtime allowed methods in CompiledRouteCollection.php. Alternate-verb detection in AbstractRouteCollection.php now considers custom registered HTTP methods.
- Fix URL generation in RouteUrlGenerator.php so domain URLs use the current request's port and secure state, and routes without an explicit domain no longer substitute their port into the root URL.
- Add native parameter and return types across global helpers in Collections, Support, and Foundation. Typed data accessors (
InteractsWithData.boolean/integer/float) now use parse_boolean and Number::tryConvertFloatToInteger/castFloatToInteger for strict float handling.
- Remove Pest integration: drop the
--pest option from make:test and matching-test creation, delete Pest stubs, make the test command run PHPUnit serially and ParaTest in parallel, and convert all docs examples to PHPUnit (porting-from-laravel.md).
- Behavioral Change:
make:test --pest no longer exists; strict integer access rejects fractional floats and out-of-range floats return the default; rescue() now invokes a callable report argument with the caught exception instead of passing it through value(); head()/last() on empty arrays return false.
Macroscope summarized cbbf247.
Summary by CodeRabbit
-
New Features
- Route matching now supports listener-specific ports, and generated links use the public origin.
- Numeric and boolean conversions handle floats and boundary values more consistently.
- Collection helpers accept broader input types with clearer type declarations.
-
Bug Fixes
- Improved method reporting for custom HTTP verbs and combined cached and runtime routes.
- Pagination safely defaults fractional page values to the first page.
-
Documentation
- Testing examples now use PHPUnit; routing documentation covers port-specific routes.