Are there any consequences to not declaring variables at the start of the class declaration. I mean, I always do it because it is just neater and nicer, but my latest project is huge, and I have added loads of vars without declaration in the heat of the moment without consequence. I am now about to go and add them all to the opening declaration no matter what, just curious.
The PHP parser doesn't care one way or the another, but, especially because your code base is so huge, having a consistent class layout will help you immensely. It need not be the start, though that is probably the most common place for it.
It has no consequences, unfortunately. Not even in STRICT mode. We use a modified version of PHP to get warnings when someone does this. Some of the warnings you need are even simply commented out in the PHP source code. That's a shame.
PHP is very loosely typed so, as you know, if you type $myClass->var1 = 1
even though no var1
exists, PHP will just create one for you. It's immensely better practice to declare and document your class members but your code will run fine.
You'll get warnings if you access a class variable before it's been created if you're running in a strict mode, but otherwise you can define them anywhere - on that score PHP doesn't care at all if you do it first thing in the class or deep within the bowels of a method
The only real consequence (Besides writing sloppy code which you're fixing) that I can see is not being able to specify access modifiers to properties not declared some where in the class, i.e. public, private, protected.
Another minor consequence is automated documentation generators like phpDocumentor won't be able to document the properties if they're not properly defined.