Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f224a7a
Plan the routing method and listener-port fixes
binaryfire Nov 24, 2026
8881841
Match route ports against the receiving listener
binaryfire Nov 24, 2026
9dcf4b5
Filter cached routes by listener before matching
binaryfire Nov 24, 2026
1ee7ec4
Advertise explicitly registered custom HTTP methods
binaryfire Nov 24, 2026
ec5ff41
Avoid rescanning cached routes after a compiled 404
binaryfire Nov 24, 2026
7e094a4
Preserve explicit cached fallbacks during runtime lookup
binaryfire Nov 24, 2026
6a2bd3c
Merge allowed methods from cached and runtime routes
binaryfire Nov 24, 2026
887a09c
Remove the pathless request-target item from the framework backlog
binaryfire Nov 24, 2026
81a3f6c
Remove the completed base skeleton dev script TODO
binaryfire Nov 24, 2026
4af0b07
Require explicit approval for each backlog addition
binaryfire Nov 24, 2026
e4341a3
Plan the global helper type contracts
binaryfire Nov 24, 2026
9e9e003
Align collection input types with supported construction paths
binaryfire Nov 24, 2026
8711b43
Honor callable reporting predicates in rescue
binaryfire Nov 24, 2026
85c69ca
Describe the return type of transform using its actual blank checks
binaryfire Nov 24, 2026
ac019c7
Complete native typing for the framework’s global helpers
binaryfire Nov 24, 2026
0630678
Remove the completed nullable configuration getters TODO
binaryfire Nov 24, 2026
2c190ea
Run nightly MySQL Innovation tests over a Unix socket
binaryfire Nov 24, 2026
9e75ae7
Honor --phpunit when generating a controller with a model
binaryfire Nov 24, 2026
e76615a
Remove Pest integration from test runners, generators and Testbench
binaryfire Nov 24, 2026
53e0a4c
Remove the completed typed config reads TODO
binaryfire Nov 24, 2026
f483190
Preserve native float precision in strict numeric reads
binaryfire Nov 24, 2026
5ef00db
Handle native float overflow in permissive integer casts
binaryfire Nov 24, 2026
647c93f
Reject fractional cached values in integer reads
binaryfire Nov 24, 2026
f0f4138
Resolve pagination inputs with the strict integer getter
binaryfire Nov 24, 2026
b93ecb9
Parse numeric boolean input without display rounding
binaryfire Nov 24, 2026
c534a69
Remove the database CI and PHPUnit runner plans
binaryfire Nov 24, 2026
047ed52
Throw the queue fixture exception only when configured
binaryfire Nov 24, 2026
cbbf247
Preserve the enum item type inferred for collect()
binaryfire Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/databases-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ permissions:
contents: read

jobs:
# @TODO: Use Unix sockets once Swoole fixes cold caching_sha2_password authentication; see docs/todo.md.
mysql_innovation:
if: github.repository == 'hypervel/components'

Expand All @@ -19,6 +18,8 @@ jobs:
services:
mysql:
image: mysql:innovation
volumes:
- database-socket:/var/run/mysqld
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testing
Expand All @@ -31,6 +32,8 @@ jobs:

container:
image: ghcr.io/hypervel/components-ci:php8.4-swoole-nightly
volumes:
- database-socket:/var/run/mysqld

name: MySQL Innovation

Expand All @@ -49,12 +52,23 @@ jobs:
- name: Execute integration tests
env:
DB_HOST: mysql
DB_SOCKET: /var/run/mysqld/mysqld.sock
DB_PORT: 3306
DB_DATABASE: testing
DB_USERNAME: root
DB_PASSWORD: password
run: bin/run-database-tests.sh mysql

- name: Verify native schema dump over TCP
env:
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: 3306
DB_DATABASE: testing
DB_USERNAME: root
DB_PASSWORD: password
run: vendor/bin/phpunit --no-progress tests/Integration/SchemaParser/Database/MySql/SchemaParserTest.php

mariadb:
if: github.repository == 'hypervel/components'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ jobs:
DB_PASSWORD: password
run: bin/run-database-tests.sh pgsql

