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/01-default/3rdparty/php-doc/appendices/migration56/new-features/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/002.php | <?php
function f($req, $opt = null, ...$params)
{
// $params is an array containing the remaining arguments.
printf('$req: %d; $opt: %d; number of params: %d' . "\n",
$req, $opt, count($params));
}
f(1);
f(1, 2);
f(1, 2, 3);
f(1, 2, 3, 4);
f(1, 2, 3, 4, 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/01-default/3rdparty/php-doc/appendices/migration56/new-features/007.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/007.php | <?php
$expected = crypt('12345', '$2a$07$usesomesillystringforsalt$');
$correct = crypt('12345', '$2a$07$usesomesillystringforsalt$');
$incorrect = crypt('1234', '$2a$07$usesomesillystringforsalt$');
var_dump(hash_equals($expected, $correct));
var_dump(hash_equals($expected, $incorrect));
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/003.php | <?php
function add($a, $b, $c)
{
return $a + $b + $c;
}
$operators = [2, 3];
echo add(1, ...$operators);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/008.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/008.php | <?php
class C
{
private $prop;
public function __construct($val)
{
$this->prop = $val;
}
public function __debugInfo()
{
return [
'propSquared' => $this->prop ** 2,
];
}
}
var_dump(new C(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/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/000.php | <?php
const ONE = 1;
const TWO = ONE * 2;
class C
{
const THREE = TWO + 1;
const ONE_THIRD = ONE / self::THREE;
const SENTENCE = 'The value of THREE is ' . self::THREE;
public function f($a = ONE + self::THREE)
{
return $a;
}
}
echo (new C)->f() . "\n";
echo C::SENTENCE;
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/005.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/new-features/005.php | <?php
namespace Name\Space
{
const FOO = 42;
function f()
{
echo __FUNCTION__ . "\n";
}
}
namespace
{
use function Name\Space\f;
use const Name\Space\FOO;
echo FOO . "\n";
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/out/01-default/3rdparty/php-doc/appendices/migration56/incompatible/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/appendices/migration56/incompatible/000.php | <?php
class C
{
const ONE = 1;
public $array = [
self::ONE => 'foo',
'bar',
'quux',
];
}
var_dump((new C)->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/01-default/3rdparty/php-doc/features/dtrace/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/dtrace/001.php | # ./configure --enable-dtrace ...
# make
# make install | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/dtrace/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/dtrace/000.php | # modprobe fasttrap
# chmod 666 /dev/dtrace/helper | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/remote-files/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/remote-files/001.php | <?php
$file = fopen('ftp://ftp.example.com/incoming/outputfile', 'w');
if (!$file) {
echo "<p>Unable to open remote file for writing.\n";
exit;
}
/* Write the data here. */
fwrite($file, $_SERVER['HTTP_USER_AGENT'] . "\n");
fclose($file);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/remote-files/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/remote-files/000.php | <?php
$file = fopen('http://www.example.com/', 'r');
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof($file)) {
$line = fgets($file, 1024);
/* This only works if the title and its tags are on one line */
if (preg_match('@\<title\>(.*)\</title\>@i', $line, $out)) {
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/http-auth/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/http-auth/001.php | <?php
function authenticate()
{
header('WWW-Authenticate: Basic realm="Test Authentication System"');
header('HTTP/1.0 401 Unauthorized');
echo "You must enter a valid login ID and password to access this resource\n";
exit;
}
if (!isset($_SERVER['PHP_AUTH_USER']) ||
($_POST['SeenBefore'] == 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/01-default/3rdparty/php-doc/features/http-auth/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/http-auth/000.php | <?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} ... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/006.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/006.php | <?php
$a = array('meaning' => 'life', 'number' => 42);
$a['life'] = $a['meaning'];
unset($a['meaning'], $a['number']);
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/gc/004.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/004.php | <?php
$a = array('meaning' => 'life', 'number' => 42);
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/gc/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/001.php | <?php
$a = 'new string';
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/gc/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/002.php | <?php
$a = 'new string';
$b = $a;
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/gc/009.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/009.php | <?php
class Foo
{
public $var = '3.14159265359';
public $self;
}
for ($i = 0; $i <= 1000000; $i++) {
$a = new Foo;
$a->self = $a;
}
echo memory_get_peak_usage(), "\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/01-default/3rdparty/php-doc/features/gc/007.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/007.php | <?php
$a = array('one');
$a[] = &$a;
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/gc/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/003.php | <?php
$a = 'new string';
$c = $b = $a;
xdebug_debug_zval('a');
$b = 42;
xdebug_debug_zval('a');
unset($c);
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/gc/008.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/008.php | <?php
class Foo
{
public $var = '3.14159265359';
public $self;
}
$baseMemory = memory_get_usage();
for ($i = 0; $i <= 100000; $i++) {
$a = new Foo;
$a->self = $a;
if ($i % 500 === 0) {
echo sprintf('%8d: ', $i), memory_get_usage() - $baseMemory, "\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/01-default/3rdparty/php-doc/features/gc/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/000.php | <?php
$a = 'new 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/01-default/3rdparty/php-doc/features/gc/005.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/gc/005.php | <?php
$a = array('meaning' => 'life', 'number' => 42);
$a['life'] = $a['meaning'];
xdebug_debug_zval('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/01-default/3rdparty/php-doc/features/commandline/006.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/006.php | <?php
$stdout = fopen('php://stdout', '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/out/01-default/3rdparty/php-doc/features/commandline/004.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/004.php | <?php
$stdin = fopen('php://stdin', '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/01-default/3rdparty/php-doc/features/commandline/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/001.php | <?php
// Our simple test application named test.php
echo getcwd(), "\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/01-default/3rdparty/php-doc/features/commandline/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/002.php | #!/usr/bin/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/01-default/3rdparty/php-doc/features/commandline/009.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/009.php | <?php
// router.php
if (php_sapi_name() == 'cli-server') {
/* route static assets and return false */
}
/* go on with normal index.php operations */
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/007.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/007.php | <?php
$stderr = fopen('php://stderr', '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/out/01-default/3rdparty/php-doc/features/commandline/010.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/010.php | <?php
// router.php
$path = pathinfo($_SERVER['SCRIPT_FILENAME']);
if ($path['extension'] == 'el') {
header('Content-Type: text/x-script.elisp');
readfile($_SERVER['SCRIPT_FILENAME']);
} else {
return FALSE;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/003.php | #!/usr/bin/php
<?php
if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
?>
This is a command line PHP script with one option.
Usage:
<?php echo $argv[0]; ?> <option>
<option> can be some word you would like
to print out. With the --help, -help, -h,
or -? options, you can get thi... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/008.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/008.php | <?php
// router.php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER['REQUEST_URI'])) {
return false; // serve the requested resource as-is.
} else {
echo '<p>Welcome to PHP</p>';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/000.php | <?php
if (php_sapi_name() === 'cli') {
echo "This is being run from the command line!\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/01-default/3rdparty/php-doc/features/commandline/005.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/commandline/005.php | <?php
$line = trim(fgets(STDIN)); // reads one line from STDIN
fscanf(STDIN, "%d\n", $number); // reads number from STDIN
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/file-upload/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/file-upload/001.php | <?php
foreach ($_FILES['pictures']['error'] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES['pictures']['tmp_name'][$key];
// basename() may prevent filesystem traversal attacks;
// further validation/sanitation of the filename may be appropriate
$name = basen... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/file-upload/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/file-upload/002.php | <?php
/* PUT data comes in on the stdin stream */
$putdata = fopen('php://input', 'r');
/* Open a file for writing */
$fp = fopen('myputfile.ext', 'w');
/* Read the data 1 KB at a time
and write to the file */
while ($data = fread($putdata, 1024))
fwrite($fp, $data);
/* Close the streams */
fclose($fp);
fclos... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/file-upload/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/features/file-upload/000.php | <?php
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here i... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/using/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/using/001.php | <?php
function myfunc($argument)
{
echo $argument + 10;
}
$variable = 10;
echo "myfunc($variable) = " . myfunc($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/01-default/3rdparty/php-doc/faq/using/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/using/002.php | <pre>
<?php echo 'This should be the first line.'; ?>
<?php echo 'This should show up after the new line above.'; ?>
</pre> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/using/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/using/003.php | <?php
$headers = getallheaders();
foreach ($headers as $name => $content) {
echo "headers[$name] = $content<br />\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/01-default/3rdparty/php-doc/faq/using/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/using/000.php | <?php
$empty = $post = array();
foreach ($_POST as $varname => $varvalue) {
if (empty($varvalue)) {
$empty[$varname] = $varvalue;
} else {
$post[$varname] = $varvalue;
}
}
print '<pre>';
if (empty($empty)) {
print "None of the POSTed values are empty, posted:\n";
var_dump($post);
} ... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/html/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/html/001.php | <?php
echo "<textarea name='mydata'>\n";
echo htmlspecialchars($data) . "\n";
echo '</textarea>';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/html/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/html/002.php | <?php
echo '<a href="' . htmlspecialchars('/nextpage.php?stage=23&data='
. urlencode($data)) . '">' . "\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/01-default/3rdparty/php-doc/faq/html/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/html/003.php | <?php
if (isset($_GET['width']) AND isset($_GET['height'])) {
// output the geometry variables
echo 'Screen width is: ' . $_GET['width'] . "<br />\n";
echo 'Screen height is: ' . $_GET['height'] . "<br />\n";
} else {
// pass the geometry variables
// (preserve the original query 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/01-default/3rdparty/php-doc/faq/html/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/html/000.php | <?php
echo '<input type="hidden" value="' . htmlspecialchars($data) . '" />' . "\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/01-default/3rdparty/php-doc/faq/build/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/build/000.php | <?php phpinfo(); ?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/com/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/faq/com/000.php | <?php
$word = new COM('C:\docs\word.doc');
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/errors/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/errors/000.php | <?php
if ($username) { // Not initialized or checked before usage
$good_login = 1;
}
if ($good_login == 1) { // If above test fails, not initialized or checked before usage
readfile('/highly/sensitive/data/index.html');
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/variables/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/variables/000.php | <?php
// remove a file from the user's home directory... or maybe
// somebody else's?
unlink($evil_var);
// Write logging of their access... or maybe an /etc/passwd entry?
fwrite($fp, $evil_var);
// Execute something trivial.. or rm -rf *?
system($evil_var);
exec($evil_var);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/004.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/004.php | <?php
$file = $_GET['file']; // "../../etc/passwd\0"
if (file_exists('/home/wwwrun/' . $file . '.php')) {
// File_exists will return true as the file /home/wwwrun/../../etc/passwd exists
include '/home/wwwrun/' . $file . '.php';
// The file /etc/passwd will be included
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/001.php | <?php
// Removes a file from anywhere on the hard drive that
// the PHP user has access to. If PHP has root access:
$username = $_POST['user_submitted_name']; // "../etc"
$userfile = $_POST['user_submitted_filename']; // "passwd"
$homedir = "/home/$username"; // "/home/../etc"
unlink("$homedir/$userfile"); // "/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/out/01-default/3rdparty/php-doc/security/filesystem/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/002.php | <?php
// Removes a file from the hard drive that
// the PHP user has access to.
$username = $_SERVER['REMOTE_USER']; // using an authentication mechanism
$userfile = basename($_POST['user_submitted_filename']);
$homedir = "/home/$username";
$filepath = "$homedir/$userfile";
if (file_exists($filepath) && unlink($fil... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/003.php | <?php
$username = $_SERVER['REMOTE_USER']; // using an authentication mechanisim
$userfile = $_POST['user_submitted_filename'];
$homedir = "/home/$username";
$filepath = "$homedir/$userfile";
if (!ctype_alnum($username) || !preg_match('/^(?:[a-z0-9_-]|\.(?!\.))+$/iD', $userfile)) {
die('Bad username/filename');... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/000.php | <?php
// Remove a file from the user's home directory
$username = $_POST['user_submitted_name'];
$userfile = $_POST['user_submitted_filename'];
$homedir = "/home/$username";
unlink("$homedir/$userfile");
echo 'The file has been deleted!';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/005.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/filesystem/005.php | <?php
$file = $_GET['file'];
// Whitelisting possible values
switch ($file) {
case 'main':
case 'foo':
case 'bar':
include '/home/wwwrun/include/' . $file . '.php';
break;
default:
include '/home/wwwrun/include/main.php';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/006.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/006.php | <?php
$query = "SELECT * FROM products
WHERE id LIKE '%a%'
exec master..xp_cmdshell 'net user test testpass /ADD' --%'";
$result = mssql_query($query);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/004.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/004.php | <?php
// $uid: ' or uid like '%admin%
$query = "UPDATE usertable SET pwd='...' WHERE uid='' or uid like '%admin%';";
// $pwd: hehehe', trusted=100, admin='yes
$query = "UPDATE usertable SET pwd='hehehe', trusted=100, admin='yes' WHERE
...;";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/001.php | <?php
$offset = $_GET['offset']; // beware, no input validation!
$query = "SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET $offset;";
$result = pg_query($conn, $query);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/002.php | <?php
$query = "SELECT id, name, inserted, size FROM products
WHERE size = '$size'";
$result = odbc_exec($conn, $query);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/007.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/007.php | <?php
// The dynamic SQL part is validated against expected values
$sortingOrder = $_GET['sortingOrder'] === 'DESC' ? 'DESC' : 'ASC';
$productId = $_GET['productId'];
// The SQL is prepared with a placeholder
$stmt = $pdo->prepare("SELECT * FROM products WHERE id LIKE ? ORDER BY price {$sortingOrder}");
// The value i... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/003.php | <?php
$query = "UPDATE usertable SET pwd='$pwd' WHERE uid='$uid';";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/000.php | <?php
// storing password hash
$query = sprintf("INSERT INTO users(name,pwd) VALUES('%s','%s');",
pg_escape_string($username),
password_hash($password, PASSWORD_DEFAULT));
$result = pg_query($connection, $query);
// querying if user submitted the right password
$query = sprintf("SELECT pwd FROM users WHERE na... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/005.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/security/database/005.php | <?php
$query = "SELECT * FROM products WHERE id LIKE '%$prod%'";
$result = mssql_query($query);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/006.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/006.php | <?php
$suit = Suit::Clubs;
$ref = &$suit->value;
// Error: Cannot acquire reference to property Suit::$value
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/018.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/018.php | <?php
enum Foo
{
case Bar;
}
enum Baz: int
{
case Beep = 5;
}
print_r(Foo::Bar);
print_r(Baz::Beep);
/*
* Produces
*
* Foo Enum (
* [name] => Bar
* )
* Baz Enum:int {
* [name] => Beep
* [value] => 5
* }
*/
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/017.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/017.php | <?php
Suit::Hearts === unserialize(serialize(Suit::Hearts));
print serialize(Suit::Hearts);
// E:11:"Suit:Hearts";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/013.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/013.php | <?php
interface Colorful
{
public function color(): string;
}
trait Rectangle
{
public function shape(): string
{
return 'Rectangle';
}
}
enum Suit implements Colorful
{
use Rectangle;
case Hearts;
case Diamonds;
case Clubs;
case Spades;
public function color(): stri... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/004.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/004.php | <?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/022.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/022.php | <?php
enum SortOrder
{
case Asc;
case Desc;
}
function query($fields, $filter, SortOrder $order = SortOrder::Asc)
{
/* ... */
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/016.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/016.php | <?php
Suit::cases();
// Produces: [Suit::Hearts, Suit::Diamonds, Suit::Clubs, Suit::Spades]
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/001.php | <?php
function pick_a_card(Suit $suit)
{
/* ... */
}
$val = Suit::Diamonds;
// OK
pick_a_card($val);
// OK
pick_a_card(Suit::Clubs);
// TypeError: pick_a_card(): Argument #1 ($suit) must be of type Suit, string given
pick_a_card('Spades');
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/002.php | <?php
$a = Suit::Spades;
$b = Suit::Spades;
$a === $b; // true
$a instanceof Suit; // true
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/024.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/024.php | <?php
foreach (UserStatus::cases() as $case) {
printf('<option value="%s">%s</option>\n', $case->value, $case->label());
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/011.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/011.php | <?php
enum Size
{
case Small;
case Medium;
case Large;
public static function fromLength(int $cm): self
{
return match (true) {
$cm < 50 => self::Small,
$cm < 100 => self::Medium,
default => self::Large,
};
}
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/009.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/009.php | <?php
interface Colorful
{
public function color(): string;
}
enum Suit: string implements Colorful
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
// Fulfills the interface contract.
public function color(): string
{
return match ($this) {
... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/020.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/020.php | <?php
enum ErrorCode
{
case SOMETHING_BROKE;
}
function quux(ErrorCode $errorCode)
{
// When written, this code appears to cover all cases
match ($errorCode) {
ErrorCode::SOMETHING_BROKE => true,
};
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/012.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/012.php | <?php
enum Size
{
case Small;
case Medium;
case Large;
public const Huge = self::Large;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/019.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/019.php | <?php
class A {}
class B extends A {}
function foo(A $a) {}
function bar(B $b)
{
foo($b);
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/014.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/014.php | <?php
// This is an entirely legal Enum definition.
enum Direction implements ArrayAccess
{
case Up;
case Down;
public function offsetExists($offset): bool
{
return false;
}
public function offsetGet($offset): mixed
{
return null;
}
public function offsetSet($offs... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/015.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/015.php | <?php
$clovers = new Suit();
// Error: Cannot instantiate enum Suit
$horseshoes = (new ReflectionClass(Suit::class))->newInstanceWithoutConstructor()
// Error: Cannot instantiate enum Suit
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/007.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/007.php | <?php
$record = get_stuff_from_database($id);
print $record['suit'];
$suit = Suit::from($record['suit']);
// Invalid data throws a ValueError: "X" is not a valid scalar value for enum "Suit"
print $suit->value;
$suit = Suit::tryFrom('A') ?? Suit::Spades;
// Invalid data returns null, so Suit::Spades is used instead.... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/010.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/010.php | <?php
interface Colorful
{
public function color(): string;
}
final class Suit implements UnitEnum, Colorful
{
public const Hearts = new self('Hearts');
public const Diamonds = new self('Diamonds');
public const Clubs = new self('Clubs');
public const Spades = new self('Spades');
private func... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/003.php | <?php
print Suit::Spades->name;
// prints "Spades"
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/023.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/023.php | <?php
enum UserStatus: string
{
case Pending = 'P';
case Active = 'A';
case Suspended = 'S';
case CanceledByUser = 'C';
public function label(): string
{
return match ($this) {
self::Pending => 'Pending',
self::Active => 'Active',
self::Suspended => ... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/008.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/008.php | <?php
interface Colorful
{
public function color(): string;
}
enum Suit implements Colorful
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
// Fulfills the interface contract.
public function color(): string
{
return match ($this) {
Suit::Hearts, Suit::Diamo... | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/000.php | <?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/005.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/enumerations/005.php | <?php
print Suit::Clubs->value;
// Prints "C"
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/goto/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/goto/001.php | <?php
for ($i = 0, $j = 50; $i < 100; $i++) {
while ($j--) {
if ($j == 17) {
goto end;
}
}
}
echo "i = $i";
end:
echo 'j hit 17';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/goto/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/goto/002.php | <?php
goto loop;
for ($i = 0, $j = 50; $i < 100; $i++) {
while ($j--) {
loop:
}
}
echo "$i = $i";
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/goto/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/goto/000.php | <?php
goto a;
echo 'Foo';
a:
echo 'Bar';
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/continue/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/continue/001.php | <?php
$i = 0;
while ($i++ < 5) {
echo "Outer\n";
while (1) {
echo "Middle\n";
while (1) {
echo "Inner\n";
continue 3;
}
echo "This never gets output.\n";
}
echo "Neither does this.\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/continue/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/continue/002.php | <?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue print "$i\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/continue/000.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/continue/000.php | <?php
$arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'];
foreach ($arr as $key => $value) {
if (0 === ($key % 2)) { // skip members with even key
continue;
}
echo $value . "\n";
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/006.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/006.php | <?php
$condition = 5;
try {
match ($condition) {
1, 2 => foo(),
3, 4 => bar(),
};
} catch (\UnhandledMatchError $e) {
var_dump($e);
}
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/004.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/004.php | <?php
$result = match ($x) {
// This match arm:
$a, $b, $c => 5,
// Is equivalent to these three match arms:
$a => 5,
$b => 5,
$c => 5,
};
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/001.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/001.php | <?php
$food = 'cake';
$return_value = match ($food) {
'apple' => 'This food is an apple',
'bar' => 'This food is a bar',
'cake' => 'This food is a cake',
};
var_dump($return_value);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/002.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/002.php | <?php
$age = 18;
$output = match (true) {
$age < 2 => 'Baby',
$age < 13 => 'Child',
$age <= 19 => 'Teenager',
$age >= 40 => 'Old adult',
$age > 19 => 'Young adult',
};
var_dump($output);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/007.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/007.php | <?php
$age = 23;
$result = match (true) {
$age >= 65 => 'senior',
$age >= 25 => 'adult',
$age >= 18 => 'young adult',
default => 'kid',
};
var_dump($result);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/003.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/003.php | <?php
$result = match ($x) {
foo() => 'value',
$this->bar() => 'value', // $this->bar() isn't called if foo() === $x
$this->baz => beep(), // beep() isn't called unless $x === $this->baz
// etc.
};
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
lkrms/pretty-php | https://github.com/lkrms/pretty-php/blob/5d244a4b7a9b484581edbb5df596a4e76ba17fa6/tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/008.php | tests/fixtures/Formatter/out/01-default/3rdparty/php-doc/language/control-structures/match/008.php | <?php
$text = 'Bienvenue chez nous';
$result = match (true) {
str_contains($text, 'Welcome'), str_contains($text, 'Hello') => 'en',
str_contains($text, 'Bienvenue'), str_contains($text, 'Bonjour') => 'fr',
// ...
};
var_dump($result);
?> | php | MIT | 5d244a4b7a9b484581edbb5df596a4e76ba17fa6 | 2026-01-05T04:31:39.990954Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.