1. Go to this page and download the library: Download symplify/phpstan-extensions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
symplify / phpstan-extensions example snippets
use Symfony\Component\DependencyInjection\Container;
/** @var Container $container */
// PHPStan: object ❌
$container->get(Type::class);
// Reality: Type ✅
$container->get(Type::class);
// same for in-controller/container-aware context
$this->get(Type::class);
use Symfony\Component\HttpKernel\Kernel;
final class AppKernel extends Kernel
{
// ...
}
$kernel = new AppKernel('prod', false);
$kernel->boot();
// PHPStan: null|ContainerInterface ❌
$kernel->getContainer();
// Reality: ContainerInterface ✅
$kernel->getContainer();
// Reality: ContainerInterface ✅
use Symfony\Component\Finder\Finder;
$finder = new Finder();
foreach ($finder as $fileInfo) {
// PHPStan: false|string ❌
$fileInfo->getRealPath();
// Reality: string ✅
$fileInfo->getRealPath();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.