If I have a class called myclass does having static methods within the class affect its size in memory?
class myclass{
public $instancevar;
public static function method1(){}
public static function method2(){}
}
Will the addition of more static methods make instances of myclass larger?
I know that static methods are shared between instances of a class but will adding more or larger static methods impact on the size of the object in memory at all? Similarly will having more static methods affect execution time if I pass an instance to a method as an argument?
I would even say that also member methods to not increase the memory footprint of an object. If I serialize an object, only the information from which class it is an instance and which values its properties have are serialized. This is enough to determine the objects behaviour.
You can compute the size of an object described in this question.
You will see that adding or removing static or non-static methods does not change the object’s size.
To sum up: You gain nothing if you use static methods that operate on the object than using object methods directly.