Created
November 19, 2024 19:53
-
-
Save ryangjchandler/2ecb065b77e467e784e6da8dd76a069c to your computer and use it in GitHub Desktop.
Big ol' PHP file
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 | |
// A PHP file containing a variety of PHP features for testing purposes. | |
namespace App { | |
use namespace\Meta\AbstractClass; | |
trait Composition { | |
public function foo() { | |
} | |
} | |
trait CompositionTwo { | |
public function foo() { | |
} | |
} | |
}; | |
namespace App\Meta { | |
use App\Composition; | |
use App\CompositionTwo; | |
interface Contract { | |
} | |
abstract class AbstractClass { | |
} | |
final class ConcreteClass extends AbstractClass implements Contract { | |
use Composition, CompositionTwo { | |
Composition::foo insteadof CompositionTwo; | |
} | |
private public(set) $a = 1; | |
} | |
enum Role { | |
case Admin; | |
case User; | |
} | |
}; | |
namespace { | |
use App\Meta\ConcreteClass; | |
function foo() { | |
} | |
const BAR = 1; | |
$a = 1; | |
$b = $a + 2; | |
$c = $b * 3; | |
$d = $c / 4; | |
$e = $d % 5; | |
$f = $e ** 6; | |
$g = $f << 7; | |
$h = $g >> 8; | |
$i = $h & 9; | |
$j = $i | 10; | |
$k = $j ^ 11; | |
$l = $k ?? 12; | |
$m = $l . 13; | |
$n = $m instanceof \App\Meta\Contract; | |
$o = $n ? 14 : 15; | |
$p = $o ?: 16; | |
$q = $p and 17; | |
$r = $q or 18; | |
$s = $r xor 19; | |
$t = $s && 20; | |
$u = $t || 21; | |
$v ??= $u; | |
$w = $v += 23; | |
$x = $w -= 24; | |
$y = $x *= 25; | |
$z = $y /= 26; | |
$aa = $z %= 27; | |
$ab = $aa **= 28; | |
$ac = $ab <<= 29; | |
$ad = $ac >>= 30; | |
$ae = $ad &= 31; | |
$af = $ae |= 32; | |
$ag = $af ^= 33; | |
$ah = $ag ??= 34; | |
$ai = $ah .= 35; | |
'Hello, world!'; | |
"Hello, world!"; | |
$name = "Ryan"; | |
"Hello, {$name}"; | |
<<<'EOF' | |
Hello, world! | |
EOF; | |
<<<EOF | |
Hello, {$name}! | |
EOF; | |
$array = [1, 2, 3]; | |
foreach ($array as $value) { | |
echo $value; | |
} | |
foreach ($array as $key => $value) { | |
echo $key . $value; | |
} | |
for ($i = 0; $i < 10; $i++) { | |
echo $i; | |
} | |
while (true) { | |
echo 'Hello, world!'; | |
} | |
do { | |
echo 'Hello, world!'; | |
} while (true); | |
if (true) { | |
echo 'Hello, world!'; | |
} elseif (false) { | |
echo 'Goodbye, world!'; | |
} else { | |
echo 'Goodbye, world!'; | |
} | |
switch ($name) { | |
case 'Ryan': | |
echo 'Hello, Ryan!'; | |
break; | |
case 'John': | |
echo 'Hello, John!'; | |
break; | |
default: | |
echo 'Hello, world!'; | |
break; | |
} | |
function bar($a, $b, $c = 1, $d = 2) { | |
return $a + $b + $c + $d; | |
} | |
bar(1, 2); | |
$closure = function ($a, $b) { | |
return $a + $b; | |
}; | |
$closure(1, 2); | |
$closure = static fn ($a, $b) => $a + $b; | |
$closure(1, 2); | |
$closure = fn ($a, $b) => $a + $b; | |
$closure(1, 2); | |
match ($name) { | |
'Ryan' => 'Hello, Ryan!', | |
'John' => 'Hello, John!', | |
default => 'Hello, world!', | |
}; | |
$object = new \App\Meta\ConcreteClass(); | |
$object->foo(); | |
$object?->foo(); | |
ConcreteClass::class; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment