laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Cannot override property comment in model hook

Open tminich opened this issue 3 years ago • 2 comments

Versions:

  • ide-helper Version: 2.12.3
  • PHP Version: 8.0.0

Description:

The comment parameter in ModelsCommand::setProperty is ignored when the property is already registered so you cannot override it using a model hook. I can see no other way of overriding the comment in a hook, so it would be great if this could be added.

If wanted I can fix this and submit a PR.

tminich avatar Apr 21 '22 11:04 tminich

If wanted I can fix this and submit a PR.

I'd say, yes please!

mfn avatar Apr 21 '22 12:04 mfn

I've started to work on this but ran into some issues, it's not as simple as just changing the method itself. Before I continue I would appreciate some input on how to proceed properly fixing this.

Currently the function signature looks like this:

public function setProperty($name, $type = null, $read = null, $write = null, $comment = '', $nullable = false)

My first instinct was to change the default for the $comment parameter to null for consistency. Unfortunately that let to some changes in output apparent in my project. Keeping the signature as is and using setting comment to null as an indication to remove a present comment makes the ModelsCommand/Comment Test fail for the properties that have both getter and setter defined.

Thus I'd love some input which signature is the preferred one so I can get started fixing from there.

tminich avatar Apr 22 '22 09:04 tminich