diff --git a/composer.json b/composer.json index 62e5f24..9155a3f 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,10 @@ } ], "require": { - "php": "^7.4", - "symfony/form": "~3.4|~4.0", - "symfony/http-foundation": "~3.4|~4.0", - "beberlei/assert": "@stable", - "doctrine/collections": "^1.4" + "php": "^8.0", + "symfony/form": "~5.4", + "symfony/http-foundation": "~5.4", + "beberlei/assert": "^3.3.2" }, "require-dev": { "phpunit/phpunit": "@stable" diff --git a/src/Mathielen/SapOci/Model/OciBasket.php b/src/Mathielen/SapOci/Model/OciBasket.php index daaf3d5..ef0a63e 100644 --- a/src/Mathielen/SapOci/Model/OciBasket.php +++ b/src/Mathielen/SapOci/Model/OciBasket.php @@ -2,19 +2,20 @@ namespace Mathielen\SapOci\Model; -use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Collections\Collection; +use Assert\Assertion; class OciBasket implements OciBasketInterface { - private Collection $items; + private array $items; - public function __construct(Collection $items = null) + public function __construct(array $items = []) { - $this->items = $items ?: new ArrayCollection(); + Assertion::allIsInstanceOf($items, OciBasketItemInterface::class); + + $this->items = $items; } - public function getItems(): Collection + public function getItems(): iterable { return $this->items; } diff --git a/src/Mathielen/SapOci/Model/OciBasketInterface.php b/src/Mathielen/SapOci/Model/OciBasketInterface.php index c02244d..3649146 100644 --- a/src/Mathielen/SapOci/Model/OciBasketInterface.php +++ b/src/Mathielen/SapOci/Model/OciBasketInterface.php @@ -2,9 +2,11 @@ namespace Mathielen\SapOci\Model; -use Doctrine\Common\Collections\Collection; - interface OciBasketInterface { - public function getItems(): Collection; + + /** + * @return OciBasketItemInterface[] + */ + public function getItems(): iterable; } diff --git a/src/Mathielen/SapOci/OciFormbuilderFactory.php b/src/Mathielen/SapOci/OciFormbuilderFactory.php index 419282a..bc697f8 100644 --- a/src/Mathielen/SapOci/OciFormbuilderFactory.php +++ b/src/Mathielen/SapOci/OciFormbuilderFactory.php @@ -57,7 +57,7 @@ public function factor(OciBasketInterface $basket): FormBuilderInterface $formBuilder = $this ->formFactory - ->createNamedBuilder(null, FormType::class, $formData, $this->defaultFormOptions); + ->createNamedBuilder('default', FormType::class, $formData, $this->defaultFormOptions); foreach (\array_keys($formData) as $formFieldName) { $this->addFormField($formBuilder, $formFieldName); diff --git a/tests/unit/Mathielen/SapOci/Model/OciModelTest.php b/tests/unit/Mathielen/SapOci/Model/OciModelTest.php index 7d07605..4c8f7e9 100644 --- a/tests/unit/Mathielen/SapOci/Model/OciModelTest.php +++ b/tests/unit/Mathielen/SapOci/Model/OciModelTest.php @@ -26,7 +26,7 @@ public function testConstraints($methodName): void $this->assertTrue(true); //all good } - public function getConstraintedMethodnames() + public static function getConstraintedMethodnames(): iterable { $rfl = new \ReflectionClass(Oci50BasketItem::class);