@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP
Sponsored developers
@brisphp1
https://brisphp.com
#BrisPHP
Next goals
@brisphp1
https://brisphp.com
#BrisPHP
class User {}
interface UserFinder
{
function findUserByEmail(): User|null;
}
class AlwaysNullUserFinder implements UserFinder
{
function findUserByEmail(): null
{
return null;
}
}
@brisphp1
https://brisphp.com
#BrisPHP
class Trade {}
class Project {
/** @var Trade[] */
public array $trades;
}
interface ProjectRelatedInterface
{
function getProject(): Project;
function getTrade(): Trade|null;
}
class EditProjectEvent implement ProjectRelatedInterface {
public function getProject(): Project {...}
public function getTrade(): null {return null}
}
@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP
// Some callables are supported by call_user_func()
// but not $callable()
// Change to the following syntax
"self::method" -> self::class . "::method"
"parent::method" -> parent::class . "::method"
"static::method" -> static::class . "::method"
["self", "method"] -> [self::class, "method"]
["parent", "method"] -> [parent::class, "method"]
["static", "method"] -> [static::class, "method"]
// Can also use PHP 8.1 syntax
self::method(...)
@brisphp1
https://brisphp.com
#BrisPHP
class User {
public $name;
}
$user = new User;
// Assigns declared property User::$name.
$user->name = "foo";
// Oops, a typo:
$user->nane = "foo";
// PHP <= 8.1: Silently creates dynamic property.
// PHP 8.2: Raises deprecation warning
// PHP 9.0: Throws Error exception.
// Add #[AllowDynamicProperties] if necessary
@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP
if ($user->admin) {
$restricted = false;
}
// Oops, not defined
if ($restricted) {
die('You do not have permission to be here');
}
$name = 'Joe';
// Oops, typo
echo 'Welcome, ' . $naame;
@brisphp1
https://brisphp.com
#BrisPHP
@brisphp1
https://brisphp.com
#BrisPHP