# Keep TCP coverage for coroutine transport and password authentication.
# Keep TCP coverage for coroutine transport and password authentication. The service trusts local socket connections.
pgsql_18:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ See [Coroutine Cancellation](src/docs/coroutines.md#coroutine-cancellation) for
Resolve the technical issues below through evidence-based second-opinion loops with your peer agent, then proceed on consensus. Ask the owner only for unapproved public API departures or capability removals; database schema changes; meaningful performance regressions or weakened guarantees; consequential tradeoffs the requirements do not settle; unresolved peer disagreements; or actions requiring owner authorization.

- **Investigate anything unusual** — missing dependencies, logic needing special consideration, things that don't make sense for Hypervel, etc. Investigate and reach consensus on the findings and recommended action through a second-opinion loop with your peer agent before implementing. Do not dismiss concerns as theoretical without investigation. If no supported, realistic path or meaningful harm is found, do not present it as a defect or add machinery to address it.
- **Do not defer work without owner authorization** — do not remove functionality or substitute stubs or TODOs for implementation unless the owner authorizes it. Preserve existing TODO comments unless their underlying work is verified complete or the owner directs otherwise. If blocked, reach consensus on a complete solution through a second-opinion loop with your peer agent.
- **Do not defer work without owner authorization** — do not remove functionality or substitute stubs or TODOs for implementation unless the owner authorizes it. Adding an item to `docs/todo.md` should be rare and requires explicit owner approval for that item. Preserve existing TODO comments unless their underlying work is verified complete or the owner directs otherwise. If blocked, reach consensus on a complete solution through a second-opinion loop with your peer agent.
- **Investigate source code bugs** — for bugs found in Hypervel or upstream code being ported, including through PHPStan or tests, reach consensus on the root cause and fix through a second-opinion loop with your peer agent before implementing. Upstream bugs must be fixed, not ported as-is.
- **Trace upstream differences before calling them bugs** — a difference from Laravel or an upstream package is not proof that Hypervel is wrong, and matching upstream is not proof that Hypervel is correct. A verified Hypervel defect remains a defect when upstream has the same problem.
- **Do not work around incorrect existing code to avoid churn** — if work exposes incorrect types, wrong logic, missing methods/classes, or other real defects in existing Hypervel code, fix the underlying code instead of adding compatibility hacks or local workarounds to sidestep the problem. Prioritize correctness and code quality over keeping the change small. For any non-trivial fix, reach consensus on the root cause and fix through a second-opinion loop with your peer agent before implementing.
Expand Down Expand Up @@ -828,6 +828,7 @@ Read `docs/ai/porting-hyperf.md` only when porting a Hyperf package or update.
Owner-approved exclusions that apply across packages. Package-specific differences belong in the package README.

- Laravel Boost and package-provided Boost resources, including skills and guidelines.
- Pest integration, including generator options and stubs, test-runner selection and Testbench helpers.

### Source workflow

Expand Down
40 changes: 40 additions & 0 deletions docs/plans/2026-11-24-global-helper-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Complete the native types of global helpers

## Contract and scope

Every global function in the Collections, Support and Foundation helper files must have native parameter and return types. Keep parameter names, defaults, variadics, reference passing, and supported Laravel behavior. Use `mixed` for arbitrary values, such as container bindings and callback results. Keep PHPDoc where it describes types more precisely than PHP can. Remove the corresponding framework-wide TODO once the complete change is verified.

## Collections

- Keep `collect()` and the eager and lazy constructors compatible with the values their implementations already accept. `getArrayableItems()` wraps scalars and enum cases, accepts null and delegates other inputs to `Arr::from()`. The shared collection tests cover scalars, objects, null, and both construction and `make()`. Dedicated tests construct and collect enum cases. Keep the lazy collection's closure/self handling and its exception for a directly supplied Generator. Preserve the runtime error for unsupported resources.
- Widen the input PHPDocs and use native `mixed` for the eager constructor, helper and `Enumerable::make()`. The concrete factories already accept `mixed`. Laravel's interface accepts an untyped argument. A custom implementation written against Hypervel's former narrower interface signature must widen that parameter. The framework and private packages contain no such implementation.
- Infer keys and values at the input boundary: use explicit generic Arrayable and iterable input types plus a method-local object template for other objects. A plain `object` union would swallow the specialized inputs. The return is simply `Collection<TKey, TValue>` or `static<TMakeKey, TMakeValue>`. Unknown keys can be integers or strings, including property names from plain objects. The existing scalar inference extension is sufficient. Preserve keyed arrays, generic Arrayable and Traversable inputs, lazy generator factories and inferred empty collections. The bleeding-edge suite has cases where later calls to `push()`, `put()` or `merge()` determine an empty collection's types.
- Preserve by-reference targets in `data_fill()`, `data_set()` and `data_forget()`. Use `mixed` for arbitrary targets and values, the declared array/int/string key types, and nullable keys on get, has, and forget. Only the overwrite flag on set is boolean. Type `value()` and `when()` without changing which callbacks are executed.
- For `head()` and `last()`, use native `(array $array): mixed`. Their PHPDoc tracks the element type and distinguishes an empty array:

```php
/**
* @template TValue
*
* @param array<array-key, TValue> $array
* @return ($array is array{} ? false : TValue)
*/
```

## Support

Match class and trait helpers to their object/class-name inputs, preserving the tested integer input to `class_basename()`. `fluent()` accepts arrays, objects and null. `object_get()` takes an object and a bool/int/string/null key, including the tested false key. Keys or targets that were only incidentally coerced outside the declared contracts may now raise TypeError, as may falsy non-arrays passed to `head()` or `last()`.

Use native `mixed` on genuinely unconstrained callback inputs and outputs. Keep generic and conditional PHPDocs for `once()`, `tap()`, `optional()`, `with()`, and conditional throws. Match `retry()` to its integer/array attempts, CarbonInterval/Closure/float/int delay and optional callable predicate. `str()` returns a native Stringable both for its anonymous proxy and its concrete string wrapper. Preserve the distinction between no argument and explicit null.

Correct `transform()`'s return PHPDoc using `blank()`'s semantics. Null, the empty string, and an empty array select the default. Numeric and boolean values, nonempty arrays, and Eloquent models select the callback. Other strings can be whitespace, and Countable or Stringable objects can be blank, so their static types can yield either result. Keep both upstream type fixture suites. Use a zero-value assertion to distinguish this contract from PHP's `empty()`.

## Foundation and exception reporting

Keep `app()`, `resolve()`, `policy()` and `context()` polymorphic. Context accepts array/string/null keys and dispatch passes arbitrary jobs to the existing pending dispatch types. Preserve type extension and class-string inference.

On `rescue()`'s exception path, evaluate a boolean report flag directly or invoke its callable with the exception. Previously an array callable returning false was treated as a truthy value and the exception was reported anyway. Cancellation still propagates first. Keep fallback evaluation through `value()`: a Closure computes the fallback, and other values, including callable strings, are returned as given.

## Verification

Run each edited test file when changed. Reuse the existing helper and collection suites and the Laravel and Larastan type fixtures. Add focused assertions for the empty-array sentinel, valid collection inputs previously rejected, the zero case in transform, and a non-Closure reporting predicate. Verify with reflection that every global function defined by all three files has native parameter and return types. Run CS Fixer, full PHPStan including type/test/skeleton configurations, then targeted runtime and analyzer tests, including bleeding-edge collection usage inference. Review the final diff and affected callers, obtain peer code-review signoff, and commit whole files with the TODO removal in the completed helper work.
48 changes: 48 additions & 0 deletions docs/plans/2026-11-24-routing-methods-and-listener-ports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Route matching across cached routes, runtime routes and listeners

## Matching contract

A cached route collection and routes registered after loading the cache serve one HTTP endpoint. If an actual route accepts the request, dispatch it. Otherwise a 405 advertises every method accepted for that host, scheme, listener and path, once each. An automatic OPTIONS response uses the same set. If nothing matches on any method, return the framework's normal 404.

Before this fix, with cached GET and runtime POST on `/users`, DELETE advertised only POST. Reversing registration advertised only GET and HEAD. Both routes dispatch successfully. Laravel's compiled collection delegates the entire miss to the runtime collection too. Hypervel can correct the response within the existing matcher and exception APIs.

## Listener matching and link generation

`Route::port()` selects the listener that received the request. RequestBridge already copies Swoole's server port into `SERVER_PORT`. Read that value for route selection in both matchers. Keep `Request::getPort()` as the effective public URL port, including trusted proxy handling. A request to the public HTTPS origin can arrive on listener 8000. Changing its Host header must not select a different listener.

Keep port constraints on routes and groups. RouteCollection keys registrations by method, domain and URI, so overlapping registrations with that same key still require the same port. Explain the storage restriction in both registration errors. Document listener matching beside domain routing, with a group example and how another matching route can handle a request on a different listener.

Preserve public URLs for links generated behind a proxy. Previously a request for `https://example.test` on listener 8000 generated `https://example.test:8000` for a route on that listener. An absolute signature computed from that URL fails verification at the public origin. Use the normal public origin for all generated links, including named domains, signed URLs and console requests derived from `app.url`. Remove route-port injection and restore Laravel's request-based default-port handling. A server-side listener cannot identify the public port or host a proxy publishes. For cross-listener links on separate public origins, map the route with the existing route-aware `URL::formatHostUsing()` hook before signing. This also handles directly exposed ports. Cover explicit origin paths and relative URLs through the existing formatting paths.

## Compiled route precedence

A post-match port check is too late. For example, a cached GET restricted to another listener can hide a later GET wildcard that would serve the request. Recovering the next eligible route after the match would require rescanning cached routes. Select the listener’s table before matching so Symfony resolves precedence, captures and allowed methods in one pass.

- At construction, identify the ports actually declared in cached route metadata. For port-scoped collections, prepare the table for each declared port and a shared table for all other listeners. Share unchanged arrays, compiled regexes and condition callbacks. Only filter groups containing excluded routes. Never store a table for an arbitrary incoming port.
- Filter candidates by route name in static path groups and dynamic groups. Keep dynamic MARK keys, even if a group is empty, and preserve Symfony's end-of-regexp sentinel rows. The native matcher still decides order, captures, fallbacks, conditions, schemes, 404 and allowed verbs. Keep the serialized cache format usable without regeneration.
- Preserve direct matching of eligible static paths and the existing optimization for a known static miss. Select tables once per request. The no-port case needs no listener read. Bind the selected cached route from the compiled result, including custom Route binding behavior.
- Remove the obsolete post-match wrong-port retry. For a cached fallback, try only an actual runtime match for the requested method. Only a concrete runtime route can displace the cached fallback.

## Allowed methods and misses

On Symfony's method rejection, use its already validated method list. A runtime route may still accept the requested method. Match that method once using the existing route validators and bind only the winner. If there is no winner, combine the compiled verbs and the runtime collection's alternate verbs and delegate to `getRouteForMethods()`. Its existing implementation owns automatic OPTIONS and the 405 exception. The existing response builder takes the merged list.

```php
$methods = array_values(array_unique([...$compiledMethods, ...$runtimeMethods]));

return $this->getRouteForMethods($request, $methods);
```

Preserve GET/HEAD, explicit OPTIONS and explicitly registered custom verbs. The plain collection must discover custom verbs on wrong-method requests as well. Check the registered method groups once and preserve the established ordering for standard verbs. Keep the existing protected matching APIs usable by subclasses.

When Symfony reports no matching resource, delegate directly to the runtime collection if one exists. Its 404 or 405 is final. Scanning the full cached collection again needlessly resolves route objects on ordinary 404 traffic. Likewise, scanning combined cached and runtime buckets on a mixed 405 both materializes unrelated routes and can hide a cached route with the same method and URI but a different parameter constraint. No worker-level request-result cache or new configuration is needed.

## Verification and commits

Use the existing routing tests to assert observable routes, bound parameters, headers, signatures and exception statuses.

- Exercise cached GET plus runtime POST and the reverse on DELETE and automatic OPTIONS. Check the complete Allow set, implicit HEAD, duplicate methods, explicit handlers, different parameter constraints and a custom verb in plain and mixed matching.
- Cover a port-restricted literal and parameterized route before a broader cached route. Check the selected name and captures on both listeners, wrong-port alternate methods, an explicit OPTIONS restricted to another listener, and a true 404. Exercise a Host/public-port mismatch with cached and uncached routes.
- Check proxied absolute and signed links at the public origin, named domains, and explicit cross-listener origin mappings. Retain explicit public-origin path coverage. Exercise the existing route-cache round trip and the routing fallback tests. Trace performance-sensitive paths without asserting private counters or timing thresholds.
- Run each changed test file immediately. At the final checkpoint run CS Fixer, PHPStan and the affected tests sequentially, then trace callers and review the full diff before peer code review.
- Record each independently verified defect in its own whole-file commit with a body. Keep listener-port behavior and its coverage in a dedicated commit. Remove the completed 405 item from `docs/todo.md` with the 405 fix.
Loading