Skip to content

Commit b6a9421

Browse files
author
codeliner
committed
Fix vo_collection: emptyList prroduces error
1 parent 4c0488e commit b6a9421

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

.env/PHPStorm/PHP.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<option name="PHP String Literal" value="false" />
6868
</context>
6969
</template>
70-
<template name="vo_collection" value="/**&#10; * @var $ITEM_CLASS$[]&#10; */&#10;private $items;&#10;&#10;public static function fromArray(array $items): self&#10;{&#10; return new self(...array_map(function ($TYPE$ $item) {&#10; return $ITEM_CLASS$::from$TYPE_METHOD$($item);&#10; }, $items));&#10;}&#10;&#10;public static function fromItems($ITEM_CLASS$ ...$items): self&#10;{&#10; return new self(...$items);&#10;}&#10;&#10;public static function emptyList(): self&#10;{&#10; return new self([]);&#10;}&#10;&#10;private function __construct($ITEM_CLASS$ ...$items)&#10;{&#10; $this-&gt;items = $items;&#10;}&#10;&#10;public function push($ITEM_CLASS$ $item): self&#10;{&#10; $copy = clone $this;&#10; $copy-&gt;items[] = $item;&#10; return $copy;&#10;}&#10;&#10;public function pop(): self&#10;{&#10; $copy = clone $this;&#10; \array_pop($copy-&gt;items);&#10; return $copy;&#10;}&#10;&#10;public function first(): ?$ITEM_CLASS$&#10;{&#10; return $this-&gt;items[0] ?? null;&#10;}&#10;&#10;public function last(): ?$ITEM_CLASS$&#10;{&#10; if(count($this-&gt;items) === 0) {&#10; return null;&#10; }&#10;&#10; return $this-&gt;items[count($this-&gt;items) - 1];&#10;}&#10;&#10;public function contains($ITEM_CLASS$ $item): bool&#10;{&#10; foreach($this-&gt;items as $existingItem) {&#10; if($existingItem-&gt;equals($item)) {&#10; return true;&#10; }&#10; }&#10; &#10; return false;&#10;}&#10;&#10;/**&#10; * @return $ITEM_CLASS$[]&#10; */&#10;public function items(): array&#10;{&#10; return $this-&gt;items;&#10;}&#10;&#10;public function toArray(): array&#10;{&#10; return \array_map(function ($ITEM_CLASS$ $item) {&#10; return $item-&gt;to$TYPE_METHOD$();&#10; }, $this-&gt;items);&#10;}&#10;&#10;public function equals($other): bool&#10;{&#10; if(!$other instanceof self) {&#10; return false;&#10; }&#10;&#10; return $this-&gt;toArray() === $other-&gt;toArray();&#10;}&#10;&#10;public function __toString(): string&#10;{&#10; return \json_encode($this-&gt;toArray());&#10;}" description="Collection value object" toReformat="true" toShortenFQNames="true">
70+
<template name="vo_collection" value="/**&#10; * @var $ITEM_CLASS$[]&#10; */&#10;private $items;&#10;&#10;public static function fromArray(array $items): self&#10;{&#10; return new self(...array_map(function ($TYPE$ $item) {&#10; return $ITEM_CLASS$::from$TYPE_METHOD$($item);&#10; }, $items));&#10;}&#10;&#10;public static function fromItems($ITEM_CLASS$ ...$items): self&#10;{&#10; return new self(...$items);&#10;}&#10;&#10;public static function emptyList(): self&#10;{&#10; return new self();&#10;}&#10;&#10;private function __construct($ITEM_CLASS$ ...$items)&#10;{&#10; $this-&gt;items = $items;&#10;}&#10;&#10;public function push($ITEM_CLASS$ $item): self&#10;{&#10; $copy = clone $this;&#10; $copy-&gt;items[] = $item;&#10; return $copy;&#10;}&#10;&#10;public function pop(): self&#10;{&#10; $copy = clone $this;&#10; \array_pop($copy-&gt;items);&#10; return $copy;&#10;}&#10;&#10;public function first(): ?$ITEM_CLASS$&#10;{&#10; return $this-&gt;items[0] ?? null;&#10;}&#10;&#10;public function last(): ?$ITEM_CLASS$&#10;{&#10; if(count($this-&gt;items) === 0) {&#10; return null;&#10; }&#10;&#10; return $this-&gt;items[count($this-&gt;items) - 1];&#10;}&#10;&#10;public function contains($ITEM_CLASS$ $item): bool&#10;{&#10; foreach($this-&gt;items as $existingItem) {&#10; if($existingItem-&gt;equals($item)) {&#10; return true;&#10; }&#10; }&#10; &#10; return false;&#10;}&#10;&#10;/**&#10; * @return $ITEM_CLASS$[]&#10; */&#10;public function items(): array&#10;{&#10; return $this-&gt;items;&#10;}&#10;&#10;public function toArray(): array&#10;{&#10; return \array_map(function ($ITEM_CLASS$ $item) {&#10; return $item-&gt;to$TYPE_METHOD$();&#10; }, $this-&gt;items);&#10;}&#10;&#10;public function equals($other): bool&#10;{&#10; if(!$other instanceof self) {&#10; return false;&#10; }&#10;&#10; return $this-&gt;toArray() === $other-&gt;toArray();&#10;}&#10;&#10;public function __toString(): string&#10;{&#10; return \json_encode($this-&gt;toArray());&#10;}" description="Collection value object" toReformat="true" toShortenFQNames="true">
7171
<variable name="ITEM_CLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" />
7272
<variable name="TYPE" expression="&quot;raw_type&quot;" defaultValue="" alwaysStopAt="true" />
7373
<variable name="TYPE_METHOD" expression="capitalize(TYPE)" defaultValue="" alwaysStopAt="false" />

.env/PHPStorm/settings.zip

-2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)