Skip to content

Commit

Permalink
Merge pull request thecodingmachine#147 from moufmouf/php7.4-testing
Browse files Browse the repository at this point in the history
Adding Travis tests on PHP 7.4
  • Loading branch information
moufmouf committed Oct 14, 2019
2 parents a5d2497 + 388e901 commit c04dfef
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ jobs:
- composer phpstan
after_script:
- ./vendor/bin/coveralls -v
- stage: test
php: 7.4snapshot
env: PREFER_LOWEST=""
before_script:
- *composerupdate
script:
- *phpunit
- stage: test
php: 7.2
env: PREFER_LOWEST=""
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"symfony/lock": "^3 || ^4"
},
"require-dev": {
"phpunit/phpunit": "^6.1",
"phpunit/phpunit": "^7.5.16",
"satooshi/php-coveralls": "^1.0",
"symfony/cache": "^4.1.4",
"mouf/picotainer": "^1.1",
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
bootstrap="tests/Bootstrap.php"
>
<testsuites>
<testsuite name="GraphQLite Test Suite">
<directory>./tests/</directory>
<exclude>./tests/dependencies/</exclude>
<exclude>./tests/Bootstrap.php</exclude>
</testsuite>
</testsuites>

Expand All @@ -24,7 +24,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
9 changes: 6 additions & 3 deletions src/FieldsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ private function mapReturnType(ReflectionMethod $refMethod, DocBlock $docBlockOb
$returnType = $refMethod->getReturnType();
if ($returnType !== null) {
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$phpdocType = $typeResolver->resolve((string) $returnType);
$phpdocType = $typeResolver->resolve(
$returnType->getName()
);
$phpdocType = $this->resolveSelf($phpdocType, $refMethod->getDeclaringClass());
} else {
$phpdocType = new Mixed_();
Expand Down Expand Up @@ -490,10 +492,11 @@ private function mapParameters(array $refParameters, DocBlock $docBlock): array
$parameterType = $parameter->getType();
$allowsNull = $parameterType === null ? true : $parameterType->allowsNull();

$type = (string) $parameterType;
if ($type === '') {
if ($parameterType === null) {
throw MissingTypeHintException::missingTypeHint($parameter);
}

$type = $parameterType->getName();
$phpdocType = $typeResolver->resolve($type);
$phpdocType = $this->resolveSelf($phpdocType, $parameter->getDeclaringClass());

Expand Down
2 changes: 1 addition & 1 deletion src/InputTypeUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private function validateReturnType(ReflectionMethod $refMethod): Fqsen
throw MissingTypeHintException::nullableReturnType($refMethod);
}

$type = (string) $returnType;
$type = $returnType->getName();

$typeResolver = new \phpDocumentor\Reflection\TypeResolver();

Expand Down
2 changes: 1 addition & 1 deletion src/MissingTypeHintException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function missingReturnType(ReflectionMethod $method): self

public static function invalidReturnType(ReflectionMethod $method): self
{
return new self(sprintf('The return type of factory "%s::%s" must be an object, "%s" passed instead.', $method->getDeclaringClass()->getName(), $method->getName(), $method->getReturnType()));
return new self(sprintf('The return type of factory "%s::%s" must be an object, "%s" passed instead.', $method->getDeclaringClass()->getName(), $method->getName(), $method->getReturnType() ? $method->getReturnType()->getName() : 'mixed'));
}

public static function nullableReturnType(ReflectionMethod $method): self
Expand Down
9 changes: 9 additions & 0 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Doctrine\Common\Annotations\AnnotationRegistry;

$autoloader = require_once __DIR__ . '/../vendor/autoload.php';

AnnotationRegistry::registerLoader('class_exists');

return $autoloader;

0 comments on commit c04dfef

Please sign in to comment.