2

I know that there is a similar question here, but that doesn't help me in any way even though I have the same problem of being a big project and not being able to find where a variable is first defined.

What I've tried:
I tried the find function from phpstorm (cmd+shift+f) and searched all files of the project, to no avail. The variable is $_SESSION['some_index'] it is used in multiple places in the code, but I could only find one place where it is assigned:

$_SESSION['some_index'] = someclass->getVar()

so I tried going there, that class has no constructor and the setVar() function is only called once, and is passed (ironically) $_SESSION['some_index'].

If there any way to follow the code maybe through debugging of some sort? I do have xdebug configured.

I did debug through the code to the spot where I got an undefined index notice and I saw that the variable is set I just used the wrong name, but there are so many (unknown) spots where I would have to change it. I'm guessing finding out where it is set, and change it there would be quicker.

Community
  • 1
  • 1
Anthony
  • 139
  • 4
  • 13
  • no extra files used? include 'filename'; or require 'filename'; maybe the var is created there – Nomistake Mar 13 '17 at 11:29
  • the find function from phpstorm searches all files in the project :/ – Anthony Mar 13 '17 at 11:58
  • Wherever you're calling `someclass->getVar()` you can hold cmd and click the code and it should take you to where the initial code was formed. – Option Mar 13 '17 at 12:00
  • 1
    I would step through your code using debugger. Session is a superglobal variable and can be set anywhere in the code. If the `some_index` is a static name I would try a full text search for index only, as it may be defined in session via variable. – Lukas Hajdu Mar 13 '17 at 12:00
  • @LukasHajdu Yeah I just tried that and 1 step after the line `session_start();` the index is already set and filled with the values that I wanted to know where they're coming from, can this be correct? – Anthony Mar 13 '17 at 12:13
  • @Option yeah tried that too, but figured out that line of code never gets called :/ – Anthony Mar 13 '17 at 12:14
  • @LukasHajdu sorry for my stupidity, of course a session was already set when I was debugging.. started a new session and am debugging now, let's see how long it will take to find the right code – Anthony Mar 13 '17 at 12:38

0 Answers0