mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2025-01-23 05:41:11 +01:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
d43d48f8c7
@ -35,7 +35,6 @@ class AppInterfaceProvider implements
|
|||||||
) : ?bool {
|
) : ?bool {
|
||||||
if ($method_name_lowercase === 'offsetget'
|
if ($method_name_lowercase === 'offsetget'
|
||||||
|| $method_name_lowercase === 'offsetset'
|
|| $method_name_lowercase === 'offsetset'
|
||||||
|| $method_name_lowercase === '__call'
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -55,7 +54,6 @@ class AppInterfaceProvider implements
|
|||||||
) : ?bool {
|
) : ?bool {
|
||||||
if ($method_name_lowercase === 'offsetget'
|
if ($method_name_lowercase === 'offsetget'
|
||||||
|| $method_name_lowercase === 'offsetset'
|
|| $method_name_lowercase === 'offsetset'
|
||||||
|| $method_name_lowercase === '__call'
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,18 @@ class Plugin implements PluginEntryPointInterface
|
|||||||
|
|
||||||
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null) : void
|
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null) : void
|
||||||
{
|
{
|
||||||
$app = ApplicationHelper::bootApp();
|
try {
|
||||||
|
$app = ApplicationHelper::bootApp();
|
||||||
|
$fake_filesystem = new FakeFilesystem();
|
||||||
|
$view_factory = $this->getViewFactory($app, $fake_filesystem);
|
||||||
|
$cache_dir = __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
$fake_filesystem = new FakeFilesystem();
|
$this->ingestFacadeStubs($registration, $app, $fake_filesystem, $view_factory, $cache_dir);
|
||||||
|
$this->ingestMetaStubs($registration, $app, $fake_filesystem, $view_factory, $cache_dir);
|
||||||
$view_factory = $this->getViewFactory($app, $fake_filesystem);
|
$this->ingestModelStubs($registration, $app, $fake_filesystem, $cache_dir);
|
||||||
|
} catch (\Throwable $t) {
|
||||||
$cache_dir = __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
|
return;
|
||||||
|
}
|
||||||
$this->ingestFacadeStubs($registration, $app, $fake_filesystem, $view_factory, $cache_dir);
|
|
||||||
$this->ingestMetaStubs($registration, $app, $fake_filesystem, $view_factory, $cache_dir);
|
|
||||||
$this->ingestModelStubs($registration, $app, $fake_filesystem, $cache_dir);
|
|
||||||
|
|
||||||
require_once 'ReturnTypeProvider/AuthReturnTypeProvider.php';
|
require_once 'ReturnTypeProvider/AuthReturnTypeProvider.php';
|
||||||
$registration->registerHooksFromClass(ReturnTypeProvider\AuthReturnTypeProvider::class);
|
$registration->registerHooksFromClass(ReturnTypeProvider\AuthReturnTypeProvider::class);
|
||||||
|
26
src/Stubs/Container.stubphp
Normal file
26
src/Stubs/Container.stubphp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Illuminate\Contracts\Container;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
interface Container extends ContainerInterface, \ArrayAccess
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param mixed $offset
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 5.0.0
|
||||||
|
*/
|
||||||
|
public function offsetGet($offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $offset The offset to assign the value to.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 5.0.0
|
||||||
|
*/
|
||||||
|
public function offsetSet($offset, $value);
|
||||||
|
}
|
@ -146,6 +146,6 @@ Feature: collection types
|
|||||||
| InvalidReturnType | The declared return type 'bool' for CollectionTypes::failingTest is incorrect, got 'null\|string' |
|
| InvalidReturnType | The declared return type 'bool' for CollectionTypes::failingTest is incorrect, got 'null\|string' |
|
||||||
| NullableReturnStatement | The declared return type 'bool' for CollectionTypes::failingTest is not nullable, but the function returns 'null\|string' |
|
| NullableReturnStatement | The declared return type 'bool' for CollectionTypes::failingTest is not nullable, but the function returns 'null\|string' |
|
||||||
| InvalidReturnStatement | The inferred type 'null\|string' does not match the declared return type 'bool' for CollectionTypes::failingTest |
|
| InvalidReturnStatement | The inferred type 'null\|string' does not match the declared return type 'bool' for CollectionTypes::failingTest |
|
||||||
| InvalidScalarArgument | Argument 2 of Illuminate\Support\Collection::put expects string, int(2) provided |
|
| InvalidScalarArgument | Argument 2 of Illuminate\Support\Collection::put expects string, 2 provided |
|
||||||
And I see no other errors
|
And I see no other errors
|
||||||
|
|
||||||
|
@ -16,6 +16,24 @@ Feature: Container
|
|||||||
</psalm>
|
</psalm>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: Application interface does not error
|
||||||
|
Given I have the following code
|
||||||
|
"""
|
||||||
|
<?php
|
||||||
|
use App\Jobs\PullContact;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider {
|
||||||
|
public function register() {
|
||||||
|
$this->app->foo("a", "b");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
When I run Psalm
|
||||||
|
Then I see these errors
|
||||||
|
| Type | Message |
|
||||||
|
| UndefinedInterfaceMethod | Method Illuminate\Contracts\Foundation\Application::foo does not exist |
|
||||||
|
|
||||||
Scenario: the container resolves correct types
|
Scenario: the container resolves correct types
|
||||||
Given I have the following code
|
Given I have the following code
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user