1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 00:47:00 +02:00

chore(phpstan): enable phpstan in bundled extensions (#3667)

* feat(phpstan): pick up extended model relations typings
* feat(phpstan): pick up extended model date attributes
* feat(core): introduce `castAttribute` extender
Stops using `dates` as it's deprecated in laravel 8
* feat(phpstan): pick up extended model attributes through casts
* fix: extenders not resolved when declared namespace
* fix(phpstan): new model attributes are always nullable
* chore(phpstan): add helpful cache clearing command
* Apply fixes from StyleCI
* chore: improve extend files provider logic
* chore: rename `castAttribute` to just `cast`
* chore: update phpstan package to detect `cast` method
* chore: enable phpstan in bundled extensions
* chore: rebasing conflicts
* chore: rebasing conflicts
* chore: typings for latest 1.7 changes

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
Sami Mazouz
2023-01-19 21:49:38 +01:00
committed by GitHub
parent ccf9442d79
commit da1bf8da21
59 changed files with 215 additions and 138 deletions

View File

@@ -48,6 +48,7 @@ class AuthController implements RequestHandlerInterface
$this->settings->get('flarum-pusher.app_key'),
$this->settings->get('flarum-pusher.app_secret'),
$this->settings->get('flarum-pusher.app_id'),
// @phpstan-ignore-next-line
['cluster' => $this->settings->get('flarum-pusher.app_cluster')]
);

View File

@@ -9,6 +9,7 @@
namespace Flarum\Pusher\Listener;
use Flarum\Extension\ExtensionManager;
use Flarum\Post\Event\Posted;
use Flarum\User\Guest;
use Flarum\User\User;
@@ -22,9 +23,15 @@ class PushNewPost
*/
protected $pusher;
public function __construct(Pusher $pusher)
/**
* @var ExtensionManager
*/
protected $extensions;
public function __construct(Pusher $pusher, ExtensionManager $extensions)
{
$this->pusher = $pusher;
$this->extensions = $extensions;
}
public function handle(Posted $event)
@@ -43,6 +50,7 @@ class PushNewPost
return;
}
// @phpstan-ignore-next-line
foreach ($response->channels as $name => $channel) {
$userId = Str::after($name, 'private-user');
@@ -53,7 +61,7 @@ class PushNewPost
}
if (count($channels)) {
$tags = $event->post->discussion->tags;
$tags = $this->extensions->isEnabled('flarum-tags') ? $event->post->discussion->tags : null;
$this->pusher->trigger($channels, 'newPost', [
'postId' => $event->post->id,

View File

@@ -29,6 +29,7 @@ class PusherProvider extends AbstractServiceProvider
$settings->get('flarum-pusher.app_key'),
$settings->get('flarum-pusher.app_secret'),
$settings->get('flarum-pusher.app_id'),
// @phpstan-ignore-next-line
$options
);
});