Skip to content

Conversation

@farmerstevieb
Copy link
Contributor

Issue

In v2.0.96, Router::callHandler() has a strict type hint requiring array $inlineValues, but the $params property is never initialized, defaulting to null.

This causes a fatal TypeError when handling routes without URL parameters:

Tina4\Router::callHandler(): Argument #3 ($inlineValues) must be of type array, null given

Affected Routes

All routes without URL parameters fail:

  • GET /
  • GET /login
  • GET /dashboard
  • etc.

Root Cause

File: Tina4/Routing/Router.php:27

private $params;  // Defaults to null

Later called with strict type checking:

// Line 568
$result = $this->callHandler($route["class"], $route["function"], $inlineValues, $request, $response);

// Line 622
public function callHandler(?string $class, $function, array $inlineValues, ...) // Requires array!

Solution

Initialize $params as an empty array:

private $params = [];

Testing

Tested with:

  • ✅ Routes without parameters (GET /)
  • ✅ Routes with parameters (GET /users/{id})
  • ✅ POST routes
  • ✅ Routes with middleware

All working as expected after fix.

Version Context

  • v2.0.88: Used call_user_func_array() (no type checking)
  • v2.0.96: Introduced reflection-based callHandler() (strict types)

This is a regression introduced in v2.0.96.

Backward Compatibility

✅ This fix is 100% backward compatible. Empty array is valid for all use cases where null was previously used.

Fixes TypeError when callHandler receives null for routes without URL parameters.

The Router::callHandler() method introduced in v2.0.96 has a strict type hint
requiring array $inlineValues, but the $params property was never initialized,
causing it to default to null.

This causes a fatal TypeError when handling routes that don't have URL
parameters (e.g., GET /, GET /login).

Solution: Initialize $params as an empty array on declaration.

Based on: Tina4PHP v2.0.96
@andrevanzuydam andrevanzuydam merged commit c6472c1 into tina4stack:master Jan 14, 2026
1 check passed
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.

2 participants