Skip to content

Commit

Permalink
Merge pull request #366 from alies-dev/no-lumen
Browse files Browse the repository at this point in the history
Drop Lumen support 👋
  • Loading branch information
alies-dev authored Mar 12, 2024
2 parents c3e3db5 + 17c9195 commit 8c2f46b
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 177 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/test-laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ on:
- '**.stubphp'
- 'composer.json'
- 'tests/laravel*'
- 'tests/lumen*'
- '.github/workflows/test-laravel.yml'
pull_request:
paths:
- '**.php'
- '**.stubphp'
- 'composer.json'
- 'tests/laravel*'
- 'tests/lumen*'
- '.github/workflows/test-laravel.yml'

jobs:
Expand All @@ -32,7 +30,3 @@ jobs:
- name: Test Laravel
run: |
./tests/Application/laravel-test.sh
- name: Test Lumen
run: |
./tests/Application/lumen-test.sh
4 changes: 0 additions & 4 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@
<issueHandlers>
<LessSpecificReturnType errorLevel="info" />
</issueHandlers>

<stubs>
<file name="stubs/Lumen/Application.stubphp"/>
</stubs>
</psalm>
12 changes: 0 additions & 12 deletions src/Handlers/Application/ContainerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ public static function getClassLikeNames(): array

public static function getMethodReturnType(MethodReturnTypeProviderEvent $event): ?Type\Union
{
// lumen doesn't have the likes of makeWith, so we will ensure these methods actually exist on the underlying
// app contract
$methods = array_filter(['make', 'makewith'], static function (string $methodName) use ($event) {
$methodId = new MethodIdentifier($event->getFqClasslikeName(), $methodName);
return $event->getSource()->getCodebase()->methodExists($methodId);
});

if (!in_array($event->getMethodNameLowercase(), $methods, true)) {
return null;
}

return ContainerResolver::resolvePsalmTypeFromApplicationContainerViaArgs($event->getSource()->getNodeTypeProvider(), $event->getCallArgs());
}

Expand All @@ -91,7 +80,6 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event)
continue;
}

/** @psalm-suppress MixedArgument */
$concrete = ApplicationProvider::getApp()->make($abstract);

if (!is_object($concrete)) {
Expand Down
1 change: 0 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ protected function getCommonStubs(): array
glob(dirname(__DIR__) . '/stubs/Foundation/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Http/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/legacy-factories/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Lumen/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Pagination/*.stubphp'),
glob(dirname(__DIR__) . '/stubs/Support/*.stubphp'),
);
Expand Down
23 changes: 9 additions & 14 deletions src/Providers/ApplicationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application as LaravelApplication;
use Laravel\Lumen\Application as LumenApplication;
use Orchestra\Testbench\Concerns\CreatesApplication;

use function define;
Expand All @@ -22,26 +21,22 @@ final class ApplicationProvider
{
use CreatesApplication;

/** @var LaravelApplication|LumenApplication|null */
/** @var LaravelApplication|null */
private static $app = null;

public static function bootApp(): void
{
$app = self::getApp();

if ($app instanceof LaravelApplication) {
/** @var \Illuminate\Contracts\Console\Kernel $consoleApp */
$consoleApp = $app->make(Kernel::class);
// @todo do not bootstrap \Illuminate\Foundation\Bootstrap\HandleExceptions
$consoleApp->bootstrap();
} else { // LumenApplication
$app->boot();
}
/** @var \Illuminate\Contracts\Console\Kernel $consoleApp */
$consoleApp = $app->make(Kernel::class);
// @todo do not bootstrap \Illuminate\Foundation\Bootstrap\HandleExceptions
$consoleApp->bootstrap();

$app->register(IdeHelperServiceProvider::class);
}

public static function getApp(): LaravelApplication | LumenApplication
public static function getApp(): LaravelApplication
{
if (self::$app instanceof \Illuminate\Container\Container) {
return self::$app;
Expand All @@ -61,8 +56,8 @@ public static function getApp(): LaravelApplication | LumenApplication
$app = (new self())->createApplication(); // Orchestra\Testbench
}

if (! $app instanceof LaravelApplication && ! $app instanceof LumenApplication) {
throw new \RuntimeException('Could not find Laravel/Lumen bootstrap file.');
if (! $app instanceof LaravelApplication) {
throw new \RuntimeException('Could not find Laravel bootstrap file.');
}

self::$app = $app;
Expand All @@ -71,7 +66,7 @@ public static function getApp(): LaravelApplication | LumenApplication
}

/**
* @psalm-return class-string<\Illuminate\Foundation\Application|\Laravel\Lumen\Application>
* @psalm-return class-string<\Illuminate\Foundation\Application>
*/
public static function getAppFullyQualifiedClassName(): string
{
Expand Down
1 change: 0 additions & 1 deletion src/Providers/ModelStubProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static function generateStubFile(): void
throw new \RuntimeException('Unsupported Application type.');
}

/** @var string $migrations_directory */
$migrations_directory = $app->databasePath('migrations/');

$project_analyzer = ProjectAnalyzer::getInstance();
Expand Down
26 changes: 0 additions & 26 deletions stubs/Lumen/Application.stubphp

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Application/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Application tests

Idea of application test: create an [almost] empty Laravel (or Lumen) app and run Psalm over its codebase.
Idea of application test: create an [almost] empty Laravel app and run Psalm over its codebase.

## FAQ

Expand Down
61 changes: 0 additions & 61 deletions tests/Application/lumen-test-baseline.xml

This file was deleted.

26 changes: 0 additions & 26 deletions tests/Application/lumen-test-psalm.xml

This file was deleted.

24 changes: 0 additions & 24 deletions tests/Application/lumen-test.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

There are 3 types of tests:
1. Acceptance (main one): Use Codeception to run Psalm over code snippets in a context of fake Laravel app [using orchestra/testbench]
2. Application: create an [almost] empty Laravel (or Lumen) app and run Psalm over its codebase.
2. Application: create an [almost] empty Laravel app and run Psalm over its codebase.
3. Unit: use PHPUnit to test some internal logic without running Psalm.

0 comments on commit 8c2f46b

Please sign in to comment.