I had same problem with my code when I was working in an Opencart Project.
After several hours of frustration I realized that the cause of this issue was the absence of closure of last function.
I forgot to close the function above it i.e.
}
was missing so it was like defining a function inside another function. Have you checked if that's the same case with you.