Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

DocBlock @return wrong in CI_DB_query_builder #2064

Closed
hailwood opened this Issue Dec 9, 2012 · 8 comments

Comments

Projects
None yet
4 participants

hailwood commented Dec 9, 2012

The @return statements all state @return object while this is technically correct where $this is returned they should instead be @return CI_DB_query_builder which helps IDE's with autocompletion as currently several IDE's fall over after calling a method such as

 $this->db->select('something')-> 

There is no autocomplete at this point as object has no methods.

Contributor

narfbg commented Dec 10, 2012

Got a pull request to solve that?

Well I am wondering if there is an actual reason for it as it seems strange to do by accident as most docblock generators will generate the block with the actual class name.

I can create one if it is an actual bug though

Contributor

narfbg commented Dec 10, 2012

Those docblocks were AFAIK written by hand, not automatically generated, so that's not unexpected. I don't consider anything in a docblock to be a bug, but it would be an improvement if you can do that - yes. :)

Awesome, will get that through in the next 24 hours, I've been awake for the last 25 and don't trust my blurry vision to type it correctly!

Contributor

pickupman commented Dec 13, 2012

This would be the case for a number of class methods that are chainable. DB_forge, DB_query_builder, Email, Encrypt, Form_validation, Output, Security, and Zip classes all have return $this; statements in them. The DocBlock shows object being returned in them. I show it appearing 62 times.

The IDE I am using will still autocomplete regardless, but I know may not always be the case.

Contributor

timw4mail commented Dec 13, 2012

Personally, I use @return $this for chained methods. Does actually using the Class name always work better for autocompletion?

Well my IDE phpstorm will autocomplete the third level onwards if I use the
class name, but I don't know if it understands $this in the docblock
context
On 13/12/2012 3:24 PM, "Timothy Warren" notifications@github.com wrote:

Personally, I use @return $this for chained methods. Does actually using
the Class name always work better for autocompletion?


Reply to this email directly or view it on GitHubhttps://github.com/EllisLab/CodeIgniter/issues/2064#issuecomment-11319853.

Contributor

narfbg commented Dec 14, 2012

I don't think that $this would pass validation rules for phpDoc (IDE autocompletion isn't the only stuff that uses it).

narfbg added a commit that referenced this issue Dec 17, 2012

@narfbg narfbg closed this Dec 17, 2012

nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

update for Issue #2064 (changed docblocks which return $this or only …
…call a method that returns $this to @return CI_DB_class_name)

nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment