diff --git a/.travis.yml b/.travis.yml index 6a6f97d72..51ad41bee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,14 +24,23 @@ matrix: - COMPOSER_FLAGS="--ignore-platform-reqs" before_install: - - composer self-update --2 + - | + composer self-update --2 + if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then + composer require --dev --no-update "phpunit/phpunit:^9.3.2" + fi install: - if [[ $DEPS == 'latest' ]]; then travis_retry composer update --no-interaction $COMPOSER_FLAGS ; fi - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable --no-interaction $COMPOSER_FLAGS ; fi script: - - ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite"; +- | + if [[ $TRAVIS_PHP_VERSION == 'nightly' ]]; then + ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite PHP8"; + else + ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite PHP7"; + fi after_success: - composer require satooshi/php-coveralls diff --git a/library/Mockery/Reflector.php b/library/Mockery/Reflector.php index e6ca619a7..fe9fb77da 100644 --- a/library/Mockery/Reflector.php +++ b/library/Mockery/Reflector.php @@ -82,88 +82,6 @@ public static function getReturnType(\ReflectionMethod $method, $withoutNullable return (!$withoutNullable && $type->allowsNull()) ? self::formatNullableType($typeHint) : $typeHint; } - /** - * Compute the legacy type hint. - * - * We return: - * - string: the legacy type hint - * - null: if there is no legacy type hint - * - false: if we must check for PHP 7+ typing - * - * @param \ReflectionParameter $param - * - * @return string|null|false - */ - private static function getLegacyTypeHint(\ReflectionParameter $param) - { - // Handle HHVM typing - if (\method_exists($param, 'getTypehintText')) { - if ($param->isArray()) { - return 'array'; - } - - if ($param->isCallable()) { - return 'callable'; - } - - $typeHint = $param->getTypehintText(); - - // throw away HHVM scalar types - if (\in_array($typeHint, array('int', 'integer', 'float', 'string', 'bool', 'boolean'), true)) { - return null; - } - - return sprintf('\\%s', $typeHint); - } - - // Handle PHP 5 typing - if (\PHP_VERSION_ID < 70000) { - if ($param->isArray()) { - return 'array'; - } - - if ($param->isCallable()) { - return 'callable'; - } - - $typeHint = self::getLegacyClassName($param); - - return $typeHint === null ? null : sprintf('\\%s', $typeHint); - } - - return false; - } - - /** - * Compute the class name using legacy APIs, if possible. - * - * This method MUST only be called on PHP 5. - * - * @param \ReflectionParameter $param - * - * @return string|null - */ - private static function getLegacyClassName(\ReflectionParameter $param) - { - try { - $class = $param->getClass(); - - $typeHint = $class === null ? null : $class->getName(); - } catch (\ReflectionException $e) { - $typeHint = null; - } - - if ($typeHint === null) { - if (preg_match('/^Parameter #[0-9]+ \[ \<(required|optional)\> (?\S+ )?.*\$' . $param->getName() . ' .*\]$/', (string) $param, $typehintMatch)) { - if (!empty($typehintMatch['typehint']) && $typehintMatch['typehint']) { - $typeHint = $typehintMatch['typehint']; - } - } - } - - return $typeHint; - } - /** * Get the string representation of the given type. * diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bbcfc3e3e..084d449c5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,6 +11,7 @@ ./tests + ./tests/PHP80