Skip to content
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: 4 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.0"

dependencies:
- "highest"
Expand All @@ -40,6 +41,9 @@ jobs:
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install composer v1"
run: "composer selfupdate --1"

- name: "Install dependencies with composer"
run: "composer install --no-interaction"

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"psr/http-factory": "^1"
},
"require-dev": {
"phpunit/phpunit": "^8.2.4",
"phpunit/phpunit": "^8.2.4||^9.4",
"php-coveralls/php-coveralls": "^2.1",
"mouf/picotainer": "^1.1",
"phpstan/phpstan": "^0.12.25",
Expand Down
7 changes: 6 additions & 1 deletion src/Mappers/RecursiveTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use TheCodingMachine\GraphQLite\Types\MutableObjectType;
use TheCodingMachine\GraphQLite\Types\ObjectFromInterfaceType;
use TheCodingMachine\GraphQLite\Types\ResolvableMutableInputInterface;
use TypeError;
use Webmozart\Assert\Assert;
use function array_flip;
use function array_reverse;
Expand Down Expand Up @@ -175,7 +176,11 @@ public function findClosestMatchingParent(string $className): ?string
if ($this->typeMapper->canMapClassToType($className)) {
return $className;
}
$className = get_parent_class($className);
try {
$className = get_parent_class($className);
} catch (TypeError $exception) {
return null;
}
} while ($className);

return null;
Expand Down
18 changes: 16 additions & 2 deletions tests/Mappers/CannotMapTypeTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

class CannotMapTypeTraitTest extends AbstractQueryProviderTest
{

public function testAddParamInfo()
/**
* @requires PHP <= 7.4
*/
public function testAddParamInfoInfphp80()
{
$e = CannotMapTypeException::createForType('Foo');
$e->addParamInfo((new ReflectionClass('DateTime'))->getMethod('__construct')->getParameters()[0]);
Expand All @@ -19,6 +21,18 @@ public function testAddParamInfo()
$this->assertSame('For parameter $time, in DateTime::__construct, cannot map class "Foo" to a known GraphQL type. Check your TypeMapper configuration.', $e->getMessage());
}

/**
* @requires PHP >= 8.0
*/
public function testAddParamInfoSupphp74()
{
$e = CannotMapTypeException::createForType('Foo');
$e->addParamInfo((new ReflectionClass('DateTime'))->getMethod('__construct')->getParameters()[0]);
$e->addParamInfo((new ReflectionClass('DateTime'))->getMethod('__construct')->getParameters()[0]);

$this->assertSame('For parameter $datetime, in DateTime::__construct, cannot map class "Foo" to a known GraphQL type. Check your TypeMapper configuration.', $e->getMessage());
}

public function testAddSourceFieldInfo()
{
$class = new ReflectionClass(TestTypeId::class);
Expand Down