1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<?php
// Enum
enum BasicSuit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
public function shape(): string
{
return "Rectangle"; // +1
}
}
enum BackedSuit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
BasicSuit::Diamonds->shape(); // +1
BackedSuit::Clubs; // +1
// Intersection types
interface MyIntersection
{
public function check(MyIntOne&MyIntTwo $intersection);
public function neverReturn(): never;
}
// New in initializers
class NewInInit_NoInit
{
public function __construct(private DateTimeInterface $dateTime) {
} // +3
public function noinit(DateTimeInterface $dateTime) {
} // +1
}
class NewInInit_OneLineNewLine
{
public function __construct(private DateTimeInterface $dateTime = new DateTime()) {
} // +1
public function onelinenewline(DateTimeInterface $dateTime = new DateTime()) {
} // +2
}
class NewInInit_OneLineSameLine
{
public function __construct(private DateTimeInterface $dateTime = new DateTime()) {} // +2
public function onelinesameline(DateTimeInterface $dateTime = new DateTime()) {} // +1
}
class NewInInit_MultiLine
{
public function __construct(
private
DateTimeInterface
$dateTime
=
new
DateTime()
,
private
bool
$var
=
true
)
{
} // +1
public function multiline(
DateTimeInterface $dateTime = new DateTime()
) {
} // +2
}
function newInInit_OneLineNewLine(DateTimeInterface $dateTime = new DateTime()) {
} // +2
function newInInit_OneLineSameLine(DateTimeInterface $dateTime = new DateTime()) {} // +2
function newInInit_multiline(
DateTimeInterface $dateTime = new DateTime()
) {
} // +1
|