Skip to content

Commit eefd04d

Browse files
authored
Merge branch 'master' into master
2 parents ca5ec9f + 9516e5b commit eefd04d

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

src/Config/Parser/MetadataParser/MetadataParser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ private static function processFile(SplFileInfo $file, ContainerBuilder $contain
134134
}
135135

136136
return $preProcess ? self::$map->toArray() : $gqlTypes;
137+
} catch (ReflectionException $e) {
138+
return $gqlTypes;
137139
} catch (\InvalidArgumentException $e) {
138140
throw new InvalidArgumentException(sprintf('Failed to parse GraphQL metadata from file "%s".', $file), $e->getCode(), $e);
139141
}

tests/Config/Parser/MetadataParserTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,30 @@ public function testInvalidProviderMutationOnQuery(): void
615615
$this->assertMatchesRegularExpression('/try to add a mutation on type "RootQuery2"/', $e->getPrevious()->getMessage());
616616
}
617617
}
618+
619+
public function testInvalidPhpFiles(): void
620+
{
621+
$files = [
622+
__DIR__.'/fixtures/annotations/Invalid/HasNoClass.php',
623+
__DIR__.'/fixtures/annotations/Invalid/EmptyPhpFile.php',
624+
__DIR__.'/fixtures/annotations/Invalid/NotAPhpFile',
625+
__DIR__.'/fixtures/annotations/Type/RootQuery.php',
626+
];
627+
$this->parser('reset', $this->parserConfig);
628+
629+
foreach ($files as $file) {
630+
$this->parser('preParse', new SplFileInfo($file), $this->containerBuilder, $this->parserConfig);
631+
}
632+
633+
$config = [];
634+
foreach ($files as $file) {
635+
$config += self::cleanConfig($this->parser('parse', new SplFileInfo($file), $this->containerBuilder, $this->parserConfig));
636+
}
637+
638+
$this->assertSame([
639+
'RootQuery' => [
640+
'type' => 'object',
641+
],
642+
], $config);
643+
}
618644
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return function (): void {};

tests/Config/Parser/fixtures/annotations/Invalid/NotAPhpFile

Whitespace-only changes.

0 commit comments

Comments
 (0)