O
O
Oleg2019-03-21 17:01:20
Eclipse
Oleg, 2019-03-21 17:01:20

Is it possible to document the list of valid values ​​for an integer type?

class Entity_Чтото{
    const STATUS_ONE = 0;
    const STATUS_TWO = 1;
    /** @var int */
    private $status;

    /**
     * @param int $status
     */
    public function setStatus($status)
    {
        $this->status = $status;
    }

};

I would like that when setStatus is used, it prompts the choice from the corresponding constants.
Is there a way to do something similar?
I didn’t add the phpDocumentor tag, because I don’t see a solution in its syntax.
Perhaps there are extensions in the IDE that I don't know about?
Refactor the code of times 5.2. There is no way to rewrite everything under 7ku. I try to
make my life as easy as possible. While I decided to redo it like this

/**
 * Класс констант для значения поля
 * STATUS_NEW -              <br>
 * STATUS_EDIT -             <br>
 */
final class Invoice_Enum_Status
{
    const STATUS_NEW = 0;
    const STATUS_EDIT = 1;
}
/**
 * Виртуальный класс, описывающий строку данных из таблицы
 * @property Invoice_Enum_Status $status - для этого поля избавляемся от захоркоженных значений 
 * @property остальные поля
 */
class Entity_Invoice{};

//  пусть сферический конь будет сущностью
/** @var Entity_Invoice $a */  
$a = new stdClass();  // 
$a->status = Invoice_Enum_Status::STATUS_NEW;

Unfortunately, autocomplete doesn't work that way. But at least there were clues.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Konyukhov, 2019-03-21
@heahoh

use enum , type parameter setStatus(MyStatusEnum $status)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question