Merge pull request #44 from mr-feek/fix-tests

Fix tests
This commit is contained in:
Matthew Brown 2020-04-18 17:56:03 -04:00 committed by GitHub
commit 8552baf29f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -48,6 +48,8 @@ class Plugin implements PluginEntryPointInterface
$registration->registerHooksFromClass(ReturnTypeProvider\RedirectReturnTypeProvider::class);
require_once 'ReturnTypeProvider/ViewReturnTypeProvider.php';
$registration->registerHooksFromClass(ReturnTypeProvider\ViewReturnTypeProvider::class);
require_once 'ReturnTypeProvider/AppReturnTypeProvider.php';
$registration->registerHooksFromClass(ReturnTypeProvider\AppReturnTypeProvider::class);
require_once 'AppInterfaceProvider.php';
$registration->registerHooksFromClass(AppInterfaceProvider::class);
require_once 'PropertyProvider/ModelPropertyProvider.php';

View File

@ -6,6 +6,7 @@ use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
use Psalm\StatementsSource;
use Psalm\Type;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Union;
@ -32,8 +33,15 @@ final class AppReturnTypeProvider implements FunctionReturnTypeProviderInterface
}
// @todo: this should really proxy to \Illuminate\Foundation\Application::make, but i was struggling with that
return new Union([
new TNamedObject($call_args[0]->value),
]);
$firstArgType = $statements_source->getNodeTypeProvider()->getType($call_args[0]->value);
if ($firstArgType && $firstArgType->isSingleStringLiteral()) {
return new Union([
new TNamedObject($firstArgType->getSingleStringLiteral()->value),
]);
}
return Type::getMixed();
}
}

View File

@ -54,9 +54,6 @@ Feature: Container
"""
<?php
class Foo {
public function resolveHelperGetContainer(): \Illuminate\Contracts\Foundation\Application {
return resolve();
}
public function resolveHelperResolvesTypes(): \Illuminate\Routing\Redirector
{