Completions bug fixes

This commit is contained in:
2026-01-10 07:56:40 +00:00
parent e9da17eb34
commit b2a64f219f
21 changed files with 400 additions and 193 deletions

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Syntax Stress Test</title>
@@ -33,98 +34,103 @@
<body>
<?php
// Basic variables
$number = 42;
$text = "Hello PHP";
$truth = true;
$nothing = null;
<?php
// Basic variables
$number = 42;
$text = "Hello PHP";
$truth = true;
$nothing = null;
// Constants
define("APP_NAME", "SyntaxTester");
// Constants
define("APP_NAME", "SyntaxTester");
// Arrays
$list = [1, 2, 3];
$assoc = [
"one" => 1,
"two" => 2
];
// Arrays
$list = [1, 2, 3];
$assoc = [
"one" => 1,
"two" => 2
];
// Function
function add(int $a, int $b): int {
return $a + $b;
}
// Class + methods
class User {
private string $name;
public static int $count = 0;
public function __construct(string $name) {
$this->name = $name;
self::$count++;
// Function
function add(int $a, int $b): int
{
return $a + $b;
}
public function greet(): string {
return "Hello {$this->name}";
// Class + methods
class User
{
private string $name;
public static int $count = 0;
public function __construct(string $name)
{
$this->name = $name;
self::$count++;
}
public function greet(): string
{
return "Hello {$this->name}";
}
}
}
// Object usage
$user = new User("Alice");
echo $user->greet();
// Object usage
$user = new User("Alice");
echo $user->greet();
// Control flow
if ($number > 10) {
echo "Big number";
} elseif ($number === 10) {
echo "Exactly ten";
} else {
echo "Small number";
}
// Control flow
if ($number > 10) {
echo "Big number";
} elseif ($number === 10) {
echo "Exactly ten";
} else {
echo "Small number";
}
// Loop
foreach ($list as $item) {
echo $item;
}
// Loop
foreach ($list as $item) {
echo $item;
}
// Match expression
$result = match ($number) {
1 => "one",
2 => "two",
default => "many"
};
// Match expression
$result = match ($number) {
1 => "one",
2 => "two",
default => "many"
};
// Try / catch
try {
throw new Exception("Test exception");
} catch (Exception $e) {
echo $e->getMessage();
}
// Try / catch
try {
throw new Exception("Test exception");
} catch (Exception $e) {
echo $e->getMessage();
}
// Anonymous function
$double = fn($x) => $x * 2;
// Anonymous function
$double = fn($x) => $x * 2;
// Nullsafe operator
$len = $user?->name ? strlen($user->name) : 0;
// Nullsafe operator
$len = $user?->name ? strlen($user->name) : 0;
// Ternary
$status = $truth ? "yes" : "no";
// Ternary
$status = $truth ? "yes" : "no";
// Include / require
require_once "config.php";
// Include / require
require_once "config.php";
// Output
echo "<div class='box'>";
echo htmlspecialchars($text);
echo "</div>";
?>
// Output
echo "<div class='box'>";
echo htmlspecialchars($text);
echo "</div>";
?>
<script>
// JS interacting with PHP output
const phpValue = <?= json_encode($number) ?>;
console.log("Value from PHP:", phpValue);
</script>
<script>
// JS interacting with PHP output
const phpValue = <?= json_encode($number) ?>;
console.log("Value from PHP:", phpValue);
</script>
</body>
</html>