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/03-tab/3rdparty/php-doc/language/attributes/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/attributes/000.php | <?php
interface ActionHandler
{
public function execute();
}
#[Attribute]
class SetUp {}
class CopyFile implements ActionHandler
{
public string $fileName;
public string $targetDirectory;
#[SetUp]
public function fileExists()
{
if (!file_exists($this->fileName)) {
throw new RuntimeException('File does not... | 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/03-tab/3rdparty/php-doc/language/attributes/005.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/attributes/005.php | <?php
namespace Example;
use Attribute;
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION)]
class MyAttribute {}
| 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/03-tab/3rdparty/php-doc/language/attributes/001.PHP74.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/attributes/001.PHP74.php | <?php
// a.php
namespace MyExample;
use Attribute;
#[Attribute]
class MyAttribute
{
const VALUE = 'value';
private $value;
public function __construct($value = null)
{
$this->value = $value;
}
}
// b.php
namespace Another;
use MyExample\MyAttribute;
#[MyAttribute]
#[\MyExample\MyAttribute]
#[MyAttribute(... | 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/03-tab/3rdparty/php-doc/language/wrappers/ssh2/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/ssh2/001.php | <?php
$session = ssh2_connect('example.com', 22);
ssh2_auth_pubkey_file($session, 'username', '/home/username/.ssh/id_rsa.pub',
'/home/username/.ssh/id_rsa', 'secret');
$connection_string = "ssh2.sftp://$session/";
unset($session);
$stream = fopen($connection_string . 'path/to/file', 'r');
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/ssh2/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/ssh2/000.php | <?php
$session = ssh2_connect('example.com', 22);
ssh2_auth_pubkey_file($session, 'username', '/home/username/.ssh/id_rsa.pub',
'/home/username/.ssh/id_rsa', 'secret');
$stream = fopen("ssh2.tunnel://$session/remote.example.com:1234", 'r');
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/rar/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/rar/001.php | <?php
$stream = fopen('rar://'
. rawurlencode(dirname(__FILE__)) . DIRECTORY_SEPARATOR
. 'encrypted_headers.rar' . '#encfile1.txt', 'r', false,
stream_context_create(
array(
'rar' =>
array(
'open_password' => 'samplepassword'
)
)
));
var_dump(stream_get_contents($stream));
/*
* creation and ... | 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/03-tab/3rdparty/php-doc/language/wrappers/rar/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/rar/000.php | <?php
class MyRecDirIt extends RecursiveDirectoryIterator
{
function current()
{
return rawurldecode($this->getSubPathName())
. (is_dir(parent::current()) ? ' [DIR]' : '');
}
}
$f = 'rar://' . rawurlencode(dirname(__FILE__))
. DIRECTORY_SEPARATOR . 'dirs_and_extra_headers.rar#';
$it = new RecursiveTreeItera... | 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/03-tab/3rdparty/php-doc/language/wrappers/glob/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/glob/000.php | <?php
// Loop over all *.php files in ext/spl/examples/ directory
// and print the filename and its size
$it = new DirectoryIterator('glob://ext/spl/examples/*.php');
foreach ($it as $f) {
printf("%s: %.1FK\n", $f->getFilename(), $f->getSize() / 1024);
}
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/data/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/data/001.php | <?php
$fp = fopen('data://text/plain;base64,', 'r');
$meta = stream_get_meta_data($fp);
// prints "text/plain"
echo $meta['mediatype'];
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/data/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/data/000.php | <?php
// prints "I love PHP"
echo file_get_contents('data://text/plain;base64,SSBsb3ZlIFBIUAo=');
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/php/004.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/php/004.php | <?php
file_put_contents('php://memory', 'PHP');
echo file_get_contents('php://memory'); // prints nothing
| 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/03-tab/3rdparty/php-doc/language/wrappers/php/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/php/001.php | <?php
/* This is equivalent to simply:
readfile("http://www.example.com");
since no filters are actually specified */
readfile('php://filter/resource=http://www.example.com');
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/php/002.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/php/002.php | <?php
/* This will output the contents of
www.example.com entirely in uppercase */
readfile('php://filter/read=string.toupper/resource=http://www.example.com');
/* This will do the same as above
but will also ROT13 encode it */
readfile('php://filter/read=string.toupper|string.rot13/resource=http://www.example.com... | 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/03-tab/3rdparty/php-doc/language/wrappers/php/003.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/php/003.php | <?php
/* This will filter the string "Hello World"
through the rot13 filter, then write to
example.txt in the current directory */
file_put_contents('php://filter/write=string.rot13/resource=example.txt', 'Hello 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/03-tab/3rdparty/php-doc/language/wrappers/php/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/php/000.php | <?php
// Set the limit to 5 MB.
$fiveMBs = 5 * 1024 * 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
fputs($fp, "hello\n");
// Read what we have written.
rewind($fp);
echo stream_get_contents($fp);
?> | 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/03-tab/3rdparty/php-doc/language/wrappers/php/005.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/php/005.php | <?php
$input = file_get_contents('php://input');
$json_array = json_decode(
json: $input,
associative: true,
flags: JSON_THROW_ON_ERROR
);
echo 'Received JSON data: ';
print_r($json_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/03-tab/3rdparty/php-doc/language/wrappers/http/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/wrappers/http/000.php | <?php
$url = 'http://www.example.com/redirecting_page.php';
$fp = fopen($url, 'r');
$meta_data = stream_get_meta_data($fp);
foreach ($meta_data['wrapper_data'] as $response) {
/* Were we redirected? */
if (strtolower(substr($response, 0, 10)) == 'location: ') {
/* update $url with where we were redirected 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/03-tab/3rdparty/php-doc/language/predefined/stringable/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/stringable/000.php | <?php
class IPv4Address implements Stringable
{
public function __construct(
private string $oct1,
private string $oct2,
private string $oct3,
private string $oct4,
) {}
public function __toString(): string
{
return "$this->oct1.$this->oct2.$this->oct3.$this->oct4";
}
}
function showStuff(string|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/out/03-tab/3rdparty/php-doc/language/predefined/iteratoraggregate/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/iteratoraggregate/000.php | <?php
class myData implements IteratorAggregate
{
public $property1 = 'Public property one';
public $property2 = 'Public property two';
public $property3 = 'Public property three';
public $property4 = '';
public function __construct()
{
$this->property4 = 'last property';
}
public function getIterator(): 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/out/03-tab/3rdparty/php-doc/language/predefined/error/gettrace/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/gettrace/000.php | <?php
function test()
{
throw new Error;
}
try {
test();
} catch (Error $e) {
var_dump($e->getTrace());
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/error/getfile/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/getfile/000.php | <?php
try {
throw new Error;
} catch (Error $e) {
echo $e->getFile();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/error/getline/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/getline/000.php | <?php
try {
throw new Error('Some error message');
} catch (Error $e) {
echo 'The error was created on line: ' . $e->getLine();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/error/gettraceasstring/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/gettraceasstring/000.php | <?php
function test()
{
throw new Error;
}
try {
test();
} catch (Error $e) {
echo $e->getTraceAsString();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/error/getcode/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/getcode/000.php | <?php
try {
throw new Error('Some error message', 30);
} catch (Error $e) {
echo 'The Error code is: ' . $e->getCode();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/error/getprevious/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/getprevious/000.php | <?php
class MyCustomError extends Error {}
function doStuff()
{
try {
throw new InvalidArgumentError('You are doing it wrong!', 112);
} catch (Error $e) {
throw new MyCustomError('Something happened', 911, $e);
}
}
try {
doStuff();
} catch (Error $e) {
do {
printf("%s:%d %s (%d) [%s]\n", $e->getFile(), $e-... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/getmessage/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/getmessage/000.php | <?php
try {
throw new Error('Some error message');
} catch (Error $e) {
echo $e->getMessage();
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/tostring/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/error/tostring/000.php | <?php
try {
throw new Error('Some error message');
} catch (Error $e) {
echo $e;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/iterator/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/iterator/000.php | <?php
class myIterator implements Iterator
{
private $position = 0;
private $array = array(
'firstelement',
'secondelement',
'lastelement',
);
public function __construct()
{
$this->position = 0;
}
public function rewind(): void
{
var_dump(__METHOD__);
$this->position = 0;
}
#[\ReturnTypeWillC... | 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/03-tab/3rdparty/php-doc/language/predefined/backedenum/from/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/backedenum/from/000.php | <?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
$h = Suit::from('H');
var_dump($h);
$b = Suit::from('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/03-tab/3rdparty/php-doc/language/predefined/backedenum/tryfrom/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/backedenum/tryfrom/000.php | <?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
$h = Suit::tryFrom('H');
var_dump($h);
$b = Suit::tryFrom('B') ?? Suit::Spades;
var_dump($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/03-tab/3rdparty/php-doc/language/predefined/generator/throw/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/generator/throw/000.php | <?php
function gen()
{
echo "Foo\n";
try {
yield;
} catch (Exception $e) {
echo "Exception: {$e->getMessage()}\n";
}
echo "Bar\n";
}
$gen = gen();
$gen->rewind();
$gen->throw(new Exception('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/03-tab/3rdparty/php-doc/language/predefined/generator/key/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/generator/key/000.php | <?php
function Gen()
{
yield 'key' => 'value';
}
$gen = Gen();
echo "{$gen->key()} => {$gen->current()}";
| 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/03-tab/3rdparty/php-doc/language/predefined/generator/rewind/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/generator/rewind/000.php | <?php
function generator(): Generator
{
echo "I'm a generator!\n";
for ($i = 1; $i <= 3; $i++) {
yield $i;
}
}
// Initialize the generator
$generator = generator();
// Rewind the generator to the beginning of the first yield expression,
// if it's not already there
$generator->rewind(); // I'm a generator!
/... | 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/03-tab/3rdparty/php-doc/language/predefined/generator/getreturn/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/generator/getreturn/000.php | <?php
$gen = (function () {
yield 1;
yield 2;
return 3;
})();
foreach ($gen as $val) {
echo $val, PHP_EOL;
}
echo $gen->getReturn(), 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/out/03-tab/3rdparty/php-doc/language/predefined/generator/send/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/generator/send/000.php | <?php
function printer()
{
echo "I'm printer!" . PHP_EOL;
while (true) {
$string = yield;
echo $string . PHP_EOL;
}
}
$printer = printer();
$printer->send('Hello world!');
$printer->send('Bye 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/03-tab/3rdparty/php-doc/language/predefined/variables/phperrormsg/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/phperrormsg/000.php | <?php
@strpos();
echo $php_errormsg;
?> | 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/03-tab/3rdparty/php-doc/language/predefined/variables/env/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/env/000.php | <?php
echo 'My username is ' . $_ENV['USER'] . '!';
?> | 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/03-tab/3rdparty/php-doc/language/predefined/variables/cookie/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/cookie/000.php | <?php
echo 'Hello ' . htmlspecialchars($_COOKIE['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/03-tab/3rdparty/php-doc/language/predefined/variables/globals/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/globals/001.php | <?php
// Generates compile-time error:
$GLOBALS = [];
$GLOBALS += [];
$GLOBALS = &$x;
$x = &$GLOBALS;
unset($GLOBALS);
array_pop($GLOBALS);
// ...and any other write/read-write operation on $GLOBALS
?> | 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/03-tab/3rdparty/php-doc/language/predefined/variables/globals/002.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/globals/002.php | <?php
// Before PHP 8.1.0
$a = 1;
$globals = $GLOBALS; // Ostensibly by-value copy
$globals['a'] = 2;
var_dump($a); // int(2)
// As of PHP 8.1.0
// this no longer modifies $a. The previous behavior violated by-value semantics.
$globals = $GLOBALS;
$globals['a'] = 1;
// To restore the previous behavior, iterate it... | 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/03-tab/3rdparty/php-doc/language/predefined/variables/globals/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/globals/000.php | <?php
function test()
{
$foo = 'local variable';
echo '$foo in global scope: ' . $GLOBALS['foo'] . "\n";
echo '$foo in current scope: ' . $foo . "\n";
}
$foo = 'Example content';
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/03-tab/3rdparty/php-doc/language/predefined/variables/httpresponseheader/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/httpresponseheader/000.php | <?php
function get_contents()
{
file_get_contents('http://example.com');
var_dump($http_response_header); // variable is populated in the local scope
}
get_contents();
var_dump($http_response_header); // a call to get_contents() does not populate the variable outside the function 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/out/03-tab/3rdparty/php-doc/language/predefined/variables/get/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/get/000.php | <?php
echo 'Hello ' . htmlspecialchars($_GET['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/03-tab/3rdparty/php-doc/language/predefined/variables/argc/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/argc/000.php | <?php
var_dump($argc);
?> | 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/03-tab/3rdparty/php-doc/language/predefined/variables/server/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/server/000.php | <?php
echo $_SERVER['SERVER_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/03-tab/3rdparty/php-doc/language/predefined/variables/argv/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/argv/000.php | <?php
var_dump($argv);
?> | 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/03-tab/3rdparty/php-doc/language/predefined/variables/post/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/variables/post/000.php | <?php
echo 'Hello ' . htmlspecialchars($_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/03-tab/3rdparty/php-doc/language/predefined/exception/gettrace/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/gettrace/000.php | <?php
function test()
{
throw new Exception;
}
try {
test();
} catch (Exception $e) {
var_dump($e->getTrace());
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/exception/getfile/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/getfile/000.php | <?php
try {
throw new Exception;
} catch (Exception $e) {
echo $e->getFile();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/exception/getline/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/getline/000.php | <?php
try {
throw new Exception('Some error message');
} catch (Exception $e) {
echo 'The exception was created on line: ' . $e->getLine();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/exception/gettraceasstring/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/gettraceasstring/000.php | <?php
function test()
{
throw new Exception;
}
try {
test();
} catch (Exception $e) {
echo $e->getTraceAsString();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/exception/getcode/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/getcode/000.php | <?php
try {
throw new Exception('Some error message', 30);
} catch (Exception $e) {
echo 'The exception code is: ' . $e->getCode();
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/exception/getprevious/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/getprevious/000.php | <?php
class MyCustomException extends Exception {}
function doStuff()
{
try {
throw new InvalidArgumentException('You are doing it wrong!', 112);
} catch (Exception $e) {
throw new MyCustomException('Something happened', 911, $e);
}
}
try {
doStuff();
} catch (Exception $e) {
do {
printf("%s:%d %s (%d) [%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/03-tab/3rdparty/php-doc/language/predefined/exception/getmessage/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/getmessage/000.php | <?php
try {
throw new Exception('Some error message');
} catch (Exception $e) {
echo $e->getMessage();
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/tostring/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/exception/tostring/000.php | <?php
try {
throw new Exception('Some error message');
} catch (Exception $e) {
echo $e;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/errorexception/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/errorexception/000.php | <?php
set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting.
return;
}
if ($errno === E_DEPRECATED || $errno === E_USER_DEPRECATED) {
// Do not throw an Exception for deprecation warn... | 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/03-tab/3rdparty/php-doc/language/predefined/errorexception/getseverity/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/errorexception/getseverity/000.php | <?php
try {
throw new ErrorException('Exception message', 0, E_USER_ERROR);
} catch (ErrorException $e) {
echo 'This exception severity is: ' . $e->getSeverity();
var_dump($e->getSeverity() === E_USER_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/03-tab/3rdparty/php-doc/language/predefined/arrayaccess/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/arrayaccess/000.php | <?php
class Obj implements ArrayAccess
{
public $container = [
'one' => 1,
'two' => 2,
'three' => 3,
];
public function offsetSet($offset, $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
public function offsetExists($offset)... | 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/03-tab/3rdparty/php-doc/language/predefined/arrayaccess/offsetexists/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/arrayaccess/offsetexists/000.php | <?php
class obj implements ArrayAccess
{
public function offsetSet($offset, $value): void
{
var_dump(__METHOD__);
}
public function offsetExists($var): bool
{
var_dump(__METHOD__);
if ($var == 'foobar') {
return true;
}
return false;
}
public function offsetUnset($var): void
{
var_dump(__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/03-tab/3rdparty/php-doc/language/predefined/arrayaccess/offsetset/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/arrayaccess/offsetset/000.php | <?php
$arrayaccess[] = 'first value';
$arrayaccess[] = 'second value';
print_r($arrayaccess);
?> | 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/03-tab/3rdparty/php-doc/language/predefined/php-incomplete-class/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/php-incomplete-class/000.php | <?php
class MyClass
{
public string $property = 'myValue';
}
$myObject = new MyClass;
$foo = serialize($myObject);
// unserializes all objects into __PHP_Incomplete_Class objects
$disallowed = unserialize($foo, ['allowed_classes' => false]);
var_dump($disallowed);
// unserializes all objects into __PHP_Incomplet... | 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/03-tab/3rdparty/php-doc/language/predefined/countable/count/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/countable/count/000.php | <?php
class Counter implements Countable
{
private $count = 0;
public function count(): int
{
return ++$this->count;
}
}
$counter = new Counter;
for ($i = 0; $i < 10; ++$i) {
echo 'I have been count()ed ' . count($counter) . " times\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/03-tab/3rdparty/php-doc/language/predefined/attributes/deprecated/000.PHP74.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/deprecated/000.PHP74.php | <?php
#[\Deprecated(message: "use safe_replacement() instead", since: "1.5")]
function unsafe_function()
{
echo 'This is unsafe', PHP_EOL;
}
unsafe_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/out/03-tab/3rdparty/php-doc/language/predefined/attributes/deprecated/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/deprecated/000.php | <?php
#[\Deprecated(message: 'use safe_replacement() instead', since: '1.5')]
function unsafe_function()
{
echo 'This is unsafe', PHP_EOL;
}
unsafe_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/out/03-tab/3rdparty/php-doc/language/predefined/attributes/sensitiveparameter/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/sensitiveparameter/000.php | <?php
function defaultBehavior(
string $secret,
string $normal
) {
throw new Exception('Error!');
}
function sensitiveParametersWithAttribute(
#[\SensitiveParameter]
string $secret,
string $normal
) {
throw new Exception('Error!');
}
try {
defaultBehavior('password', 'normal');
} catch (Exception $e) {
ech... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/allowdynamicproperties/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/allowdynamicproperties/000.php | <?php
class DefaultBehaviour {}
#[\AllowDynamicProperties]
class ClassAllowsDynamicProperties {}
$o1 = new DefaultBehaviour();
$o2 = new ClassAllowsDynamicProperties();
$o1->nonExistingProp = true;
$o2->nonExistingProp = 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/03-tab/3rdparty/php-doc/language/predefined/attributes/override/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/override/001.php | <?php
class Base
{
protected string $foo;
}
final class Extended extends Base
{
#[\Override]
protected string $boo;
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/attributes/override/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/attributes/override/000.php | <?php
class Base
{
protected function foo(): void {}
}
final class Extended extends Base
{
#[\Override]
protected function boo(): void {}
}
?> | 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/03-tab/3rdparty/php-doc/language/predefined/stdclass/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/stdclass/001.php | <?php
$json = '{"foo":"bar"}';
var_dump(json_decode($json));
| 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/03-tab/3rdparty/php-doc/language/predefined/stdclass/002.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/stdclass/002.php | <?php
$obj = new stdClass();
$obj->foo = 42;
$obj->{1} = 42;
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/03-tab/3rdparty/php-doc/language/predefined/stdclass/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/stdclass/000.php | <?php
$obj = (object) array('foo' => 'bar');
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/03-tab/3rdparty/php-doc/language/predefined/weakreference/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/weakreference/000.php | <?php
$obj = new stdClass();
$weakref = WeakReference::create($obj);
var_dump($weakref->get());
unset($obj);
var_dump($weakref->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/03-tab/3rdparty/php-doc/language/predefined/unitenum/cases/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/unitenum/cases/000.php | <?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
var_dump(Suit::cases());
?> | 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/03-tab/3rdparty/php-doc/language/predefined/closure/call/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/closure/call/000.php | <?php
class Value
{
protected $value;
public function __construct($value)
{
$this->value = $value;
}
public function getValue()
{
return $this->value;
}
}
$three = new Value(3);
$four = new Value(4);
$closure = function ($delta) {
var_dump($this->getValue() + $delta);
};
$closure->call($three, 4);
$clos... | 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/03-tab/3rdparty/php-doc/language/predefined/closure/bind/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/closure/bind/000.php | <?php
class A
{
private static $sfoo = 1;
private $ifoo = 2;
}
$cl1 = static function () {
return A::$sfoo;
};
$cl2 = function () {
return $this->ifoo;
};
$bcl1 = Closure::bind($cl1, null, 'A');
$bcl2 = Closure::bind($cl2, new A(), 'A');
echo $bcl1(), "\n";
echo $bcl2(), "\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/03-tab/3rdparty/php-doc/language/predefined/closure/bindto/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/closure/bindto/000.php | <?php
class A
{
private $val;
public function __construct($val)
{
$this->val = $val;
}
public function getClosure()
{
// Returns closure bound to this object and scope
return function () {
return $this->val;
};
}
}
$ob1 = new A(1);
$ob2 = new A(2);
$cl = $ob1->getClosure();
echo $cl(), "\n";
$cl... | 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/03-tab/3rdparty/php-doc/language/predefined/sensitiveparametervalue/getvalue/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/sensitiveparametervalue/getvalue/000.php | <?php
$s = new \SensitiveParameterValue('secret');
echo 'The protected value is: ', $s->getValue(), "\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/03-tab/3rdparty/php-doc/language/predefined/sensitiveparametervalue/debuginfo/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/sensitiveparametervalue/debuginfo/000.php | <?php
$s = new \SensitiveParameterValue('secret');
var_dump($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/03-tab/3rdparty/php-doc/language/predefined/weakmap/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/weakmap/000.php | <?php
$wm = new WeakMap();
$o = new stdClass;
class A
{
public function __destruct()
{
echo "Dead!\n";
}
}
$wm[$o] = new A;
var_dump(count($wm));
echo "Unsetting...\n";
unset($o);
echo "Done\n";
var_dump(count($wm));
| 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/03-tab/3rdparty/php-doc/language/predefined/serializable/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/predefined/serializable/000.php | <?php
class obj implements Serializable
{
private $data;
public function __construct()
{
$this->data = 'My private data';
}
public function serialize()
{
return serialize($this->data);
}
public function unserialize($data)
{
$this->data = unserialize($data);
}
public function getData()
{
return $... | 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/03-tab/3rdparty/php-doc/language/expressions/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/expressions/001.php | <?php
$first ? $second : $third
?> | 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/03-tab/3rdparty/php-doc/language/expressions/002.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/expressions/002.php | <?php
function double($i)
{
return $i * 2;
}
$b = $a = 5; /* assign the value five into the variable $a and $b */
$c = $a++; /* post-increment, assign original value of $a
(5) to $c */
$e = $d = ++$b; /* pre-increment, assign the incremented value of
$b (6) to $d and $e */
/* at this point, both $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/03-tab/3rdparty/php-doc/language/expressions/000.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/expressions/000.php | <?php
function foo()
{
return 5;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/028.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/028.php | <?php
class Foo
{
function Variable()
{
$name = 'Bar';
$this->$name(); // This calls the Bar() method
}
function Bar()
{
echo 'This is Bar';
}
}
$foo = new Foo();
$funcname = 'Variable';
$foo->$funcname(); // This calls $foo->Variable()
?> | 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/03-tab/3rdparty/php-doc/language/functions/031.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/031.php | <?php
var_dump(strlen(null));
// "Deprecated: Passing null to parameter #1 ($string) of type string is deprecated" as of PHP 8.1.0
// int(0)
var_dump(str_contains('foobar', null));
// "Deprecated: Passing null to parameter #2 ($needle) of type string is deprecated" as of PHP 8.1.0
// 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/03-tab/3rdparty/php-doc/language/functions/006.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/006.php | <?php
function takes_many_args(
$first_arg,
$second_arg,
$a_very_long_argument_name,
$arg_with_default = 5,
$again = 'a default string', // This trailing comma was not permitted before 8.0.0.
) {
// ...
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/017.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/017.php | <?php
function total_intervals($unit, DateInterval ...$intervals)
{
$time = 0;
foreach ($intervals as $interval) {
$time += $interval->$unit;
}
return $time;
}
$a = new DateInterval('P1D');
$b = new DateInterval('P2D');
echo total_intervals('d', $a, $b) . ' days';
// This will fail, since null isn't a DateInter... | 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/03-tab/3rdparty/php-doc/language/functions/013.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/013.php | <?php
function makeyogurt($container = 'bowl', $flavour = 'raspberry', $style = 'Greek')
{
return "Making a $container of $flavour $style yogurt.\n";
}
echo makeyogurt(style: 'natural');
?> | 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/03-tab/3rdparty/php-doc/language/functions/036.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/036.php | <?php
class Test
{
public function testing()
{
return function () {
var_dump($this);
};
}
}
$object = new Test;
$function = $object->testing();
$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/out/03-tab/3rdparty/php-doc/language/functions/004.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/004.php | <?php
function recursion($a)
{
if ($a < 20) {
echo "$a\n";
recursion($a + 1);
}
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/045.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/045.php | <?php
$obj?->method(...);
$obj?->prop->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/03-tab/3rdparty/php-doc/language/functions/016.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/016.php | <?php
function add($a, $b)
{
return $a + $b;
}
echo add(...[1, 2]) . "\n";
$a = [1, 2];
echo add(...$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/03-tab/3rdparty/php-doc/language/functions/001.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/001.php | <?php
function foo(
$arg_1,
$arg_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/03-tab/3rdparty/php-doc/language/functions/002.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/002.php | <?php
$makefoo = true;
/* We can't call foo() from here
since it doesn't exist yet,
but we can call bar() */
bar();
if ($makefoo) {
function foo()
{
echo "I don't exist until program execution reaches me.\n";
}
}
/* Now we can safely call foo()
since $makefoo evaluated to true */
if ($makefoo)
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/03-tab/3rdparty/php-doc/language/functions/025.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/025.php | <?php
function small_numbers()
{
return [0, 1, 2];
}
// Array destructuring will collect each member of the array individually
[$zero, $one, $two] = small_numbers();
// Prior to 7.1.0, the only equivalent alternative is using list() construct
list($zero, $one, $two) = small_numbers();
?> | 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/03-tab/3rdparty/php-doc/language/functions/024.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/024.php | <?php
function square($num)
{
return $num * $num;
}
echo square(4); // outputs '16'.
?> | 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/03-tab/3rdparty/php-doc/language/functions/032.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/032.php | <?php
echo preg_replace_callback('~-([a-z])~', function ($match) {
return strtoupper($match[1]);
}, 'hello-world');
// outputs helloWorld
?> | 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/03-tab/3rdparty/php-doc/language/functions/011.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/011.php | <?php
function makeyogurt($container = 'bowl', $flavour)
{
return "Making a $container of $flavour yogurt.\n";
}
echo makeyogurt('raspberry'); // "raspberry" is $container, not $flavour
?> | 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/03-tab/3rdparty/php-doc/language/functions/009.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/009.php | <?php
function makecoffee($types = array('cappuccino'), $coffeeMaker = NULL)
{
$device = is_null($coffeeMaker) ? 'hands' : $coffeeMaker;
return 'Making a cup of ' . join(', ', $types) . " with $device.\n";
}
echo makecoffee();
echo makecoffee(array('cappuccino', 'lavazza'), 'teapot');
?> | 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/03-tab/3rdparty/php-doc/language/functions/040.php | tests/fixtures/Formatter/out/03-tab/3rdparty/php-doc/language/functions/040.php | <?php
$z = 1;
$fn = fn($x) => fn($y) => $x * $y + $z;
// Outputs 51
var_export($fn(5)(10));
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.