I have a need to manage, handle, and manipulate a [set, collection] of objects.
I am thinking of creating a class that manages set of these objects.
What data structure can I use for this?
Example use:
$setManager = new SetManager();
$setManager->getCase($caseNum);
$ave = $setManager->getAverageValueForPropertyXFromAllCases();
$case = new Case();
$setManager->setCase($pos, $case);
I can use anything I want inside SetManager
, I have been using arrays, but my IDE has various issues with using autocomplete on arrays, and I am seeking other structures.
Most IDE's support annotations or have addons to add support for annotations and autocomplete.
For example
/** @var MyObject[]|array $myVar */
$myVar = [];
For an actual demonstration of annotation autocomplete on an array of objects.
You can even specify multiple types of objects that can be in the array and be accepted by a setter method.