Skip to content

Simplify FQCN when using class_exists #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Config/Parser/AnnotationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ private static function typeAnnotationToGQLConfiguration(
private static function getAnnotationReader(): AnnotationReader
{
if (null === self::$annotationReader) {
if (!class_exists('\\Doctrine\\Common\\Annotations\\AnnotationReader') ||
!class_exists('\\Doctrine\\Common\\Annotations\\AnnotationRegistry')) {
if (!class_exists(AnnotationReader::class) ||
!class_exists(AnnotationRegistry::class)) {
throw new RuntimeException('In order to use graphql annotation, you need to require doctrine annotations');
}

Expand Down
3 changes: 2 additions & 1 deletion src/DependencyInjection/OverblogGraphQLExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Validator\Validation;
use function array_fill_keys;
use function class_exists;
use function realpath;
Expand Down Expand Up @@ -105,7 +106,7 @@ private function registerForAutoconfiguration(ContainerBuilder $container): void

private function registerValidatorFactory(ContainerBuilder $container): void
{
if (class_exists('Symfony\\Component\\Validator\\Validation')) {
if (class_exists(Validation::class)) {
$container->register(ValidatorFactory::class)
->setArguments([
new Reference('validator.validator_factory'),
Expand Down
3 changes: 2 additions & 1 deletion tests/EventListener/ValidationErrorsListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validation;
use function class_exists;

class ValidationErrorsListenerTest extends TestCase
Expand All @@ -21,7 +22,7 @@ class ValidationErrorsListenerTest extends TestCase

protected function setUp(): void
{
if (!class_exists('Symfony\\Component\\Validator\\Validation')) {
if (!class_exists(Validation::class)) {
$this->markTestSkipped('Symfony validator component is not installed');
}
$this->listener = new ValidationErrorsListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Overblog\GraphQLBundle\Tests\Transformer\InputType1;
use Overblog\GraphQLBundle\Tests\Transformer\InputType2;
use Overblog\GraphQLBundle\Transformer\ArgumentsTransformer;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\RecursiveValidator;
use function class_exists;
use function count;
Expand All @@ -23,7 +24,7 @@ class ArgumentsTest extends TestCase
{
public function setUp(): void
{
if (!class_exists('Symfony\\Component\\Validator\\Validation')) {
if (!class_exists(Validation::class)) {
$this->markTestSkipped('Symfony validator component is not installed');
}
parent::setUp();
Expand Down
3 changes: 2 additions & 1 deletion tests/Functional/Validator/InputValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Overblog\GraphQLBundle\Tests\Functional\Validator;

use Overblog\GraphQLBundle\Tests\Functional\TestCase;
use Symfony\Component\Validator\Validation;
use function class_exists;
use function json_decode;

Expand All @@ -13,7 +14,7 @@ class InputValidatorTest extends TestCase
protected function setUp(): void
{
parent::setUp();
if (!class_exists('Symfony\\Component\\Validator\\Validation')) {
if (!class_exists(Validation::class)) {
$this->markTestSkipped('Symfony validator component is not installed');
}
static::bootKernel(['test_case' => 'validator']);
Expand Down
3 changes: 2 additions & 1 deletion tests/Transformer/ArgumentsTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\RecursiveValidator;
use function class_exists;
use function count;
Expand All @@ -26,7 +27,7 @@ class ArgumentsTransformerTest extends TestCase
protected function setUp(): void
{
parent::setUp();
if (!class_exists('Symfony\\Component\\Validator\\Validation')) {
if (!class_exists(Validation::class)) {
$this->markTestSkipped('Symfony validator component is not installed');
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Validator/InputValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\Validator\ConstraintValidatorFactory;
use Symfony\Component\Validator\Validation;
use function class_exists;

class InputValidatorTest extends TestCase
{
public function setUp(): void
{
parent::setUp();
if (!class_exists('Symfony\\Component\\Validator\\Validation')) {
if (!class_exists(Validation::class)) {
$this->markTestSkipped('Symfony validator component is not installed');
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Validator/Mapping/MetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
use PHPUnit\Framework\TestCase;
use stdClass;
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
use Symfony\Component\Validator\Validation;
use function class_exists;

class MetadataFactoryTest extends TestCase
{
public function setUp(): void
{
if (!class_exists('Symfony\\Component\\Validator\\Validation')) {
if (!class_exists(Validation::class)) {
$this->markTestSkipped('Symfony validator component is not installed');
}
parent::setUp();
Expand Down