diff --git a/.github/jobs/fix_pipelinecomponents_image.sh b/.github/jobs/fix_pipelinecomponents_image.sh index 8723b86f1b..32d77a1e52 100755 --- a/.github/jobs/fix_pipelinecomponents_image.sh +++ b/.github/jobs/fix_pipelinecomponents_image.sh @@ -15,10 +15,19 @@ mydir=$(pwd) echo "Before /app/composer.json:" cat /app/composer.json -sed -i 's/"phpcompatibility\/php-compatibility": "9.3.5"/"phpcompatibility\/php-compatibility": "dev-develop"/g' /app/composer.json -sed -i 's/"squizlabs\/php_codesniffer": "3.13.2"/"squizlabs\/php_codesniffer": "^3.13.3"/g' /app/composer.json + +echo "Install the only needed tool" +rm /app/composer.json +cd /app +set +eu +composer require phpcompatibility/php-compatibility:dev-develop +set -eu + +composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + echo "After /app/composer.json:" cat /app/composer.json -cd /app; composer update +echo "Install the needed tools" +composer update cd $mydir diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 0dbddf8f72..48f3c3d62a 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -40,6 +40,35 @@ jobs: webapp/public webapp/config + phpcs_compatibility_new_style: + runs-on: ubuntu-latest + container: + image: domjudge/gitlabci:24.04 + strategy: + matrix: + PHPVERSION: ["8.1", "8.2", "8.3", "8.4", "8.5"] + steps: + - uses: actions/checkout@v4 + - name: Trigger the plugin + run: | + olddir=`pwd` + cd / + composer install + cd "$olddir" + - name: Detect compatibility with supported PHP version + run: > + /vendor/bin/phpcs -s -p --colors + --standard=PHPCompatibility + --extensions=php + --runtime-set testVersion ${{ matrix.PHPVERSION }} + lib/lib.*.php + etc + judge + webapp/src + webapp/tests + webapp/public + webapp/config + phpcs_compatibility: runs-on: ubuntu-latest container: diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 4b4a56ae4d..0cd34901de 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -1779,5 +1779,30 @@ private function initsignals(): void } } +$result = "Hello World" + |> strtoupper(...) + |> str_shuffle(...) + |> trim(...); + +interface I { + // We may naively assume that the PHP constant is always a string. + const PHP = 'PHP 8.2'; +} + +class Foo implements I { + // But implementing classes may define it as an array. + const PHP = []; +} + +class Foo2 { + const PHP = 'PHP 8.3'; +} + +$searchableConstant = 'PHP'; + +var_dump(json_validate('{ "test": { "foo": "bar" } }')); // true + +var_dump(Foo2::{$searchableConstant}); + $daemon = new JudgeDaemon(); $daemon->run();