Constructor property promotion
Constructor property promotion combines a constructor parameter with a property declaration using a visibility modifier.
CKTIS / PHP
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Constructor property promotion combines a constructor parameter with a property declaration using a visibility modifier.
A foreach by-reference binding and lingering reference let the loop variable alias each array element in turn, and then the last visited element after a nonempty loop.
Reference assignment (= &) makes two names refer to the same variable.
Pass-by-reference parameters put the ampersand in the declaration and bind the parameter to an argument variable.
Returning by reference places & before the function name and returns a variable that a caller can alias using =&.
An array is an ordered map whose keys are integers or strings.
A boolean stores true or false.
A callable parameter accepts something that PHP can invoke, such as a closure or a public method paired with an object.
The literal type false describes exactly the boolean value false, for example a disabled flag.
A float represents a floating-point number with finite precision.
An integer is a signed whole number within platform-dependent limits.
An iterable parameter accepts an array or an object implementing Traversable.
The mixed declaration explicitly accepts all PHP values, including null, resources and objects.
A never return type promises that no normal return occurs.
The null type has exactly one value, null.
The object declaration accepts any object, without guaranteeing that a particular method or property exists.
Inside a derived class, parent denotes its direct base class in a type declaration.
A resource is a runtime handle managed by an extension, such as an open stream.
Within a class, self in a type declaration refers to the declaring class.
A static return type is tied to the class through which the method is called.
A PHP string is a sequence of bytes and can contain a zero byte.
The literal type true denotes exactly the boolean value true.
A void return declaration describes a procedure called for its effects.
The superglobal $GLOBALS exposes global variables under their string names from any scope.