Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c762735

Browse files
committed
Favor LogicException for missing classes & functions
1 parent 31f8cb9 commit c762735

File tree

21 files changed

+47
-26
lines changed

21 files changed

+47
-26
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function getMaxRedirects()
118118
public function insulate($insulated = true)
119119
{
120120
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) {
121-
throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.');
121+
throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.');
122122
}
123123

124124
$this->insulated = (bool) $insulated;

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private function __construct()
4747
public static function parse($content, $schemaOrCallable = null)
4848
{
4949
if (!\extension_loaded('dom')) {
50-
throw new \RuntimeException('Extension DOM is required.');
50+
throw new \LogicException('Extension DOM is required.');
5151
}
5252

5353
$internalErrors = libxml_use_internal_errors(true);

src/Symfony/Component/Console/Command/LockableTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Command;
1313

1414
use Symfony\Component\Console\Exception\LogicException;
15-
use Symfony\Component\Console\Exception\RuntimeException;
1615
use Symfony\Component\Lock\Factory;
1716
use Symfony\Component\Lock\Lock;
1817
use Symfony\Component\Lock\Store\FlockStore;
@@ -36,7 +35,7 @@ trait LockableTrait
3635
private function lock($name = null, $blocking = false)
3736
{
3837
if (!class_exists(SemaphoreStore::class)) {
39-
throw new RuntimeException('To enable the locking feature you must install the symfony/lock component.');
38+
throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
4039
}
4140

4241
if (null !== $this->lock) {

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Definition;
17+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1718
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1819
use Symfony\Component\DependencyInjection\ExpressionLanguage;
1920
use Symfony\Component\DependencyInjection\Reference;
@@ -197,7 +198,7 @@ private function getExpressionLanguage()
197198
{
198199
if (null === $this->expressionLanguage) {
199200
if (!class_exists(ExpressionLanguage::class)) {
200-
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
201+
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
201202
}
202203

203204
$providers = $this->container->getExpressionLanguageProviders();

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ private function getExpressionLanguage()
15871587
{
15881588
if (null === $this->expressionLanguage) {
15891589
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
1590-
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
1590+
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
15911591
}
15921592
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);
15931593
}

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ private function getExpressionLanguage()
16921692
{
16931693
if (null === $this->expressionLanguage) {
16941694
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
1695-
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
1695+
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
16961696
}
16971697
$providers = $this->container->getExpressionLanguageProviders();
16981698
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {

src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
2020
use Symfony\Component\DependencyInjection\ContainerInterface;
2121
use Symfony\Component\DependencyInjection\Definition;
22+
use Symfony\Component\DependencyInjection\Exception\LogicException;
2223
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2324
use Symfony\Component\DependencyInjection\Parameter;
2425
use Symfony\Component\DependencyInjection\Reference;
@@ -45,7 +46,7 @@ class YamlDumper extends Dumper
4546
public function dump(array $options = array())
4647
{
4748
if (!class_exists('Symfony\Component\Yaml\Dumper')) {
48-
throw new RuntimeException('Unable to dump the container as the Symfony Yaml Component is not installed.');
49+
throw new LogicException('Unable to dump the container as the Symfony Yaml Component is not installed.');
4950
}
5051

5152
if (null === $this->dumper) {

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Config\Util\XmlUtils;
1515
use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
16+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1617
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1718

1819
/**
@@ -180,7 +181,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)
180181
private static function phpize($value)
181182
{
182183
if (!class_exists(XmlUtils::class)) {
183-
throw new RuntimeException('The Symfony Config component is required to cast env vars to "bool", "int" or "float".');
184+
throw new LogicException('The Symfony Config component is required to cast env vars to "bool", "int" or "float".');
184185
}
185186

186187
return XmlUtils::phpize($value);

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ private function createSubCrawler($nodes)
11661166
private function createCssSelectorConverter(): CssSelectorConverter
11671167
{
11681168
if (!\class_exists(CssSelectorConverter::class)) {
1169-
throw new \RuntimeException('To filter with a CSS selector, install the CssSelector component ("composer require symfony/css-selector"). Or use filterXpath instead.');
1169+
throw new \LogicException('To filter with a CSS selector, install the CssSelector component ("composer require symfony/css-selector"). Or use filterXpath instead.');
11701170
}
11711171

11721172
return new CssSelectorConverter($this->isHtml);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Exception;
13+
14+
/**
15+
* @author Roland Franssen <[email protected]>
16+
*/
17+
class LogicException extends \LogicException implements ExceptionInterface
18+
{
19+
}

src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Messenger\Envelope;
1515
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
16-
use Symfony\Component\Messenger\Exception\RuntimeException;
16+
use Symfony\Component\Messenger\Exception\LogicException;
1717
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1818
use Symfony\Component\Serializer\Encoder\XmlEncoder;
1919
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
@@ -39,7 +39,7 @@ public function __construct(SymfonySerializerInterface $serializer, string $form
3939
public static function create(): self
4040
{
4141
if (!class_exists(SymfonySerializer::class)) {
42-
throw new RuntimeException(sprintf('The default Messenger Serializer requires Symfony\'s Serializer component. Try running "composer require symfony/serializer".'));
42+
throw new LogicException(sprintf('The default Messenger Serializer requires Symfony\'s Serializer component. Try running "composer require symfony/serializer".'));
4343
}
4444

4545
$encoders = array(new XmlEncoder(), new JsonEncoder());

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Process implements \IteratorAggregate
140140
public function __construct($command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
141141
{
142142
if (!\function_exists('proc_open')) {
143-
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
143+
throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
144144
}
145145

146146
if (!\is_array($command)) {

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ private function getPropertyPath($propertyPath): PropertyPath
788788
public static function createCache($namespace, $defaultLifetime, $version, LoggerInterface $logger = null)
789789
{
790790
if (!class_exists('Symfony\Component\Cache\Adapter\ApcuAdapter')) {
791-
throw new \RuntimeException(sprintf('The Symfony Cache component must be installed to use %s().', __METHOD__));
791+
throw new \LogicException(sprintf('The Symfony Cache component must be installed to use %s().', __METHOD__));
792792
}
793793

794794
if (!ApcuAdapter::isSupported()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
5454
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
5555
{
5656
if (!class_exists(DocBlockFactory::class)) {
57-
throw new \RuntimeException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed.', __CLASS__));
57+
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed.', __CLASS__));
5858
}
5959

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

src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AnnotationFileLoader extends FileLoader
3232
public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader)
3333
{
3434
if (!\function_exists('token_get_all')) {
35-
throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.');
35+
throw new \LogicException('The Tokenizer extension is required for the routing annotation loaders.');
3636
}
3737

3838
parent::__construct($locator);

src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ private function getExpressionLanguage()
724724
{
725725
if (null === $this->expressionLanguage) {
726726
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
727-
throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
727+
throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
728728
}
729729
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);
730730
}

src/Symfony/Component/Routing/Matcher/UrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ protected function getExpressionLanguage()
246246
{
247247
if (null === $this->expressionLanguage) {
248248
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
249-
throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
249+
throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
250250
}
251251
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);
252252
}

src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\PropertyAccess\PropertyAccess;
1616
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1717
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
18-
use Symfony\Component\Serializer\Exception\RuntimeException;
18+
use Symfony\Component\Serializer\Exception\LogicException;
1919
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
2020
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface;
2121
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
@@ -33,7 +33,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer
3333
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null, ClassDiscriminatorResolverInterface $classDiscriminatorResolver = null)
3434
{
3535
if (!\class_exists(PropertyAccess::class)) {
36-
throw new RuntimeException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
36+
throw new LogicException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
3737
}
3838

3939
parent::__construct($classMetadataFactory, $nameConverter, $propertyTypeExtractor, $classDiscriminatorResolver);

src/Symfony/Component/Validator/Constraints/EmailValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
1616
use Symfony\Component\Validator\Constraint;
1717
use Symfony\Component\Validator\ConstraintValidator;
18-
use Symfony\Component\Validator\Exception\RuntimeException;
18+
use Symfony\Component\Validator\Exception\LogicException;
1919
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
2020

2121
/**
@@ -100,7 +100,7 @@ public function validate($value, Constraint $constraint)
100100

101101
if (Email::VALIDATION_MODE_STRICT === $constraint->mode) {
102102
if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
103-
throw new RuntimeException('Strict email validation requires egulias/email-validator ~1.2|~2.0');
103+
throw new LogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0');
104104
}
105105

106106
$strictValidator = new \Egulias\EmailValidator\EmailValidator();

src/Symfony/Component/Validator/Constraints/ExpressionValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1515
use Symfony\Component\Validator\Constraint;
1616
use Symfony\Component\Validator\ConstraintValidator;
17-
use Symfony\Component\Validator\Exception\RuntimeException;
17+
use Symfony\Component\Validator\Exception\LogicException;
1818
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1919

2020
/**
@@ -55,7 +55,7 @@ private function getExpressionLanguage()
5555
{
5656
if (null === $this->expressionLanguage) {
5757
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
58-
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
58+
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
5959
}
6060
$this->expressionLanguage = new ExpressionLanguage();
6161
}

src/Symfony/Component/Validator/Constraints/ImageValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
16-
use Symfony\Component\Validator\Exception\RuntimeException;
16+
use Symfony\Component\Validator\Exception\LogicException;
1717
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1818

1919
/**
@@ -218,7 +218,7 @@ public function validate($value, Constraint $constraint)
218218

219219
if ($constraint->detectCorrupted) {
220220
if (!\function_exists('imagecreatefromstring')) {
221-
throw new RuntimeException('Corrupted images detection requires installed and enabled GD extension');
221+
throw new LogicException('Corrupted images detection requires installed and enabled GD extension');
222222
}
223223

224224
$resource = @imagecreatefromstring(file_get_contents($value));

0 commit comments

Comments
 (0)