3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait PropertyHelperTrait { protected function splitPropertyParts(): void { } } trait OrmPropertyHelperTrait { abstract protected function splitPropertyParts(): void; protected function addJoinsForNestedProperty(): void { $this->splitPropertyParts(); } } trait SearchFilterTrait { use PropertyHelperTrait; } abstract class AbstractFilter { use OrmPropertyHelperTrait, PropertyHelperTrait; public function apply(): void { $this->filterProperty(); } abstract protected function filterProperty(): void; } class SearchFilter extends AbstractFilter { use SearchFilterTrait; protected function filterProperty(): void { $this->addJoinsForNestedProperty(); } } class FilterExtension { public function applyToCollection(): void { (new SearchFilter())->apply(); } } (new FilterExtension)->applyToCollection();
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.19, 8.2.21 - 8.2.29, 8.3.0 - 8.3.7, 8.3.9 - 8.3.25, 8.4.1 - 8.4.12
Output for 8.2.20, 8.3.8
Fatal error: Uncaught Error: Call to protected method SearchFilter::splitPropertyParts() from scope AbstractFilter in /in/ZsLJ0:16 Stack trace: #0 /in/ZsLJ0(42): AbstractFilter->addJoinsForNestedProperty() #1 /in/ZsLJ0(31): SearchFilter->filterProperty() #2 /in/ZsLJ0(50): AbstractFilter->apply() #3 /in/ZsLJ0(54): FilterExtension->applyToCollection() #4 {main} thrown in /in/ZsLJ0 on line 16
Process exited with code 255.

preferences:
69.01 ms | 407 KiB | 5 Q