Cannot use “parent” when no class scope is active

Description

parent is a keyword that represent the parent class of the current class. When the code is not located inside a class, it cannot have a parent, and so, is forbidden.

Example

<?php

function foo(parent $argument) { }

?>

Solutions

  • Convert the function into a method, in a class with a parent.

  • Convert the function into a closure, and assign it a to an object of a class with a parent.