The main advantage of SplFixedArray
is that for a specific subset of use cases for arrays, it is much faster (this subset is an array that has only integer keys and a fixed length). So for example:
$a = array("foo", $bar, 7, ... thousands of values ..., $quux); $b = \SplFixedArray::fromArray($a);
Using this class literally may be something you could use for an array, but found that they used to be too slow. Many times this happens in complex calculations on large data sets. For your typical PHP or web site, there will not be many (if any) cases where you need to improve performance.
However, the SplObjectStorage
class can be useful in all typical cases. It provides a way to map objects to other data. So, for example, perhaps you have a Route
class that you want to provide a mapping to the Controller
class:
$routeOne = new Route(); $routeTwo = new Route(); $controllerOne = new Controller(); $controllerTwo = new Controller(); $controllers = new \SplObjectStorage(); $controllers[$routeOne] = $controllerOne; $controllers[$routeTwo] = $controllerTwo;
source share