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/language/oop5/constants/005.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/constants/005.php
<?php class Foo { public const BAR = 'bar'; private const BAZ = 'baz'; } $name = 'BAR'; echo Foo::{$name}, PHP_EOL; // 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/oop5/traits/006.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/006.php
<?php trait Hello { public function sayHello() { echo 'Hello '; } } trait World { public function sayWorld() { echo 'World!'; } } trait HelloWorld { use Hello, World; } class MyHelloWorld { use HelloWorld; } $o = new MyHelloWorld(); $o->sayHello(); $o->sayWorld(); ?>
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/traits/013.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/013.php
<?php trait ConstantsTrait { public const FLAG_MUTABLE = 1; final public const FLAG_IMMUTABLE = 5; } class ConstantsExample { use ConstantsTrait; } $example = new ConstantsExample; echo $example::FLAG_MUTABLE; ?>
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/traits/004.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/004.php
<?php trait A { public function smallTalk() { echo 'a'; } public function bigTalk() { echo 'A'; } } trait B { public function smallTalk() { echo 'b'; } public function bigTalk() { echo 'B'; } } class Talker { use A, B { 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/oop5/traits/001.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/001.php
<?php class Base { public function sayHello() { echo 'Hello '; } } trait SayWorld { public function sayHello() { parent::sayHello(); echo 'World!'; } } class MyHelloWorld extends Base { use SayWorld; } $o = new MyHelloWorld(); $o->sayHello(); ?>
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/traits/002.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/002.php
<?php trait HelloWorld { public function sayHello() { echo 'Hello World!'; } } class TheWorldIsNotEnough { use HelloWorld; public function sayHello() { echo 'Hello Universe!'; } } $o = new TheWorldIsNotEnough(); $o->sayHello(); ?>
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/traits/011.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/011.php
<?php trait PropertiesTrait { public $x = 1; } class PropertiesExample { use PropertiesTrait; } $example = new PropertiesExample(); $example->x; ?>
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/traits/009.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/009.php
<?php trait StaticExample { public static function doSomething() { return 'Doing something'; } } class Example { use StaticExample; } echo Example::doSomething(); ?>
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/traits/012.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/012.php
<?php trait PropertiesTrait { public $same = true; public $different1 = false; public bool $different2; public bool $different3; } class PropertiesExample { use PropertiesTrait; public $same = true; public $different1 = true; // Fatal error public string $different2; // Fatal error ...
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/traits/014.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/014.php
<?php trait ConstantsTrait { public const FLAG_MUTABLE = 1; final public const FLAG_IMMUTABLE = 5; } class ConstantsExample { use ConstantsTrait; public const FLAG_IMMUTABLE = 5; // Fatal error } ?>
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/traits/015.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/015.php
<?php trait CommonTrait { public function method() { echo 'Hello'; } } class FinalExampleA { use CommonTrait { CommonTrait::method as final; // The 'final' prevents child classes from overriding the method } } class FinalExampleB extends FinalExampleA { public function method...
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/traits/007.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/007.php
<?php trait Hello { public function sayHelloWorld() { echo 'Hello' . $this->getWorld(); } abstract public function getWorld(); } class MyHelloWorld { private $world; use Hello; public function getWorld() { return $this->world; } public function setWorld($val...
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/traits/010.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/010.php
<?php trait T { public static $counter = 1; } class A { use T; public static function incrementCounter() { static::$counter++; } } class B extends A { use T; } A::incrementCounter(); echo A::$counter, "\n"; echo B::$counter, "\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/oop5/traits/003.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/003.php
<?php trait Hello { public function sayHello() { echo 'Hello '; } } trait World { public function sayWorld() { echo 'World'; } } class MyHelloWorld { use Hello, World; public function sayExclamationMark() { echo '!'; } } $o = new MyHelloWorld(); $o->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/oop5/traits/008.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/008.php
<?php trait Counter { public function inc() { static $c = 0; $c = $c + 1; echo "$c\n"; } } class C1 { use Counter; } class C2 { use Counter; } $o = new C1(); $o->inc(); $p = new C2(); $p->inc(); ?>
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/traits/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/000.php
<?php trait TraitA { public function sayHello() { echo 'Hello'; } } trait TraitB { public function sayWorld() { echo 'World'; } } class MyHelloWorld { use TraitA, TraitB; // A class can use multiple traits public function sayHelloWorld() { $this->sayHello...
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/traits/005.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/traits/005.php
<?php trait HelloWorld { public function sayHello() { echo 'Hello World!'; } } // Change visibility of sayHello class MyClass1 { use HelloWorld { sayHello as protected; } } // Alias method with changed visibility // sayHello visibility not changed class MyClass2 { use HelloWor...
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/property-hooks/006.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/006.php
<?php class Example { public string $foo { get { $temp = __PROPERTY__; return $this->$temp; // Doesn't refer to $this->foo, so it doesn't count. } } } ?>
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/property-hooks/004.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/004.php
<?php class Example { public function __construct( public private(set) DateTimeInterface $created { set (string|DateTimeInterface $value) { if (is_string($value)) { $value = new DateTimeImmutable($value); } $this->created = $va...
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/property-hooks/001.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/001.php
<?php class Example { private bool $modified = false; public string $foo = 'default value' { get => $this->foo . ($this->modified ? ' (modified)' : ''); set (string $value) { $this->foo = strtolower($value); $this->modified = 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/oop5/property-hooks/002.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/002.php
<?php class Example { private bool $modified = false; public string $foo = 'default value' { get => $this->foo . ($this->modified ? ' (modified)' : ''); set { $this->foo = strtolower($value); $this->modified = 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/oop5/property-hooks/011.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/011.php
<?php class Point { public int $x; public int $y; } class PositivePoint extends Point { public int $x { set { if ($value < 0) { throw new \InvalidArgumentException('Too small'); } parent::$x::set($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/property-hooks/009.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/009.php
<?php class User { public string $username { final set => strtolower($value); } } class Manager extends User { public string $username { // This is allowed get => strtoupper($this->username); // But this is NOT allowed, because set is final in the parent. set => str...
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/property-hooks/012.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/012.php
<?php class Strings { public string $val; } class CaseFoldingStrings extends Strings { public bool $uppercase = true; public string $val { get => $this->uppercase ? strtoupper(parent::$val::get()) : strtolower(parent::$val::get()); } } ?>
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/property-hooks/007.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/007.php
<?php class Rectangle { // A virtual property. public int $area { get => $this->h * $this->w; } public function __construct( public int $h, public int $w ) {} } $s = new Rectangle(4, 5); print $s->area; // prints 20 $s->area = 30; // Error, as there is no set operation d...
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/property-hooks/010.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/010.php
<?php class Point { public int $x; public int $y; } class PositivePoint extends Point { public int $x { set { if ($value < 0) { throw new \InvalidArgumentException('Too small'); } $this->x = $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/property-hooks/003.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/003.php
<?php class Example { public string $foo = 'default value' { get => $this->foo . ($this->modified ? ' (modified)' : ''); set => strtolower($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/property-hooks/008.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/008.php
<?php class Person { public string $phone { set => $this->sanitizePhone($value); } private function sanitizePhone(string $value): string { $value = ltrim($value, '+'); $value = ltrim($value, '1'); if (!preg_match('/\d\d\d\-\d\d\d\-\d\d\d\d/', $value)) { thr...
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/property-hooks/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/000.php
<?php class Example { private bool $modified = false; public string $foo = 'default value' { get { if ($this->modified) { return $this->foo . ' (modified)'; } return $this->foo; } set (string $value) { $this->foo = strtolo...
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/property-hooks/005.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/property-hooks/005.php
<?php class Example { public private(set) DateTimeInterface $created { set (string|DateTimeInterface $value) { if (is_string($value)) { $value = new DateTimeImmutable($value); } $this->created = $value; } } public function __construct( ...
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/serialization/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/serialization/000.php
<?php // A.php: class A { public $one = 1; public function show_one() { echo $this->one; } } // page1.php: include 'A.php'; $a = new A; $s = serialize($a); // store $s somewhere where page2.php can find it. file_put_contents('store', $s); // page2.php: // this is needed for the unserializ...
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/object-comparison/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/object-comparison/000.php
<?php function bool2str($bool) { if ($bool === false) { return 'FALSE'; } else { return 'TRUE'; } } function compareObjects(&$o1, &$o2) { echo 'o1 == o2 : ' . bool2str($o1 == $o2) . "\n"; echo 'o1 != o2 : ' . bool2str($o1 != $o2) . "\n"; echo 'o1 === o2 : ' . bool2str($o1 === $...
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/final/001.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/final/001.php
<?php final class BaseClass { public function test() { echo "BaseClass::test() called\n"; } // As the class is already final, the final keyword is redundant final public function moreTesting() { echo "BaseClass::moreTesting() called\n"; } } class ChildClass extends BaseCla...
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/final/002.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/final/002.php
<?php class BaseClass { final protected string $test; } class ChildClass extends BaseClass { public string $test; } // Results in Fatal error: Cannot override final property BaseClass::$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/final/003.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/final/003.php
<?php class Foo { final public const X = 'foo'; } class Bar extends Foo { public const X = 'bar'; } // Fatal error: Bar::X cannot override final constant Foo::X ?>
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/final/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/oop5/final/000.php
<?php class BaseClass { public function test() { echo "BaseClass::test() called\n"; } final public function moreTesting() { echo "BaseClass::moreTesting() called\n"; } } class ChildClass extends BaseClass { public function moreTesting() { echo "ChildClass::more...
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/variables/028.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/028.php
<?php if (isset($_COOKIE['count'])) { $count = $_COOKIE['count'] + 1; } else { $count = 1; } setcookie('count', $count, time() + 3600); setcookie("Cart[$count]", $item, time() + 3600); ?>
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/variables/006.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/006.php
<?php $unset_array[] = 'value'; // Does not generate a warning. ?>
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/variables/018.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/018.php
<?php function test_global_ref() { global $obj; $new = new stdClass; $obj = &$new; } function test_global_noref() { global $obj; $new = new stdClass; $obj = $new; } test_global_ref(); var_dump($obj); test_global_noref(); var_dump($obj); ?>
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/variables/017.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/017.php
<?php class Foo { public static function counter() { static $counter = 0; $counter++; return $counter; } } class Bar extends Foo {} var_dump(Foo::counter()); // int(1) var_dump(Foo::counter()); // int(2) var_dump(Bar::counter()); // int(3), prior to PHP 8.1.0 int(1) var_dump(Ba...
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/variables/013.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/013.php
<?php function test() { static $a = 0; echo $a; $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/variables/022.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/022.php
<?php echo "$a {$$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/variables/016.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/016.php
<?php function exampleFunction($input) { $result = (static function () use ($input) { static $counter = 0; $counter++; return "Input: $input, Counter: $counter\n"; }); return $result(); } // Calls to exampleFunction will recreate the anonymous function, so the static // variable d...
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/variables/002.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/002.php
<?php ${'invalid-name'} = 'bar'; $name = 'invalid-name'; echo ${'invalid-name'}, ' ', $$name; ?>
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/variables/025.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/025.php
<?php echo $_POST['username']; echo $_REQUEST['username']; ?>
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/variables/024.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/024.php
<?php class Foo { public $bar = 'I am bar.'; public $arr = ['I am A.', 'I am B.', 'I am C.']; public $r = 'I am r.'; } $foo = new Foo(); $bar = 'bar'; $baz = ['foo', 'bar', 'baz', 'quux']; echo $foo->$bar . "\n"; echo $foo->{$baz[1]} . "\n"; $start = 'b'; $end = 'ar'; echo $foo->{$start . $end} . "\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/variables/011.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/011.php
<?php function test_superglobal() { echo $_POST['name']; } ?>
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/variables/009.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/009.php
<?php $a = 1; $b = 2; function Sum() { global $a, $b; $b = $a + $b; } Sum(); echo $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/variables/020.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/020.php
<?php $a = 'hello'; ?>
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/variables/029.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/029.php
<?php $varname . ext; /* invalid variable name */ ?>
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/variables/012.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/012.php
<?php function test() { $a = 0; echo $a; $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/variables/019.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/019.php
<?php function &get_instance_ref() { static $obj; echo 'Static object: '; var_dump($obj); if (!isset($obj)) { $new = new stdClass; // Assign a reference to the static variable $obj = &$new; } if (!isset($obj->property)) { $obj->property = 1; } else { ...
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/variables/014.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/014.php
<?php function test() { static $count = 0; $count++; echo $count; if ($count < 10) { test(); } $count--; } ?>
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/variables/015.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/015.php
<?php function foo() { static $int = 0; // correct static $int = 1 + 2; // correct static $int = sqrt(121); // correct as of PHP 8.3.0 $int++; echo $int; } ?>
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/variables/007.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/007.php
<?php $a = 1; include 'b.inc'; // Variable $a will be available within b.inc ?>
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/variables/010.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/010.php
<?php $a = 1; $b = 2; function Sum() { $GLOBALS['b'] = $GLOBALS['a'] + $GLOBALS['b']; } Sum(); echo $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/variables/003.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/003.php
<?php $foo = 'Bob'; // Assign the value 'Bob' to $foo $bar = &$foo; // Reference $foo via $bar. $bar = "My name is $bar"; // Alter $bar... echo $bar; echo $foo; // $foo is altered too. ?>
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/variables/023.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/023.php
<?php echo "$a $hello"; ?>
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/variables/026.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/026.php
<?php if ($_POST) { echo '<pre>'; echo htmlspecialchars(print_r($_POST, true)); echo '</pre>'; } ?> <form action="" method="post"> Name: <input type="text" name="personal[name]" /><br /> Email: <input type="text" name="personal[email]" /><br /> Beer: <br /> <select multiple name="beer[]"> ...
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/variables/008.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/008.php
<?php $a = 1; // global scope function test() { echo $a; // Variable $a is undefined as it refers to a local version of $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/variables/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/000.php
<?php $var = 'Bob'; $Var = 'Joe'; echo "$var, $Var"; // outputs "Bob, Joe" $_4site = 'not yet'; // valid; starts with an underscore $täyte = 'mansikka'; // valid; 'ä' is (Extended) ASCII 228. ?>
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/variables/005.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/005.php
<?php // Unset AND unreferenced (no use context) variable. var_dump($unset_var); ?>
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/variables/027.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/027.php
<?php setcookie('MyCookie[foo]', 'Testing 1', time() + 3600); setcookie('MyCookie[bar]', 'Testing 2', time() + 3600); ?>
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/variables/021.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/variables/021.php
<?php $$a = 'world'; ?>
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/references/006.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/006.php
<?php /* Assignment of scalar variables */ $a = 1; $b = &$a; $c = $b; $c = 7; // $c is not a reference; no change to $a or $b /* Assignment of array variables */ $arr = array(1); $a = &$arr[0]; // $a and $arr[0] are in the same reference set $arr2 = $arr; // Not an assignment-by-reference! $arr2[0]++; /* $a == 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/references/013.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/013.php
<?php function &collector() { static $collection = array(); return $collection; } $collection = &collector(); // Now the $collection is a referenced variable that references the static array inside the function $collection[] = 'foo'; print_r(collector()); // Array // ( // [0] => foo // ) ?>
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/references/004.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/004.php
<?php $ref = 0; $row = &$ref; foreach (array(1, 2, 3) as $row) { // Do something } echo $ref; // 3 - last element of the iterated array ?>
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/references/016.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/016.php
<?php $var = &$GLOBALS['var']; ?>
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/references/001.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/001.php
<?php function foo(&$var) {} foo($a); // $a is "created" and assigned to null $b = array(); foo($b['b']); var_dump(array_key_exists('b', $b)); // bool(true) $c = new stdClass(); foo($c->d); var_dump(property_exists($c, 'd')); // bool(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/references/002.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/002.php
<?php $foo = &find_var($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/references/011.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/011.php
<?php function foo(&$var) { $var++; } function bar() // Note the missing & { $a = 5; return $a; } foo(bar()); // Produces a notice foo($a = 5); // Expression, not variable foo(5); // Produces fatal error class Foobar {} foo(new Foobar()) // Produces a notice as of PHP 7.0.7 // Notice: Only variab...
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/references/009.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/009.php
<?php function foo(&$var) { $var++; } $a = 5; foo($a); // $a is 6 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/references/012.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/012.php
<?php class Foo { public $value = 42; public function &getValue() { return $this->value; } } $obj = new Foo(); $myValue = &$obj->getValue(); // $myValue is a reference to $obj->value, which is 42 $obj->value = 2; echo $myValue; // Prints the new value of $obj->value, i.e. 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/references/014.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/014.php
<?php function &collector() { static $collection = array(); return $collection; } array_push(collector(), 'foo'); ?>
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/references/015.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/015.php
<?php $a = 1; $b = &$a; unset($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/references/007.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/007.php
<?php function foo(&$var) { $var++; } $a = 5; foo($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/references/010.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/010.php
<?php function foo(&$var) { $var++; } function &bar() { $a = 5; return $a; } foo(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/references/003.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/003.php
<?php $var1 = 'Example variable'; $var2 = ''; function global_references($use_globals) { global $var1, $var2; if (!$use_globals) { $var2 = &$var1; // visible only inside the function } else { $GLOBALS['var2'] = &$var1; // visible also in global context } } global_references(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/references/008.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/008.php
<?php function foo(&$var) { $var = &$GLOBALS['baz']; } foo($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/references/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/000.php
<?php $a = &$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/references/005.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/references/005.php
<?php $a = 1; $b = array(2, 3); $arr = array(&$a, &$b[0], &$b[1]); $arr[0]++; $arr[1]++; $arr[2]++; /* $a == 2, $b == array(3, 4); */ ?>
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/generators/006.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/006.php
<?php function count_to_ten() { yield 1; yield 2; yield from [3, 4]; yield from new ArrayIterator([5, 6]); yield from seven_eight(); yield 9; yield 10; } function seven_eight() { yield 7; yield from eight(); } function eight() { yield 8; } foreach (count_to_ten() as $num) { ...
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/generators/004.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/004.php
<?php function &gen_reference() { $value = 3; while ($value > 0) { yield $value; } } /* * Note that we can change $number within the loop, and * because the generator is yielding references, $value * within gen_reference() changes. */ foreach (gen_reference() as &$number) { echo (--$numbe...
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/generators/001.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/001.php
<?php function gen_one_to_three() { for ($i = 1; $i <= 3; $i++) { // Note that $i is preserved between yields. yield $i; } } $generator = gen_one_to_three(); foreach ($generator as $value) { 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/generators/002.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/002.php
<?php /* * The input is semi-colon separated fields, with the first * field being an ID to use as a key. */ $input = <<<'EOF' 1;PHP;Likes dollar signs 2;Python;Likes whitespace 3;Ruby;Likes blocks EOF; function input_parser($input) { foreach (explode("\n", $input) as $line) { $fields =...
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/generators/007.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/007.php
<?php function count_to_ten() { yield 1; yield 2; yield from [3, 4]; yield from new ArrayIterator([5, 6]); yield from seven_eight(); return yield from nine_ten(); } function seven_eight() { yield 7; yield from eight(); } function eight() { yield 8; } function nine_ten() { yie...
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/generators/003.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/003.php
<?php function gen_three_nulls() { foreach (range(1, 3) as $i) { yield; } } var_dump(iterator_to_array(gen_three_nulls())); ?>
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/generators/008.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/008.php
<?php function getLinesFromFile($fileName) { if (!$fileHandle = fopen($fileName, 'r')) { return; } while (false !== $line = fgets($fileHandle)) { yield $line; } fclose($fileHandle); } // versus... class LineIterator implements Iterator { protected $fileHandle; protected...
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/generators/000.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/000.php
<?php function xrange($start, $limit, $step = 1) { if ($start <= $limit) { if ($step <= 0) { throw new LogicException('Step must be positive'); } for ($i = $start; $i <= $limit; $i += $step) { yield $i; } } else { if ($step >= 0) { th...
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/generators/005.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/generators/005.php
<?php function inner() { yield 1; // key 0 yield 2; // key 1 yield 3; // key 2 } function gen() { yield 0; // key 0 yield from inner(); // keys 0-2 yield 4; // key 1 } // pass false as second parameter to get an array [0, 1, 2, 3, 4] var_dump(iterator_to_array(gen())); ?>
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/namespaces/028.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/028.php
<?php $a = new \stdClass; ?>
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/namespaces/031.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/031.php
<?php namespace foo; class MyClass {} // using a class from the current namespace as a parameter type function test(MyClass $parameter_type_example = null) {} // another way to use a class from the current namespace as a parameter type function test(\foo\MyClass $parameter_type_example = null) {} // extending a cla...
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/namespaces/006.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/006.php
<?php namespace MyProject { const CONNECT_OK = 1; class Connection { /* ... */ } function connect() { /* ... */ } } namespace { // global code session_start(); $a = MyProject\connect(); echo MyProject\Connection::start(); } ?>
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/namespaces/018.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/018.php
<?php namespace foo; use My\Full\Classname as Another; // this is the same as use My\Full\NSname as NSname use My\Full\NSname; // importing a global class use ArrayObject; // importing a function use function My\Full\functionName; // aliasing a function use function My\Full\functionName as func; // importing a cons...
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/namespaces/017.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/017.php
<?php namespace\func(); // calls function func() namespace\sub\func(); // calls function sub\func() namespace\cname::method(); // calls static method "method" of class cname $a = new namespace\sub\cname(); // instantiates object of class sub\cname $b = namespace\CONSTANT; // assigns value of constant CONSTANT to ...
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/namespaces/013.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/013.php
<?php namespace MyProject; echo '"', __NAMESPACE__, '"'; // outputs "MyProject" ?>
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/namespaces/036.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/036.php
<?php namespace my\stuff; class MyClass {} ?>
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/namespaces/004.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/004.php
<?php namespace MyProject; const CONNECT_OK = 1; class Connection { /* ... */ } function connect() { /* ... */ } namespace AnotherProject; const CONNECT_OK = 1; class Connection { /* ... */ } function connect() { /* ... */ } ?>
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/namespaces/016.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/016.php
<?php namespace MyProject; use blah\blah as mine; // see "Using namespaces: Aliasing/Importing" blah\mine(); // calls function MyProject\blah\mine() namespace\blah\mine(); // calls function MyProject\blah\mine() namespace\func(); // calls function MyProject\func() namespace\sub\func(); // calls function MyProj...
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/namespaces/001.php
tests/fixtures/Formatter/out/04-psr12/3rdparty/php-doc/language/namespaces/001.php
<?php namespace MyProject; const CONNECT_OK = 1; class Connection { /* ... */ } function connect() { /* ... */ } ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false