repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/security/database/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/security/database/003.php | <?php
$query = "UPDATE usertable SET pwd='$pwd' WHERE uid='$uid';";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/security/database/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/security/database/000.php | <?php
// storing password hash
$query = sprintf(
"INSERT INTO users(name,pwd) VALUES('%s','%s');",
pg_escape_string($username),
password_hash($password, PASSWORD_DEFAULT)
);
$result = pg_query($connection, $query);
// querying if user submitted the right password
$query = sprintf(
"SELECT pwd FROM use... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/security/database/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/security/database/005.php | <?php
$query = "SELECT * FROM products WHERE id LIKE '%$prod%'";
$result = mssql_query($query);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/006.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/006.php | <?php
$suit = Suit::Clubs;
$ref = &$suit->value;
// Error: Cannot acquire reference to property Suit::$value
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/018.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/018.php | <?php
enum Foo
{
case Bar;
}
enum Baz: int
{
case Beep = 5;
}
print_r(Foo::Bar);
print_r(Baz::Beep);
/*
* Produces
*
* Foo Enum (
* [name] => Bar
* )
* Baz Enum:int {
* [name] => Beep
* [value] => 5
* }
*/
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/017.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/017.php | <?php
Suit::Hearts === unserialize(serialize(Suit::Hearts));
print serialize(Suit::Hearts);
// E:11:"Suit:Hearts";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/013.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/013.php | <?php
interface Colorful
{
public function color(): string;
}
trait Rectangle
{
public function shape(): string
{
return 'Rectangle';
}
}
enum Suit implements Colorful
{
use Rectangle;
case Hearts;
case Diamonds;
case Clubs;
case Spades;
public function color(): stri... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/004.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/004.php | <?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/022.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/022.php | <?php
enum SortOrder
{
case Asc;
case Desc;
}
function query($fields, $filter, SortOrder $order = SortOrder::Asc)
{
/* ... */
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/016.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/016.php | <?php
Suit::cases();
// Produces: [Suit::Hearts, Suit::Diamonds, Suit::Clubs, Suit::Spades]
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/001.php | <?php
function pick_a_card(Suit $suit)
{
/* ... */
}
$val = Suit::Diamonds;
// OK
pick_a_card($val);
// OK
pick_a_card(Suit::Clubs);
// TypeError: pick_a_card(): Argument #1 ($suit) must be of type Suit, string given
pick_a_card('Spades');
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/002.php | <?php
$a = Suit::Spades;
$b = Suit::Spades;
$a === $b; // true
$a instanceof Suit; // true
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/024.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/024.php | <?php
foreach (UserStatus::cases() as $case) {
printf('<option value="%s">%s</option>\n', $case->value, $case->label());
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/011.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/011.php | <?php
enum Size
{
case Small;
case Medium;
case Large;
public static function fromLength(int $cm): self
{
return match (true) {
$cm < 50 => self::Small,
$cm < 100 => self::Medium,
default => self::Large,
};
}
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/009.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/009.php | <?php
interface Colorful
{
public function color(): string;
}
enum Suit: string implements Colorful
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
// Fulfills the interface contract.
public function color(): string
{
return match ($this) {
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/020.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/020.php | <?php
enum ErrorCode
{
case SOMETHING_BROKE;
}
function quux(ErrorCode $errorCode)
{
// When written, this code appears to cover all cases
match ($errorCode) {
ErrorCode::SOMETHING_BROKE => true,
};
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/012.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/012.php | <?php
enum Size
{
case Small;
case Medium;
case Large;
public const Huge = self::Large;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/019.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/019.php | <?php
class A {}
class B extends A {}
function foo(A $a) {}
function bar(B $b)
{
foo($b);
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/014.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/014.php | <?php
// This is an entirely legal Enum definition.
enum Direction implements ArrayAccess
{
case Up;
case Down;
public function offsetExists($offset): bool
{
return false;
}
public function offsetGet($offset): mixed
{
return null;
}
public function offsetSet($offs... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/015.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/015.php | <?php
$clovers = new Suit();
// Error: Cannot instantiate enum Suit
$horseshoes = (new ReflectionClass(Suit::class))->newInstanceWithoutConstructor()
// Error: Cannot instantiate enum Suit
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/007.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/007.php | <?php
$record = get_stuff_from_database($id);
print $record['suit'];
$suit = Suit::from($record['suit']);
// Invalid data throws a ValueError: "X" is not a valid scalar value for enum "Suit"
print $suit->value;
$suit = Suit::tryFrom('A') ?? Suit::Spades;
// Invalid data returns null, so Suit::Spades is used instead.... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/010.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/010.php | <?php
interface Colorful
{
public function color(): string;
}
final class Suit implements UnitEnum, Colorful
{
public const Hearts = new self('Hearts');
public const Diamonds = new self('Diamonds');
public const Clubs = new self('Clubs');
public const Spades = new self('Spades');
private func... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/003.php | <?php
print Suit::Spades->name;
// prints "Spades"
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/023.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/023.php | <?php
enum UserStatus: string
{
case Pending = 'P';
case Active = 'A';
case Suspended = 'S';
case CanceledByUser = 'C';
public function label(): string
{
return match ($this) {
self::Pending => 'Pending',
self::Active => 'Active',
self::Suspended => ... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/008.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/008.php | <?php
interface Colorful
{
public function color(): string;
}
enum Suit implements Colorful
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
// Fulfills the interface contract.
public function color(): string
{
return match ($this) {
Suit::Hearts, Suit::Diamo... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/000.php | <?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/enumerations/005.php | <?php
print Suit::Clubs->value;
// Prints "C"
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/goto/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/goto/001.php | <?php
for ($i = 0, $j = 50; $i < 100; $i++) {
while ($j--) {
if ($j == 17) {
goto end;
}
}
}
echo "i = $i";
end:
echo 'j hit 17';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/goto/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/goto/002.php | <?php
goto loop;
for ($i = 0, $j = 50; $i < 100; $i++) {
while ($j--) {
loop:
}
}
echo "$i = $i";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/goto/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/goto/000.php | <?php
goto a;
echo 'Foo';
a:
echo 'Bar';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/continue/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/continue/001.php | <?php
$i = 0;
while ($i++ < 5) {
echo "Outer\n";
while (1) {
echo "Middle\n";
while (1) {
echo "Inner\n";
continue 3;
}
echo "This never gets output.\n";
}
echo "Neither does this.\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/continue/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/continue/002.php | <?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue print "$i\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/continue/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/continue/000.php | <?php
$arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'];
foreach ($arr as $key => $value) {
if (0 === ($key % 2)) { // skip members with even key
continue;
}
echo $value . "\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/006.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/006.php | <?php
$condition = 5;
try {
match ($condition) {
1, 2 => foo(),
3, 4 => bar(),
};
} catch (\UnhandledMatchError $e) {
var_dump($e);
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/004.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/004.php | <?php
$result = match ($x) {
// This match arm:
$a, $b, $c => 5,
// Is equivalent to these three match arms:
$a => 5,
$b => 5,
$c => 5,
};
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/001.php | <?php
$food = 'cake';
$return_value = match ($food) {
'apple' => 'This food is an apple',
'bar' => 'This food is a bar',
'cake' => 'This food is a cake',
};
var_dump($return_value);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/002.php | <?php
$age = 18;
$output = match (true) {
$age < 2 => 'Baby',
$age < 13 => 'Child',
$age <= 19 => 'Teenager',
$age >= 40 => 'Old adult',
$age > 19 => 'Young adult',
};
var_dump($output);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/007.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/007.php | <?php
$age = 23;
$result = match (true) {
$age >= 65 => 'senior',
$age >= 25 => 'adult',
$age >= 18 => 'young adult',
default => 'kid',
};
var_dump($result);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/003.php | <?php
$result = match ($x) {
foo() => 'value',
$this->bar() => 'value', // $this->bar() isn't called if foo() === $x
$this->baz => beep(), // beep() isn't called unless $x === $this->baz
// etc.
};
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/008.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/008.php | <?php
$text = 'Bienvenue chez nous';
$result = match (true) {
str_contains($text, 'Welcome'), str_contains($text, 'Hello') => 'en',
str_contains($text, 'Bienvenue'), str_contains($text, 'Bonjour') => 'fr',
// ...
};
var_dump($result);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/000.php | <?php
$return_value = match (subject_expression) {
single_conditional_expression => return_expression,
conditional_expression1, conditional_expression2 => return_expression,
};
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/match/005.php | <?php
$expressionResult = match ($condition) {
1, 2 => foo(),
3, 4 => bar(),
default => baz(),
};
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/break/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/break/000.php | <?php
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
foreach ($arr as $val) {
if ($val == 'stop') {
break; /* You could also write 'break 1;' here. */
}
echo "$val<br />\n";
}
/* Using the optional argument. */
$i = 0;
while (++$i) {
switch ($i) {
case 5:
ech... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/if/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/if/001.php | <?php
if ($a > $b) {
echo 'a is bigger than b';
$b = $a;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/if/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/if/000.php | <?php
if ($a > $b)
echo 'a is bigger than b';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/else/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/else/001.php | <?php
$a = false;
$b = true;
if ($a)
if ($b)
echo 'b';
else
echo 'c';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/else/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/else/000.php | <?php
if ($a > $b) {
echo 'a is greater than b';
} else {
echo 'a is NOT greater than b';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/elseif/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/elseif/002.php | <?php
/* Correct Method: */
if ($a > $b):
echo $a . ' is greater than ' . $b;
elseif ($a == $b): // Note the combination of the words.
echo $a . ' equals ' . $b;
else:
echo $a . ' is neither greater than or equal to ' . $b;
endif;
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/elseif/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/elseif/000.php | <?php
if ($a > $b) {
echo 'a is bigger than b';
} elseif ($a == $b) {
echo 'a is equal to b';
} else {
echo 'a is smaller than b';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/006.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/006.php | <?php
switch ($i):
case 0:
echo 'i equals 0';
break;
case 1:
echo 'i equals 1';
break;
case 2:
echo 'i equals 2';
break;
default:
echo 'i is not equal to 0, 1 or 2';
endswitch;
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/004.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/004.php | <?php
$target = 1;
$start = 3;
switch ($target) {
case $start - 1:
print 'A';
break;
case $start - 2:
print 'B';
break;
case $start - 3:
print 'C';
break;
case $start - 4:
print 'D';
break;
}
// Prints "B"
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/001.php | <?php
switch ($i) {
case 0:
echo 'i equals 0';
case 1:
echo 'i equals 1';
case 2:
echo 'i equals 2';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/002.php | <?php
switch ($i) {
case 0:
case 1:
case 2:
echo 'i is less than 3 but not negative';
break;
case 3:
echo 'i is 3';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/007.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/007.php | <?php
switch ($beer) {
case 'tuborg';
case 'carlsberg';
case 'stella';
case 'heineken';
echo 'Good choice';
break;
default;
echo 'Please make a new selection...';
break;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/003.php | <?php
switch ($i) {
case 0:
echo 'i equals 0';
break;
case 1:
echo 'i equals 1';
break;
case 2:
echo 'i equals 2';
break;
default:
echo 'i is not equal to 0, 1 or 2';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/000.php | <?php
// This switch statement:
switch ($i) {
case 0:
echo 'i equals 0';
break;
case 1:
echo 'i equals 1';
break;
case 2:
echo 'i equals 2';
break;
}
// Is equivalent to:
if ($i == 0) {
echo 'i equals 0';
} elseif ($i == 1) {
echo 'i equals 1';
} el... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/switch/005.php | <?php
$offset = 1;
$start = 3;
switch (true) {
case $start - $offset === 1:
print 'A';
break;
case $start - $offset === 2:
print 'B';
break;
case $start - $offset === 3:
print 'C';
break;
case $start - $offset === 4:
print 'D';
break;
}
/... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/while/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/while/000.php | <?php
/* example 1 */
$i = 1;
while ($i <= 10) {
echo $i++; /* the printed value would be
$i before the increment
(post-increment) */
}
/* example 2 */
$i = 1;
while ($i <= 10):
echo $i;
$i++;
endwhile;
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/004.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/004.php | return.php
<?php
$var = 'PHP';
return $var;
?>
noreturn.php
<?php
$var = 'PHP';
?>
testreturns.php
<?php
$foo = include 'return.php';
echo $foo; // prints 'PHP'
$bar = include 'noreturn.php';
echo $bar; // prints 1
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/001.php | <?php
function foo()
{
global $color;
include 'vars.php';
echo "A $color $fruit";
}
/*
* vars.php is in the scope of foo() so
* $fruit is NOT available outside of this
* scope. $color is because we declared it
* as global.
*/
foo(); // A green apple
echo "A $color $fruit"; // A green
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/002.php | <?php
/*
* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file.
*/
// Won't work; file.txt wasn't handled by www.example.com as PHP
include 'http://www.example.com/file.... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/003.php | <?php
// won't work, evaluated as include(('vars.php') == TRUE), i.e. include('1')
if (include ('vars.php') == TRUE) {
echo 'OK';
}
// works
if ((include 'vars.php') == TRUE) {
echo 'OK';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/000.php | vars.php
<?php
$color = 'green';
$fruit = 'apple';
?>
test.php
<?php
echo "A $color $fruit"; // A
include 'vars.php';
echo "A $color $fruit"; // A green apple
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/include/005.php | <?php
$string = get_include_contents('somefile.php');
function get_include_contents($filename)
{
if (is_file($filename)) {
ob_start();
include $filename;
return ob_get_clean();
}
return false;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/alternative-syntax/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/alternative-syntax/001.php | <?php
if ($a == 5):
echo 'a equals 5';
echo '...';
elseif ($a == 6):
echo 'a equals 6';
echo '!!!';
else:
echo 'a is neither 5 nor 6';
endif;
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/alternative-syntax/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/alternative-syntax/003.php | <?php switch ($foo): ?>
<?php case 1: ?>
...
<?php endswitch; ?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/alternative-syntax/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/alternative-syntax/000.php | <?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/for/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/for/001.php | <?php
/*
* This is an array with some data we want to modify
* when running through the for loop.
*/
$people = array(
array('name' => 'Kalle', 'salt' => 856412),
array('name' => 'Pierre', 'salt' => 215863)
);
for ($i = 0; $i < count($people); ++$i) {
$people[$i]['salt'] = mt_rand(0, 999999);
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/for/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/for/002.php | <?php
$people = array(
array('name' => 'Kalle', 'salt' => 856412),
array('name' => 'Pierre', 'salt' => 215863)
);
for ($i = 0, $size = count($people); $i < $size; ++$i) {
$people[$i]['salt'] = mt_rand(0, 999999);
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/for/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/for/000.php | <?php
/* example 1 */
for ($i = 1; $i <= 10; $i++) {
echo $i;
}
/* example 2 */
for ($i = 1;; $i++) {
if ($i > 10) {
break;
}
echo $i;
}
/* example 3 */
$i = 1;
for (;;) {
if ($i > 10) {
break;
}
echo $i;
$i++;
}
/* example 4 */
for ($i = 1, $j = 0; $i <= 10; $j +=... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/do-while/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/do-while/001.php | <?php
do {
if ($i < 5) {
echo 'i is not big enough';
break;
}
$i *= $factor;
if ($i < $minimum_limit) {
break;
}
echo 'i is ok';
/* process i */
} while (0);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/do-while/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/do-while/000.php | <?php
$i = 0;
do {
echo $i;
} while ($i > 0);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/001.php | <?php
// these are the same:
// you can use this:
declare(ticks=1) {
// entire script here
}
// or you can use this:
declare(ticks=1);
// entire script here
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/002.php | <?php
declare(ticks=1);
// A function called on each tick event
function tick_handler()
{
echo "tick_handler() called\n";
}
register_tick_function('tick_handler'); // causes a tick event
$a = 1; // causes a tick event
if ($a > 0) {
$a += 2; // causes a tick event
print $a; // causes a tick event
}
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/003.php | <?php
declare(encoding='ISO-8859-1');
// code here
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/declare/000.php | <?php
// This is valid:
declare(ticks=1);
// This is invalid:
const TICK_VALUE = 1;
declare(ticks=TICK_VALUE);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/006.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/006.php | <?php
foreach ([1, 2, 3, 4] as &$value) {
$value = $value * 2;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/004.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/004.php | <?php
$arr = [1, 2, 3, 4];
foreach ($arr as &$value) {
$value = $value * 2;
}
// $arr is now [2, 4, 6, 8]
unset($value); // break the reference with the last element
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/001.php | <?php
$array = [
[1, 2],
[3, 4],
];
foreach ($array as [$a, $b]) {
echo "A: $a; B: $b\n";
}
foreach ($array as list($a, $b)) {
echo "A: $a; B: $b\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/002.php | <?php
$array = [
[1, 2, 5],
[3, 4, 6],
];
foreach ($array as [$a, $b]) {
// Note that there is no $c here.
echo "$a $b\n";
}
foreach ($array as [,, $c]) {
// Skipping over $a and $b
echo "$c\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/003.php | <?php
$array = [
[1, 2],
[3, 4],
];
foreach ($array as [$a, $b, $c]) {
echo "A: $a; B: $b; C: $c\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/000.php | <?php
/* Example: value only */
$array = [1, 2, 3, 17];
foreach ($array as $value) {
echo "Current element of \$array: $value.\n";
}
/* Example: key and value */
$array = [
'one' => 1,
'two' => 2,
'three' => 3,
'seventeen' => 17
];
foreach ($array as $key => $value) {
echo "Key: $key => Valu... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/control-structures/foreach/005.php | <?php
$arr = [1, 2, 3, 4];
foreach ($arr as &$value) {
$value = $value * 2;
}
// $arr is now [2, 4, 6, 8]
// without an unset($value), $value is still a reference to the last item: $arr[3]
foreach ($arr as $key => $value) {
// $arr[3] will be updated with each value from $arr...
echo "{$key} => {$value} "... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/006.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/006.php | <?php
class SpecificException extends Exception {}
function test()
{
throw new SpecificException('Oopsie');
}
try {
test();
} catch (SpecificException) {
print "A SpecificException was thrown, but we don't care about the details.";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/004.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/004.php | <?php
class MyException extends Exception {}
class Test
{
public function testing()
{
try {
try {
throw new MyException('foo!');
} catch (MyException $e) {
// rethrow it
throw $e;
}
} catch (Exception $e) {
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/001.php | <?php
function inverse($x)
{
if (!$x) {
throw new Exception('Division by zero.');
}
return 1 / $x;
}
try {
echo inverse(5) . "\n";
echo inverse(0) . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Continue execution
echo "Hello World\n";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/002.php | <?php
function inverse($x)
{
if (!$x) {
throw new Exception('Division by zero.');
}
return 1 / $x;
}
try {
echo inverse(5) . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
} finally {
echo "First finally.\n";
}
try {
echo inverse(0) . "\n";
} cat... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/009.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/009.php | <?php
class Exception implements Throwable
{
protected $message = 'Unknown exception'; // exception message
private $string; // __toString cache
protected $code = 0; // user defined exception code
protected $file; // source filename of exception
protected $line; // source line of exception
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/007.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/007.php | <?php
function test()
{
do_something_risky() or throw new Exception('It did not work');
}
function do_something_risky()
{
return false; // Simulate failure
}
try {
test();
} catch (Exception $e) {
print $e->getMessage();
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/010.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/010.php | <?php
/**
* Define a custom exception class
*/
class MyException extends Exception
{
// Redefine the exception so message isn't optional
public function __construct($message, $code = 0, ?Throwable $previous = null)
{
// some code
// make sure everything is assigned properly
paren... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/003.php | <?php
function test()
{
try {
throw new Exception('foo');
} catch (Exception $e) {
return 'catch';
} finally {
return 'finally';
}
}
echo test();
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/008.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/008.php | <?php
try {
try {
throw new Exception(message: 'Third', previous: new Exception('Fourth'));
} finally {
throw new Exception(message: 'First', previous: new Exception('Second'));
}
} catch (Exception $e) {
var_dump(
$e->getMessage(),
$e->getPrevious()->getMessage(),
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/000.php | <?php
function exceptions_error_handler($severity, $message, $filename, $lineno)
{
throw new ErrorException($message, 0, $severity, $filename, $lineno);
}
set_error_handler('exceptions_error_handler');
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/005.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/exceptions/005.php | <?php
class MyException extends Exception {}
class MyOtherException extends Exception {}
class Test
{
public function testing()
{
try {
throw new MyException();
} catch (MyException | MyOtherException $e) {
var_dump(get_class($e));
}
}
}
$foo = new Test;
$... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/001.php | <?php
abstract class AbstractClass
{
// An abstract method only needs to define the required arguments
abstract protected function prefixName($name);
}
class ConcreteClass extends AbstractClass
{
// A child class may define optional parameters which are not present in the parent's signature
public fun... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/002.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/002.php | <?php
abstract class A
{
// Extending classes must have a publicly-gettable property
abstract public string $readable { get; }
// Extending classes must have a protected- or public-writeable property
abstract protected string $writeable { set; }
// Extending classes must have a protected or publi... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/003.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/003.php | <?php
abstract class A
{
// This provides a default (but overridable) set implementation,
// and requires child classes to provide a get implementation
abstract public string $foo {
get;
set {
$this->foo = $value;
}
}
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/abstract/000.php | <?php
abstract class AbstractClass
{
// Force extending class to define this method
abstract protected function getValue();
abstract protected function prefixValue($prefix);
// Common method
public function printOut()
{
print $this->getValue() . "\n";
}
}
class ConcreteClass1 exte... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/static/001.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/static/001.php | <?php
class Foo
{
public static $my_static = 'foo';
public function staticValue()
{
return self::$my_static;
}
}
class Bar extends Foo
{
public function fooStatic()
{
return parent::$my_static;
}
}
print Foo::$my_static . "\n";
$foo = new Foo();
print $foo->staticValue()... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/static/000.php | tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/static/000.php | <?php
class Foo
{
public static function aStaticMethod()
{
// ...
}
}
Foo::aStaticMethod();
$classname = 'Foo';
$classname::aStaticMethod();
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.