I ran into a code in PHP, which has strange question mark operators. Since the code itself doesn't have any comments on that part, i tried to google it, but failed to succeed.
The code i'm interested in goes like:
<?php
class Cart
{
private $_user;
private $_items = [];
public function __construct(?User $user)
{
$this->_user = $user;
}
public function getUser(): ?User
{
return $this->_user;
}
My first thought was of type hinting, which was introduced in PHP 7, but it's apparently not the case, nor it is the strict type declaration. I've got no idea, what it is. Can you help me?