bramus / bramus/router

Unable to Call to Controller Method with Uncaught TypeError: stripos()

Open
#222 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.1k
Forks
236
PR merge metrics
No merged PRs in 30d

Description

I would like to call to the `loadDashboard()` method in `\App\Http\Controllers\DashboardController` class but failed. The program are somethings like:
```php
use Common\DatabaseConnection;
use Bramus\Router\Router;
use Opis\Database\Database;
use App\Http\Controllers\DashboardController;

$router = new Router();
$router->get('/', [DashboardController::class, 'loadDashboard']);
$router->run();
```

## Error Message
```php
Fatal error: Uncaught TypeError: stripos(): Argument #1 ($haystack) must be of type string, array given in
C:\xampp\htdocs\EVS\vendor\bramus\router\src\Bramus\Router\Router.php:462 Stack trace: #0
C:\xampp\htdocs\EVS\vendor\bramus\router\src\Bramus\Router\Router.php(462): stripos(Array, '@') #1
C:\xampp\htdocs\EVS\vendor\bramus\router\src\Bramus\Router\Router.php(440): Bramus\Router\Router->invoke(Array, Array) #2
C:\xampp\htdocs\EVS\vendor\bramus\router\src\Bramus\Router\Router.php(287): Bramus\Router\Router->handle(Array, true) #3
C:\xampp\htdocs\EVS\router.php(251): Bramus\Router\Router->run() #4
{main} thrown in C:\xampp\htdocs\EVS\vendor\bramus\router\src\Bramus\Router\Router.php on line 462
```

Please help to resolve the issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the callable passed to Router::get() in router.php and trace Router.php through run(), handle(), and invoke(), especially line 462 where stripos() receives the array. Reproduce the reported controller route and determine whether the array callable is supported; done means the route invokes loadDashboard() without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.