Could be written shorter as `$parent = $parent ?: 0;` i think?