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/in/3rdparty/php-doc/language/control-structures/include/003.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/include/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/include/005.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/alternative-syntax/001.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/alternative-syntax/003.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/alternative-syntax/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/for/001.php
tests/fixtures/Formatter/in/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(000000, 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/in/3rdparty/php-doc/language/control-structures/for/002.php
tests/fixtures/Formatter/in/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(000000, 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/in/3rdparty/php-doc/language/control-structures/for/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/do-while/001.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/do-while/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/declare/001.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/declare/002.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/declare/003.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/declare/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/006.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/004.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/001.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/002.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/003.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/control-structures/foreach/005.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/006.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/004.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/001.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/002.php
tests/fixtures/Formatter/in/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"; } catch...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/exceptions/009.php
tests/fixtures/Formatter/in/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 f...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/exceptions/007.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/010.php
tests/fixtures/Formatter/in/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 parent::__...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/exceptions/003.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/008.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/exceptions/005.php
tests/fixtures/Formatter/in/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; $fo...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/abstract/001.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/oop5/abstract/002.php
tests/fixtures/Formatter/in/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 h...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/abstract/003.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/oop5/abstract/000.php
tests/fixtures/Formatter/in/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/in/3rdparty/php-doc/language/oop5/static/001.php
tests/fixtures/Formatter/in/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() . "\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/in/3rdparty/php-doc/language/oop5/static/000.php
tests/fixtures/Formatter/in/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
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/paamayim-nekudotayim/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/paamayim-nekudotayim/001.php
<?php class MyClass { const CONST_VALUE = 'A constant value'; } class OtherClass extends MyClass { public static $my_static = 'static var'; public static function doubleColon() { echo parent::CONST_VALUE . "\n"; echo self::$my_static . "\n"; } } $classname = 'OtherClass'; $classname::...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/paamayim-nekudotayim/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/paamayim-nekudotayim/002.php
<?php class MyClass { protected function myFunc() { echo "MyClass::myFunc()\n"; } } class OtherClass extends MyClass { // Override parent's definition public function myFunc() { // But still call the parent function parent::myFunc(); echo "OtherClass::myFunc()\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/in/3rdparty/php-doc/language/oop5/paamayim-nekudotayim/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/paamayim-nekudotayim/000.php
<?php class MyClass { const CONST_VALUE = 'A constant value'; } $classname = 'MyClass'; echo $classname::CONST_VALUE; echo MyClass::CONST_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/in/3rdparty/php-doc/language/oop5/basic/006.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/006.php
<?php class ClassA extends \stdClass {} class ClassB extends \stdClass {} class ClassC extends ClassB {} class ClassD extends ClassA {} function getSomeClass(): string { return 'ClassA'; } var_dump(new (getSomeClass())); var_dump(new ('Class' . 'B')); var_dump(new ('Class' . 'C')); var_dump(new (ClassD::class));...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/018.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/018.php
<?php print Does\Not\Exist::class; ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/017.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/017.php
<?php namespace NS { class ClassName { } echo ClassName::class; } ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/013.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/013.php
<?php class Base { public function foo(int $a) { echo "Valid\n"; } } class Extend1 extends Base { function foo(int $a = 5) { parent::foo($a); } } class Extend2 extends Base { function foo(int $a, $b = 5) { parent::foo($a); } } $extended1 = new Extend1(); $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/in/3rdparty/php-doc/language/oop5/basic/004.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/004.php
<?php readonly class Foo { public static int $bar; } // Fatal error: Readonly class Foo cannot declare static properties ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/016.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/016.php
<?php class A { public function test($foo, $bar) {} } class B extends A { public function test($a, $b) {} } $obj = new B; // Pass parameters according to A::test() contract $obj->test(foo: "foo", bar: "bar"); // 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/in/3rdparty/php-doc/language/oop5/basic/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/001.php
<?php class A { function foo() { if (isset($this)) { echo '$this is defined ('; echo get_class($this); echo ")\n"; } else { echo "\$this is not defined.\n"; } } } class B { function bar() { A::foo(); } } $a = new 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/in/3rdparty/php-doc/language/oop5/basic/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/002.php
<?php #[\AllowDynamicProperties] readonly class Foo { } // Fatal error: Cannot apply #[AllowDynamicProperties] to readonly class 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/in/3rdparty/php-doc/language/oop5/basic/011.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/011.php
<?php class Foo { public $bar; public function __construct() { $this->bar = function() { return 42; }; } } $obj = new Foo(); echo ($obj->bar)(), PHP_EOL;
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/009.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/009.php
<?php echo (new DateTime())->format('Y'), PHP_EOL; // surrounding parentheses are optional as of PHP 8.4.0 echo new DateTime()->format('Y'), PHP_EOL; ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/020.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/020.php
<?php // As of PHP 8.0.0, this line: $result = $repository?->getUser(5)?->name; // Is equivalent to the following code block: if (is_null($repository)) { $result = null; } else { $user = $repository->getUser(5); if (is_null($user)) { $result = null; } else { $result = $user->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/in/3rdparty/php-doc/language/oop5/basic/012.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/012.php
<?php class SimpleClass { function displayVar() { echo "Parent class\n"; } } class ExtendClass extends SimpleClass { // Redefine the parent method function displayVar() { echo "Extending class\n"; parent::displayVar(); } } $extended = new ExtendClass(); $extended->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/in/3rdparty/php-doc/language/oop5/basic/019.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/019.php
<?php namespace NS { class ClassName { } $c = new ClassName(); print $c::class; } ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/014.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/014.php
<?php class Base { public function foo(int $a = 5) { echo "Valid\n"; } } class Extend extends Base { function foo() { parent::foo(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/in/3rdparty/php-doc/language/oop5/basic/015.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/015.php
<?php class Base { public function foo(int $a = 5) { echo "Valid\n"; } } class Extend extends Base { function foo(int $a) { parent::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/in/3rdparty/php-doc/language/oop5/basic/007.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/007.php
<?php class SimpleClass { public string $var; } $instance = new SimpleClass(); $assigned = $instance; $reference =& $instance; $instance->var = '$assigned will have this value'; $instance = null; // $instance and $reference become null var_dump($instance); var_dump($reference); var_dump($assigned); ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/010.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/010.php
<?php class Foo { public $bar = 'property'; public function bar() { return 'method'; } } $obj = new Foo(); echo $obj->bar, PHP_EOL, $obj->bar(), PHP_EOL;
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/003.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/003.php
<?php readonly class Foo { public $bar; } // Fatal error: Readonly property Foo::$bar must have type ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/008.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/008.php
<?php class Test { public static function getNew() { return new static(); } } class Child extends Test {} $obj1 = new Test(); // By the class name $obj2 = new $obj1(); // Through the variable containing an object var_dump($obj1 !== $obj2); $obj3 = Test::getNew(); // By the class method var_dump(...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/000.php
<?php class SimpleClass { // property declaration public $var = 'a default value'; // method declaration public function displayVar() { echo $this->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/in/3rdparty/php-doc/language/oop5/basic/005.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/basic/005.php
<?php class SimpleClass { } $instance = new SimpleClass(); var_dump($instance); // This can also be done with a variable: $className = 'SimpleClass'; $instance = new $className(); // new SimpleClass() var_dump($instance); ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/006.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/006.php
<?php interface A { public function foo(string $s): string; public function bar(int $i): int; } // An abstract class may implement only a portion of an interface. // Classes that extend the abstract class must implement the rest. abstract class B implements A { public function foo(string $s): string {...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/004.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/004.php
<?php interface A { public function foo(); } interface B { public function bar(); } interface C extends A, B { public function baz(); } class D implements C { public function foo() { } public function bar() { } public function 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/in/3rdparty/php-doc/language/oop5/interfaces/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/001.php
<?php // Declare the interface 'Template' interface Template { public function setVariable($name, $var); public function getHtml($template); } // Implement the interface // This will work class WorkingTemplate implements Template { private $vars = []; public function setVariable($name, $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/in/3rdparty/php-doc/language/oop5/interfaces/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/002.php
<?php interface A { public function foo(); } interface B extends A { public function baz(Baz $baz); } // This will work class C implements B { public function foo() { } public function baz(Baz $baz) { } } // This will not work and result in a fatal error class D implements B { pu...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/007.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/007.php
<?php class One { /* ... */ } interface Usable { /* ... */ } interface Updatable { /* ... */ } // The keyword order here is important. 'extends' must come first. class Two extends One implements Usable, Updatable { /* ... */ } ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/003.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/003.php
<?php class Foo {} class Bar extends Foo {} interface A { public function myfunc(Foo $arg): Foo; } interface B { public function myfunc(Bar $arg): Bar; } class MyClass implements A, B { public function myfunc(Foo $arg): Bar { return new 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/in/3rdparty/php-doc/language/oop5/interfaces/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/000.php
<?php interface I { // An implementing class MUST have a publicly-readable property, // but whether or not it's publicly settable is unrestricted. public string $readable { get; } // An implementing class MUST have a publicly-writeable property, // but whether or not it's publicly readable is unres...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/005.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/interfaces/005.php
<?php interface A { const B = 'Interface constant'; } // Prints: Interface constant echo A::B; class B implements A { const B = 'Class constant'; } // Prints: Class constant // Prior to PHP 8.1.0, this will however not work because it was not // allowed to override constants. echo 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/in/3rdparty/php-doc/language/oop5/late-static-bindings/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/late-static-bindings/001.php
<?php class A { public static function who() { echo __CLASS__; } public static function test() { static::who(); // Here comes Late Static Bindings } } class B extends A { public static function who() { echo __CLASS__; } } B::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/in/3rdparty/php-doc/language/oop5/late-static-bindings/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/late-static-bindings/002.php
<?php class A { private function foo() { echo "Success!\n"; } public function test() { $this->foo(); static::foo(); } } class B extends A { /* foo() will be copied to B, hence its scope will still be A and * the call be successful */ } class C extends 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/in/3rdparty/php-doc/language/oop5/late-static-bindings/003.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/late-static-bindings/003.php
<?php class A { public static function foo() { static::who(); } public static function who() { echo __CLASS__ . "\n"; } } class B extends A { public static function test() { A::foo(); parent::foo(); self::foo(); } public static function...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/late-static-bindings/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/late-static-bindings/000.php
<?php class A { public static function who() { echo __CLASS__; } public static function test() { self::who(); } } class B extends A { public static function who() { echo __CLASS__; } } B::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/in/3rdparty/php-doc/language/oop5/references/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/references/000.php
<?php class A { public $foo = 1; } $a = new A; $b = $a; // $a and $b are copies of the same identifier // ($a) = ($b) = <id> $b->foo = 2; echo $a->foo."\n"; $c = new A; $d = &$c; // $c and $d are references // ($c,$d) = <id> $d->foo = 2; echo $c->foo."\n"; $e = new A; funct...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/lazy-objects/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/lazy-objects/001.php
<?php class Example { public function __construct(public int $prop) { echo __METHOD__, "\n"; } } $reflector = new ReflectionClass(Example::class); $lazyObject = $reflector->newLazyProxy(function (Example $object) { // Create and return the real instance return new Example(1); }); var_dump(...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/lazy-objects/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/lazy-objects/002.php
<?php class BlogPost { public function __construct( public int $id, public string $title, public string $content, ) { } } $reflector = new ReflectionClass(BlogPost::class); $post = $reflector->newLazyGhost(function ($post) { $data = fetch_from_store($post->id); $post->__constru...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/lazy-objects/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/lazy-objects/000.php
<?php class Example { public function __construct(public int $prop) { echo __METHOD__, "\n"; } } $reflector = new ReflectionClass(Example::class); $lazyObject = $reflector->newLazyGhost(function (Example $object) { // Initialize object in-place $object->__construct(1); }); var_dump($lazyOb...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/006.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/006.php
<?php class Test { public function __construct( public readonly int $i = 0, public readonly array $ary = [], ) {} } $test = new Test; $test->i += 1; $test->i++; ++$test->i; $test->ary[] = 1; $test->ary[0][] = 1; unset($test->ary[0]); $ref =& $test->i; $test->i =& $ref; byRef($test->i); foreach...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/004.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/004.php
<?php class Test1 { public readonly string $prop; } $test1 = new Test1; // Illegal initialization outside of private scope. $test1->prop = "foobar"; // Error: Cannot initialize readonly property Test1::$prop from global scope ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/001.php
<?php class User { public int $id; public ?string $name; public function __construct(int $id, ?string $name) { $this->id = $id; $this->name = $name; } } $user = new User(1234, null); var_dump($user->id); var_dump($user->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/in/3rdparty/php-doc/language/oop5/properties/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/002.php
<?php class Shape { public int $numberOfSides; public string $name; public function setNumberOfSides(int $numberOfSides): void { $this->numberOfSides = $numberOfSides; } public function setName(string $name): void { $this->name = $name; } public function getNumber...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/007.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/007.php
<?php class Test { public function __construct(public readonly object $obj) {} } $test = new Test(new stdClass); // Legal interior mutation. $test->obj->foo = 1; // Illegal reassignment. $test->obj = 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/in/3rdparty/php-doc/language/oop5/properties/003.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/003.php
<?php class Test { public readonly string $prop; public function __construct(string $prop) { // Legal initialization. $this->prop = $prop; } } $test = new Test("foobar"); // Legal read. var_dump($test->prop); // string(6) "foobar" // Illegal reassignment. It does not matter that the assigned ...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/008.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/008.php
<?php class Test1 { public readonly ?string $prop; public function __clone() { $this->prop = null; } public function setProp(string $prop): void { $this->prop = $prop; } } $test1 = new Test1; $test1->setProp('foobar'); $test2 = clone $test1; var_dump($test2->prop); // NULL ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/000.php
<?php class SimpleClass { public $var1 = 'hello ' . 'world'; public $var2 = <<<EOD hello world EOD; public $var3 = 1+2; // invalid property declarations: public $var4 = self::myStaticMethod(); public $var5 = $myVar; // valid property declarations: public $var6 = myConstant; public $var7 = [t...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/005.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/properties/005.php
<?php class Test { // Fatal error: Readonly property Test::$prop cannot have default value public readonly int $prop = 42; } ?>
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/004.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/004.php
<?php echo get_class(new class {});
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/001.php
<?php class SomeClass {} interface SomeInterface {} trait SomeTrait {} var_dump(new class(10) extends SomeClass implements SomeInterface { private $num; public function __construct($num) { $this->num = $num; } use SomeTrait; });
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/002.php
<?php class Outer { private $prop = 1; protected $prop2 = 2; protected function func1() { return 3; } public function func2() { return new class($this->prop) extends Outer { private $prop3; public function __construct($prop) { ...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/003.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/003.php
<?php function anonymous_class() { return new class {}; } if (get_class(anonymous_class()) === get_class(anonymous_class())) { echo 'same class'; } else { echo 'different class'; }
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/000.php
<?php // Using an explicit class class Logger { public function log($msg) { echo $msg; } } $util->setLogger(new Logger()); // Using an anonymous class $util->setLogger(new class { public function log($msg) { echo $msg; } });
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/005.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/anonymous/005.php
<?php // Using an anonymous class var_dump(new readonly class('[DEBUG]') { public function __construct(private string $prefix) { } public function log($msg) { echo $this->prefix . ' ' . $msg; } });
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/004.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/004.php
<?php $some_json_string = '{ "id": 1004, "name": "Elephpant" }'; $some_xml_string = "<animal><id>1005</id><name>Elephpant</name></animal>"; class Product { private ?int $id; private ?string $name; private function __construct(?int $id = null, ?string $name = null) { $this->id = $id; $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/in/3rdparty/php-doc/language/oop5/decon/001.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/001.php
<?php class Point { protected int $x; protected int $y; public function __construct(int $x, int $y = 0) { $this->x = $x; $this->y = $y; } } // Pass both parameters. $p1 = new Point(4, 5); // Pass only the required parameter. $y will take its default value of 0. $p2 = new Point(4); // W...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/002.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/002.php
<?php class Point { public function __construct(protected int $x, protected int $y = 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/in/3rdparty/php-doc/language/oop5/decon/003.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/003.php
<?php // All allowed: static $x = new Foo; const C = new Foo; function test($param = new Foo) {} #[AnAttribute(new Foo)] class Test { public function __construct( public $prop = new Foo, ) {} } // All not allowed (compile-time error): function test( $a = new (CLASS_NAME_CONSTANT)(), // dynami...
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false
lkrms/pretty-php
https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/000.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/000.php
<?php class BaseClass { function __construct() { print "In BaseClass constructor\n"; } } class SubClass extends BaseClass { function __construct() { parent::__construct(); print "In SubClass constructor\n"; } } class OtherSubClass extends BaseClass { // inherits BaseClass'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/in/3rdparty/php-doc/language/oop5/decon/005.php
tests/fixtures/Formatter/in/3rdparty/php-doc/language/oop5/decon/005.php
<?php class MyDestructableClass { function __construct() { print "In constructor\n"; } function __destruct() { print "Destroying " . __CLASS__ . "\n"; } } $obj = new MyDestructableClass();
php
MIT
5d244a4b7a9b484581edbb5df596a4e76ba17fa6
2026-01-05T04:31:39.990954Z
false