This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface UserInterface {} | |
final class RegularWebUser implements UserInterface {} | |
final class AdminUser implements UserInterface {} | |
final class PowerAdminUser implements UserInterface {} | |
final class WipFunctionalityUser implements UserInterface {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class BaseUser {} | |
abstract class WebUser extends BaseUser {} | |
class RegularUser extends WebUser {} | |
class AdminUser extends RegularUser {} | |
class PowerAdminUser extends RegularUser {} | |
class WipFunctionalityUser extends RegularUser {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types); | |
namespace ${NAMESPACE}; | |
final class ${NAME} | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User { | |
/** | |
* @return self::STATUS_* | |
*/ | |
public function getStatus(): string | |
{ | |
return $this->status; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User { | |
public const STATUS_NEW = 'new'; | |
public const STATUS_ACTIVE = 'active'; | |
public const STATUS_BLOCKED = 'blocked'; | |
private string $status = self::STATUS_NEW; | |
private int $age; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function act(bool $success) | |
{ | |
if ($success) { | |
// towering block of code | |
// towering block of code | |
// towering block of code | |
// towering block of code | |
// towering block of code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function act(bool $success) | |
{ | |
if (!$success) { | |
// one liner | |
return; | |
} | |
// towering block of code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$workers = [ | |
['id' => 1, 'name' => 'John Doe'], | |
['id' => 3, 'name' => 'Jane Doe'], | |
['id' => 4, 'name' => 'Monica Trullo'], | |
['id' => 5, 'name' => 'Jonathan Bank'], | |
]; | |
foreach ($workers as ['id' => $workerId, 'name' => $workerName]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$workers = [ | |
['id' => 1, 'name' => 'John Doe'], | |
['id' => 3, 'name' => 'Jane Doe'], | |
['id' => 4, 'name' => 'Monica Trullo'], | |
['id' => 5, 'name' => 'Jonathan Bank'], | |
]; | |
foreach ($workers as $worker) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @return array{total: float, items: array<array{id: int, name: string}>} | |
*/ | |
function basketToViewModel(Basket $basket): array | |
{ | |
// function body skipped for brevity | |
// output annotations especially useful if using tools like PsalmPHP |