Skip to content

Commit 2f7cf98

Browse files
committed
fail with a meaningful error when a needed package is missing
1 parent b8c7604 commit 2f7cf98

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
6060
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
6161
{
6262
if (!class_exists(DocBlockFactory::class)) {
63-
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed.', __CLASS__));
63+
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', __CLASS__));
6464
}
6565

6666
$this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance();

src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Extractor;
1313

14+
use phpDocumentor\Reflection\Types\ContextFactory;
1415
use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode;
1516
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
1617
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
@@ -59,6 +60,10 @@ final class PhpStanExtractor implements PropertyTypeExtractorInterface, Construc
5960
*/
6061
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
6162
{
63+
if (!class_exists(ContextFactory::class)) {
64+
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/type-resolver" package is not installed. Try running composer require "phpdocumentor/type-resolver".', __CLASS__));
65+
}
66+
6267
$this->phpStanTypeHelper = new PhpStanTypeHelper();
6368
$this->mutatorPrefixes = $mutatorPrefixes ?? ReflectionExtractor::$defaultMutatorPrefixes;
6469
$this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;

0 commit comments

Comments
 (0)