From 2475ce47e4c76bb8924d74f2d859ccd8a59e7b2b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 18 Apr 2011 00:12:40 +0200 Subject: [PATCH] Make ArrayRepository more extensible --- src/Composer/Repository/ArrayRepository.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index f73b5bed7..a1afc5343 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -21,7 +21,7 @@ use Composer\Package\PackageInterface; */ class ArrayRepository implements RepositoryInterface { - protected $packages = array(); + protected $packages; /** * Adds a new package to the repository @@ -41,6 +41,9 @@ class ArrayRepository implements RepositoryInterface */ public function getPackages() { + if (null === $this->packages) { + $this->initialize(); + } return $this->packages; } @@ -53,4 +56,12 @@ class ArrayRepository implements RepositoryInterface { return count($this->packages); } + + /** + * Initializes the packages array. Mostly meant as an extension point. + */ + protected function initialize() + { + $this->packages = array(); + } }