Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documenting implicit input parameters such as $_SESSION

Tags:

php

phpdoc

If a function relies on $_SESSION['some_var'] then the header comment out to make that clear. How do you do it? Just as text, or what?

Or even @param?

like image 865
Mawg says reinstate Monica Avatar asked Aug 28 '26 21:08

Mawg says reinstate Monica


2 Answers

You could maybe use @uses to document superglobals

like image 142
Nev Stokes Avatar answered Aug 31 '26 17:08

Nev Stokes


Wow, I never even thought about that. I don't even doc things like that. I would say to just state it in the method detail like

/**
 * Takes the some_var session variable and uses it to solve world hunger
 * @return food
 */

Makes the most sense to me.

There is @global, but that seems to indicate the creation of a global var. I think @param should only refer to method parameters passed to the method. There is no @note, that I know of.

like image 27
Explosion Pills Avatar answered Aug 31 '26 17:08

Explosion Pills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!