Được TopGit lập chỉ mục từ metadata GitHub: phpstan/phpstan-symfony có 806 sao, viết chủ yếu bằng PHP. Symfony extension for PHPStan
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
You have to provide a path to srcDevDebugProjectContainer.xml or similar XML file describing your container.
parameters:
symfony:
containerXmlPath: var/cache/dev/srcDevDebugProjectContainer.xml
# or with Symfony 4.2+
containerXmlPath: var/cache/dev/srcApp_KernelDevDebugContainer.xml
# or with Symfony 5+
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
# If you're using PHP config files for Symfony 5.3+, you also need this for auto-loading of `Symfony\Config`:
scanDirectories:
- var/cache/dev/Symfony/Config
# If you're using PHP config files (including the ones under packages/*.php) for Symfony 5.3+,
# you need this to load the helper functions (i.e. service(), env()):
scanFiles:
- vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php
Constant hassers
Sometimes, when you are dealing with optional dependencies, the ::has() methods can cause problems. For example, the following construct would complain that the condition is always either on or off, depending on whether you have the dependency for service installed:
if ($this->has('service')) {
// ...
}
In that case, you can disable the ::has() method return type resolving like this:
parameters:
symfony:
constantHassers: false
Be aware that it may hide genuine errors in your application.
Analysis of Symfony Console Commands
You can opt in for more advanced analysis of Symfony Console Commands
by providing the console application from your own application. This will allow the correct argument and option types to be inferred when accessing $input->getArgument() or $input->getOption().
// tests/console-application.php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
require __DIR__ . '/../config/bootstrap.php';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
return new Application($kernel);
Symfony 5:
// tests/console-application.php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Dotenv\Dotenv;
require __DIR__ . '/../vendor/autoload.php';
(new Dotenv())->bootEnv(__DIR__ . '/../.env');
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
return new Application($kernel);
Single Command Application:
// tests/console-application.php
use App\Application; // where Application extends Symfony\Component\Console\SingleCommandApplication
use Symfony\Component\Console;
require __DIR__ . '/../vendor/autoload.php';
$application = new Console\Application();
$application->add(new Application());
return $application;
You may then encounter an error with PhpParser:
Compile Error: Cannot Declare interface PhpParser\NodeVisitor, because the name is already in use
If this is the case, you should create a new environment for your application that will disable inlining. In config/packages/phpstan_env/parameters.yaml:
$kernel = new \App\Kernel('phpstan_env', (bool) $_SERVER['APP_DEBUG']);
Messenger HandleTrait Wrappers
The extension provides advanced type inference for methods that internally use Symfony Messenger's HandleTrait. This feature is particularly useful for query bus implementations (in CQRS pattern) that use/wrap the HandleTrait::handle() method.
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
// Product handler that returns Product
#[AsMessageHandler]
class GetProductQueryHandler
{
public function __invoke(GetProductQuery $query): Product
{
return $this->productRepository->get($query->productId);
}
}
PHP Examples
use Symfony\Component\Messenger\HandleTrait;
use Symfony\Component\Messenger\MessageBusInterface;
// Basic query bus implementation
class QueryBus
{
use HandleTrait;
public function __construct(MessageBusInterface $messageBus)
{
$this->messageBus = $messageBus;
}
public function dispatch(object $query): mixed
{
return $this->handle($query); // Return type will be inferred in calling code as query result
}
// Multiple methods per class example
public function execute(object $message): mixed
{
return $this->handle($message); // Return type will be inferred in calling code as query result
}
}
// Interface-based configuration example
interface QueryBusInterface
{
public function dispatch(object $query): mixed; // Return type will be inferred in calling code as query result
}
class QueryBusWithInterface implements QueryBusInterface
{
use HandleTrait;
public function __construct(MessageBusInterface $queryBus)
{
$this->messageBus = $queryBus;
}
public function dispatch(object $query): mixed
{
return $this->handle($query);
}
}
// Examples of use with proper type inference
$query = new GetProductQuery($productId);
$queryBus = new QueryBus($messageBus);
$queryBusWithInterface = new QueryBusWithInterface($messageBus);
$product = $queryBus->dispatch($query); // Returns: Product
$product2 = $queryBus->execute($query); // Returns: Product
$product3 = $queryBusWithInterface->dispatch($query); // Returns: Product
// Without the feature all above query bus results would be default 'mixed'.
phpstan/phpstan-symfony thuộc nhóm Backend trên TopGit, cùng 7 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về phpstan/phpstan-symfony ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/phpstan/phpstan-symfony là nguồn chính thức.
phpstan/phpstan-symfony có bao nhiêu sao?
phpstan/phpstan-symfony có 806 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/phpstan/phpstan-symfony. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
phpstan/phpstan-symfony có phải mã nguồn mở không?
Có — phpstan/phpstan-symfony phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/phpstan/phpstan-symfony.
phpstan/phpstan-symfony còn đang phát triển không?
Commit gần nhất trên phpstan/phpstan-symfony là 14 ngày trước (theo timestamp GitHub). Repo có 107 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
phpstan/phpstan-symfony dùng license gì?
phpstan/phpstan-symfony phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
phpstan/phpstan-symfony là gì?
phpstan/phpstan-symfony (phpstan/phpstan-symfony) là dự án PHP trên GitHub. Theo mô tả gốc: Symfony extension for PHPStan
phpstan/phpstan-symfony viết bằng ngôn ngữ gì?
phpstan/phpstan-symfony chủ yếu viết bằng PHP. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
phpstan-symfony có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về phpstan-symfony.