Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems reported by PHPStan #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Exceptions/CreateReplayException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Gosuperscript\ZeroDowntimeEventReplays\Exceptions;

class CreateReplayException extends \Exception
final class CreateReplayException extends \Exception
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protect static in line number 9.

{
public static function replayAlreadyExists(string $key): self
{
Expand Down
4 changes: 2 additions & 2 deletions src/Projectors/EloquentZeroDowntimeProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ public function removeConnection(): void
return $model->getConnectionName();
})->each(function ($models, $connection) {
$tables = [];
$statements = [];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it en error or $statements array should be emptied in each iteration?

foreach ($models as $model) {
if (! $model instanceof Model) {
throw new Exception("models in the models method should extend eloquents model class");
}
$ghostConnectionTable = config('database.connections.' . $this->getGhostConnectionForModel($model) . '.prefix') . $model->getTable();

$defaultValues = DB::connection($model->getConnectionName())->select("SELECT column_name, column_default FROM information_schema.columns WHERE (table_schema, table_name) = ('public', '{$ghostConnectionTable}') AND column_default is not null;");
$statements = [];
collect($defaultValues)->filter(function ($defaultValue) {
return Str::contains($defaultValue->column_default, "_seq") && Str::contains($defaultValue->column_default, 'nextval(');
})->each(function ($defaultValue) use ($model, $ghostConnectionTable, &$statements) {
})->each(function ($defaultValue) use ($ghostConnectionTable, &$statements) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$model is not used.

$statements[] = "DROP SEQUENCE IF EXISTS {$ghostConnectionTable}_{$defaultValue->column_name}_seq";
});
$tables[] = $ghostConnectionTable;
Expand Down
3 changes: 1 addition & 2 deletions src/Replay.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public function started(int $fromEventId, ?CarbonInterface $startedAt = null)

public function finished(?CarbonInterface $finishedAt = null)
{
/** @var Play $play */
$play = $this->getActivePlay();
if (! $play) {
if ($play === null) {
return;
}
$play->finished($finishedAt);
Expand Down
2 changes: 1 addition & 1 deletion src/ZeroDowntimeEventReplaysServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public function register()
return new RedisReplayRepository();
});

return parent::register(); // TODO: Change the autogenerated stub
parent::register(); // TODO: Change the autogenerated stub
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

register() should not return anything.

There is an error in ./vendor/spatie/laravel-package-tools/src/PackageServiceProvider.php too.

}
}