Futuristic PHP development
PXP is an work-in-progress superset of the PHP programming language with support for new language features and syntax.
1class Collection<T> 2{ 3 public function __construct( 4 protected T[] $items = [] 5 ) {} 6 7 public function push(T $item): static 8 { 9 $this->items[] = $item;10 11 return $this;12 }13 14 public function all(): T[]15 {16 return $this->items;17 }18}
1type LabelValue = string | Closure | null; 2 3trait HasLabel 4{ 5 protected LabelValue $label; 6 7 public function getLabel(): LabelValue 8 { 9 return $this->label;10 }11 12 public function setLabel(LabelValue $label): void13 {14 $this->label = $label;15 }16}
1$guests = array_filter($users, fn ($user) {2 $guest = $repository->findByUserId($user->id);3 return $guest !== null && in_array($guest->id, $guestsIds);4});5 6foreach ($guests as $guest) {7 // ...8}