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

Protected/Private Attributes marked methods are not included in the model docBlock

Open viicslen opened this issue 3 years ago • 6 comments

Versions:

  • ide-helper Version: dev-master
  • Laravel Version: 8.78.1
  • PHP Version: 8.0.13

Description:

As described in the pull request attribute marked methods should be protected which makes them not discoverable by the the ModelsCommand.

Steps To Reproduce:

  • Create a protected attribute marked method
  • Run the ide-helper:models command

viicslen avatar Jan 05 '22 17:01 viicslen

While tinkering a bit with how Laravel handles these methods I found that we can get all methods even non-public by using (new ReflectionClass($instance))->getMethods() instead of get_class_methods()

viicslen avatar Jan 05 '22 17:01 viicslen

I would love to see this improvement made to be able to adhere to the recommended code style.

pindab0ter avatar Feb 10 '22 12:02 pindab0ter

I created PR for this around a month ago- https://github.com/barryvdh/laravel-ide-helper/pull/1325

mridul89 avatar Apr 07 '22 06:04 mridul89

@mridul89 seems I've forgotten about it; my first reaction: 0 tests. Probably that's the reason I wanted to queue it for later and then forgot about it…

mfn avatar Apr 07 '22 06:04 mfn

@mfn Sorry about that, i thought the existing tests would be fine since this is a bugfix.

I pushed another commit on the PR https://github.com/barryvdh/laravel-ide-helper/pull/1325 now.

mridul89 avatar Apr 07 '22 08:04 mridul89

In general, if you add a feature or fix a bug, you write tests for it to prove that it works since the existing tests won't point that out.

It's also a good idea to mention the issue you're fixing in the description of the PR. Since this issue wasn't mentioned in your PR I didn't see it and therefore didn't know it existed.

pindab0ter avatar Apr 07 '22 09:04 pindab0ter