Skip to content

Commit

Permalink
Fix PHPStan issues again, change fire to dispatch on all events
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Jan 23, 2023
1 parent 301e952 commit f9b9241
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 18 deletions.
13 changes: 9 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,14 @@ parameters:
path: src/Extension/Extendable.php

-
message: "#^Call to an undefined method Illuminate\\\\Events\\\\Dispatcher\\:\\:fire\\(\\)\\.$#"
count: 2
message: "#^Parameter \\#3 \\$replacement of method Illuminate\\\\Support\\\\Collection\\<int\\<0, 1\\>,Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\), mixed\\>\\>\\:\\:splice\\(\\) expects array\\<Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\), mixed\\>\\>, array\\{array\\} given\\.$#"
count: 1
path: src/Foundation/Application.php

-
message: "#^Parameter \\#3 \\$replacement of method Illuminate\\\\Support\\\\Collection\\<int\\<0, 1\\>,Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\), mixed\\>\\>\\:\\:splice\\(\\) expects array\\<Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\), mixed\\>\\>, array\\{array\\} given\\.$#"
message: "#^Strict comparison using \\=\\=\\= between array\\|null and false will always evaluate to false\\.$#"
count: 1
path: src/Foundation/Application.php
path: src/Foundation/Exception/Handler.php

-
message: "#^Conditional return type uses subject type TCacheValue which is not part of PHPDoc @template tags\\.$#"
Expand Down Expand Up @@ -800,6 +800,11 @@ parameters:
count: 1
path: src/Mail/Mailer.php

-
message: "#^Call to an undefined method Illuminate\\\\Config\\\\Repository\\:\\:package\\(\\)\\.$#"
count: 1
path: src/Support/ModuleServiceProvider.php

-
message: "#^Parameter \\#2 \\$data \\(array\\) of method Winter\\\\Storm\\\\Support\\\\Testing\\\\Fakes\\\\MailFake\\:\\:queue\\(\\) should be compatible with parameter \\$queue \\(string\\|null\\) of method Illuminate\\\\Contracts\\\\Mail\\\\MailQueue\\:\\:queue\\(\\)$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Connections/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ protected function fireEvent(string $event, array|object $attributes = []): void
return;
}

$eventManager->fire($event, $attributes);
$eventManager->dispatch($event, $attributes);
}
}
2 changes: 1 addition & 1 deletion src/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function register()
$this->app->bind('db.schema', function ($app) {
$builder = $app['db']->connection()->getSchemaBuilder();

$app['events']->fire('db.schema.getBuilder', [$builder]);
$app['events']->dispatch('db.schema.getBuilder', [$builder]);

return $builder;
});
Expand Down
6 changes: 3 additions & 3 deletions src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function bootstrapWith(array $bootstrappers)

$exceptions = [];
foreach ($bootstrappers as $bootstrapper) {
$this['events']->fire('bootstrapping: '.$bootstrapper, [$this]);
$this['events']->dispatch('bootstrapping: '.$bootstrapper, [$this]);

// Defer any exceptions until after the application has been
// bootstrapped so that the exception handler can run without issues
Expand All @@ -139,7 +139,7 @@ public function bootstrapWith(array $bootstrappers)
$exceptions[] = $ex;
}

$this['events']->fire('bootstrapped: '.$bootstrapper, [$this]);
$this['events']->dispatch('bootstrapped: '.$bootstrapper, [$this]);
}

if (!empty($exceptions)) {
Expand Down Expand Up @@ -385,7 +385,7 @@ public function setLocale($locale)
{
parent::setLocale($locale);

$this['events']->fire('locale.changed', [$locale]);
$this['events']->dispatch('locale.changed', [$locale]);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Foundation/Console/ClearCompiledCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use Illuminate\Foundation\Console\ClearCompiledCommand as ClearCompiledCommandBase;

/**
* @property \Winter\Storm\Foundation\Application $laravel
*/
class ClearCompiledCommand extends ClearCompiledCommandBase
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$this->bootstrap();
$this->app['events']->fire('console.schedule', [$schedule]);
$this->app['events']->dispatch('console.schedule', [$schedule]);
}
}
4 changes: 2 additions & 2 deletions src/Mail/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function mailer($name = null)
/*
* Extensibility
*/
$this->app['events']->fire('mailer.beforeRegister', [$this]);
$this->app['events']->dispatch('mailer.beforeRegister', [$this]);

return parent::mailer($name);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ protected function resolve($name)
/*
* Extensibility
*/
$this->app['events']->fire('mailer.register', [$this, $mailer]);
$this->app['events']->dispatch('mailer.register', [$this, $mailer]);

return $mailer;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Router/CoreRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public function dispatch(Request $request)
{
$this->currentRequest = $request;

$this->events->fire('router.before', [$request]);
$this->events->dispatch('router.before', [$request]);

$response = $this->dispatchToRoute($request);

$this->events->fire('router.after', [$request, $response]);
$this->events->dispatch('router.after', [$request, $response]);

return $response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Facades/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function connection($name)
{
$builder = static::$app['db']->connection($name)->getSchemaBuilder();

static::$app['events']->fire('db.schema.getBuilder', [$builder]);
static::$app['events']->dispatch('db.schema.getBuilder', [$builder]);

return $builder;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Events/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testNormalListen()
$dispatcher->listen('test.test', function () use (&$magic_value) {
$magic_value = true;
});
$dispatcher->fire('test.test');
$dispatcher->dispatch('test.test');
$this->assertTrue($magic_value);
}

Expand Down Expand Up @@ -170,7 +170,7 @@ public function testInstanceMethodListen()
$classInstance = new TestClass;

$dispatcher->listen('test.test', [$classInstance, 'instanceMethodHandler']);
$dispatcher->fire('test.test');
$dispatcher->dispatch('test.test');

$this->assertTrue($classInstance->getMagicValue());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/EventFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testFire()
{
$event = 'event.fake.test';

$this->faker->fire($event);
$this->faker->dispatch($event);
$this->faker->assertDispatched($event);
}
}

0 comments on commit f9b9241

Please sign in to comment.