Try these: PHP 7.4 Typed Properties create_function() Early Return Null Coalescing


Result

 <?php
 
 class SomeClass
 {
-    public function run()
-    {
-        if (null !== $this->orderItem) {
-            return $this->orderItem;
-        }
-
-        if (null !== $this->orderItemUnit) {
-            return $this->orderItemUnit;
-        }
-
-        return null;
+    public function run()
+    {
+        return $this->orderItem ?? $this->orderItemUnit;
     }
 }