Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slavarazum committed Dec 9, 2023
1 parent bb5ece3 commit a354491
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"extra": {
"laravel": {
"providers": [
"Qruto\\LaravelWave\\LaravelWaveServiceProvider"
"Qruto\\LaravelWave\\WaveServiceProvider"
]
}
},
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ parameters:
- src
- config
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false
10 changes: 10 additions & 0 deletions phpstan.neon.rector.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- phpstan-baseline.neon

parameters:
level: 4
paths:
- src
- config
tmpDir: build/phpstan
checkMissingIterableValueType: false
10 changes: 8 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

Expand All @@ -22,11 +23,16 @@
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
// SetList::CODING_STYLE,
// SetList::NAMING,
// SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION,
// SetList::PRIVATIZATION,
// SetList::TYPE_DECLARATION,
]);

$rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon.dist');
$rectorConfig->skip([
RemoveUnusedPromotedPropertyRector::class => [
__DIR__ . '/src/Sse/ServerSentEvent.php',
],
]);

$rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon.rector.dist');
};
2 changes: 1 addition & 1 deletion src/Sse/ServerSentEventStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function shouldNotSend(BroadcastingEvent $event, ?string $socket, ?Aut
return false;
}

if ($user !== null && $this->presenceChannelEvent->isSelfLeaveEvent($event, $user)) {
if ($user instanceof \Illuminate\Contracts\Auth\Authenticatable && $this->presenceChannelEvent->isSelfLeaveEvent($event, $user)) {
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Storage/BroadcastEventHistoryRedisStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getEventsFrom(string $id): Collection

return collect($this->db->xRange('broadcasted_events', $timestamp.'-'.$sequence, '+'))
->map(function ($event, $id) {
$event['data'] = json_decode($event['data'], true);
$event['data'] = json_decode($event['data'], true, 512, JSON_THROW_ON_ERROR);

return new BroadcastingEvent(...['id' => $id] + $event);
})->values();
Expand All @@ -39,15 +39,15 @@ public function lastEventTimestamp(): int
{
$keys = array_keys($this->db->xRevRange('broadcasted_events', '-', '+', 1));

return empty($keys) ? 0 : explode('-', reset($keys))[0];
return $keys === [] ? 0 : explode('-', reset($keys))[0];
}

public function pushEvent(BroadcastingEvent $event)
{
$this->removeOldEvents();

$eventData = \get_object_vars($event);
$eventData['data'] = json_encode($eventData['data']);
$eventData['data'] = json_encode($eventData['data'], JSON_THROW_ON_ERROR);
$id = $this->db->xAdd('broadcasted_events', '*', $eventData);

$event->id = $id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class LaravelWaveServiceProvider extends PackageServiceProvider
class WaveServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\TestCase as Orchestra;
use Qruto\LaravelWave\LaravelWaveServiceProvider;
use Qruto\LaravelWave\WaveServiceProvider;

class TestCase extends Orchestra
{
Expand All @@ -22,7 +22,7 @@ protected function setUp(): void
protected function getPackageProviders($app)
{
return [
LaravelWaveServiceProvider::class,
WaveServiceProvider::class,
];
}

Expand Down

0 comments on commit a354491

Please sign in to comment.