Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-feek authored Jun 9, 2021
2 parents 96b90a2 + 2b7fe45 commit d43d48f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/AppInterfaceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static function doesMethodExist(
) : ?bool {
if ($method_name_lowercase === 'offsetget'
|| $method_name_lowercase === 'offsetset'
|| $method_name_lowercase === '__call'
) {
return true;
}
Expand All @@ -55,7 +54,6 @@ public static function isMethodVisible(
) : ?bool {
if ($method_name_lowercase === 'offsetget'
|| $method_name_lowercase === 'offsetset'
|| $method_name_lowercase === '__call'
) {
return true;
}
Expand Down
23 changes: 12 additions & 11 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ class Plugin implements PluginEntryPointInterface

public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null) : void
{
$app = ApplicationHelper::bootApp();

$fake_filesystem = new FakeFilesystem();

$view_factory = $this->getViewFactory($app, $fake_filesystem);

$cache_dir = __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;

$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);
try {
$app = ApplicationHelper::bootApp();
$fake_filesystem = new FakeFilesystem();
$view_factory = $this->getViewFactory($app, $fake_filesystem);
$cache_dir = __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;

$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);
} catch (\Throwable $t) {
return;
}

require_once 'ReturnTypeProvider/AuthReturnTypeProvider.php';
$registration->registerHooksFromClass(ReturnTypeProvider\AuthReturnTypeProvider::class);
Expand Down
26 changes: 26 additions & 0 deletions src/Stubs/Container.stubphp
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion tests/acceptance/CollectionTypes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ Feature: collection types
| 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' |
| 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

18 changes: 18 additions & 0 deletions tests/acceptance/Container.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ Feature: Container
</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
Given I have the following code
"""
Expand Down

0 comments on commit d43d48f

Please sign in to comment.