A
A
Anton Ivanov2014-07-13 11:11:56
PHP
Anton Ivanov, 2014-07-13 11:11:56

phpstorm. how to make explicit type casting in setter?

Hello.
A question from the category of laziness, but which of the programmers is not lazy? :)
Let's say there is such a class property:

/**
* @var int
*/
private $id;

In PhpStorm, I can auto create getter and setter.
Getter does not interest us now.
As a rule, the setter is created like this:
/**
 * @param int $id
 */
public function setId($id)
{
  $this->id = $id;
}

So, I want, if a property (or a method parameter), has a type explicitly specified, then the setter should be created with an explicit cast to this type. That is, to be like this:
/**
 * @param int $id
 */
public function setId($id)
{
  $this->id = (int)$id;
}

Who knows if this is even possible?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2014-07-13
@Fly3110

Settings -> File and code templates -> Code -> PHP Setter Method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question