slimphp / Slim-Skeleton

Slim Framework 4 Skeleton Application
http://www.slimframework.com
MIT License
1.58k stars 477 forks source link

`src/Application/Actions/ActionError` has wrong type `$description` #289

Closed Dmitrev closed 2 years ago

Dmitrev commented 2 years ago
// src/Application/Actions/ActionError.php

class ActionError implements JsonSerializable
{

    private string $description;                                     // <- string

    public function __construct(string $type, ?string $description)  // string|null ?
    {
        $this->type = $type;
        $this->description = $description;
    }

    public function getDescription(): string                          // string
    {
        return $this->description;
    }

    public function setDescription(?string $description = null): self // string|null ?
    {
        $this->description = $description;
        return $this;
    }
}

This file declares $description as string

https://github.com/slimphp/Slim-Skeleton/blob/master/src/Application/Actions/ActionError.php#L23

While all the other methods seem to accept ?string https://github.com/slimphp/Slim-Skeleton/blob/master/src/Application/Actions/ActionError.php#L25 https://github.com/slimphp/Slim-Skeleton/blob/master/src/Application/Actions/ActionError.php#L47

However passing a null to these methods will result in a TypeError

Is this a typo or intentional? In my own project I just converted everything to string. Happy to make a PR for that if you agree.

nbayramberdiyev commented 2 years ago

Hey, thanks for raising this issue. Feel free to open a PR.

Dmitrev commented 2 years ago

Fixed in #290