Are you expecting a return from the function SUM()? If so there is no return command. (return $this->sumx; )
Also for your code, foreach is a better alternative as it’s easier to read/understand. Or you can use a predefined php function (array_sum), though I assume you’re just doing this for learning.
Another thing, don’t use one letter variables like x and k together -_-, very hard to read and easily confusing.