Add PHP 7.4 demo for Jenkins

This commit is contained in:
ci
2026-08-31 23:56:34 +08:00
commit 18133958d6
4 changed files with 54 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
# php-demo
PHP **7.4** demo for Gitea + Jenkins on this server.
```bash
/www/server/php/74/bin/php -l src/Hello.php
/www/server/php/74/bin/php tests/hello_test.php
```
+12
View File
@@ -0,0 +1,12 @@
{
"name": "ci/php-demo",
"description": "Tiny PHP 7.4 demo built by Jenkins",
"require": {
"php": ">=7.4 <8.0"
},
"autoload": {
"psr-4": {
"Demo\\": "src/"
}
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Demo;
final class Hello
{
public static function greet(string $name): string
{
$name = trim($name);
if ($name === '') {
$name = 'World';
}
return 'Hello, ' . $name;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
require __DIR__ . '/../src/Hello.php';
use Demo\Hello;
$got = Hello::greet('Gitea');
if ($got !== 'Hello, Gitea') {
fwrite(STDERR, "FAIL greet: {$got}\n");
exit(1);
}
$got = Hello::greet(' ');
if ($got !== 'Hello, World') {
fwrite(STDERR, "FAIL empty: {$got}\n");
exit(1);
}
echo "PHP 7.4 tests OK\n";