-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
PHP Version
8.2
PHPStan CodeIgniter Version
1.5.4
PHPStan Version
2.1.17
What happened?
Property Acme\Main\Controllers\AbstractController::$toasts (Acme\Toasts) does not accept
object.
🪪 assign.propertyType
Minimum Reproduction Script
Added to phpstan.neon.dist:
parameters:
codeigniter:
additionalConfigNamespaces:
- Acme\Main\Config
additionalServices:
- Acme\Main\Config\Services
In controller:
public function __construct()
{
\PHPStan\dumpType(service('toasts')); // Dumped type: object
\PHPStan\dumpType(service('session')); // Dumped type: CodeIgniter\Session\Session
$this->session = service('session');
$this->toasts = service('toasts');
}Acme\Main\Config\Services:
class Services extends BaseService
{
public static function toasts(bool $getShared = true): Toasts
{
if ($getShared) {
return static::getSharedInstance('toasts');
}
return new Toasts();
}
}Expected Output
The correct type must be returned.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working