Add PHP 8.4 compatibility checks and fix compatibility issues#141
Merged
Add PHP 8.4 compatibility checks and fix compatibility issues#141
Conversation
…, parse errors + CI
Code fixes:
- Add `?` prefix to four implicit-nullable parameters that PHP 8.4 deprecates
(Dataface/Menu.php, xf/db/Binding.php, xf/db/Database.php, xf/core/XFException.php)
- Add #[AllowDynamicProperties] to high-traffic Xataface classes that assign
undeclared properties at runtime (Application, Table, Record + iterators, IO,
Relationship + ForeignKey, RelatedRecord, QueryTool + Null, QueryBuilder,
ResultController, ResultList, RelatedList, SummaryList, SearchForm,
RecordView, Menu + Item) to silence the PHP 8.2+ dynamic-property
deprecation warnings.
- Rename the `<<<END` heredoc terminator in xf/db/Binding.php to `<<<ENDSQL`
so the SQL `END IF;` content stops colliding with the heredoc closing
marker scanner under PHP 8.4's stricter heredoc indentation rules.
- Replace utf8_encode (deprecated since 8.2) with mb_convert_encoding in
the tools/ini2csv.php translation utility.
- Fix pre-existing parse errors that became fatal under PHP 8+:
- Dataface/HelpTool.php: drop empty duplicate getContents() stub
- Dataface/Clipboard.php: close two unterminated xf_db_query() calls
- actions/commit.php: parenthesize an unparenthesized nested ternary
- Dataface/FormTool/WidgetHandler.php: drop duplicate pushField() decl
- modules/XataJax/classes/xatacard/layout/{Record,Field,MySQLDataSource}.php:
missing paren, double semicolon, missing method bodies
CI hardening:
- Add .github/workflows/php-compat.yml with four jobs:
1. Syntax matrix (php -l) across PHP 8.0/8.1/8.2/8.3/8.4 — gating
2. PHPCompatibility scan against PHP 8.4 — informational baseline
3. PHPStan (level 0, phpVersion 80400) — informational baseline
4. Docker-based runtime tests on PHP 8.4
- Extend .github/workflows/tests.yml with a PHP version matrix
(7.4, 8.0, 8.2, 8.4) using shivammathur/setup-php
- Add phpcs.xml.dist (PHPCompatibility, testVersion=8.4-) and
phpstan.neon.dist (level 0, phpVersion 80400), both excluding bundled
third-party libraries and the legacy mysql_* driver path
- Add composer require-dev for php_codesniffer, PHPCompatibility,
phpcodesniffer-composer-installer, and phpstan, plus lint:syntax,
lint:compat, lint:phpstan composer scripts
After this change, every Xataface-authored .php file in the tree parses
cleanly on PHP 8.4. PHPCompatibility and PHPStan jobs are wired up but
left as continue-on-error pending baseline files; flip them to gating
once `vendor/bin/phpstan analyse --generate-baseline` has been committed.
https://claude.ai/code/session_01DJ5jTLjq12Qt445KeJGKxR
The Dockerfile in tests/docker_php8_test.sh starts MariaDB in the background and then runs Phase 2 against `host=localhost`, which makes mysqli try a Unix socket at /tmp/mysql.sock while the container's MariaDB listens at /run/mysqld/mysqld.sock. That path mismatch fails in the GitHub Actions environment even though the script works for the local /test-php8 skill flow. Rather than patch a harness that was only ever designed for local use, drop the CI job. tests.yml already runs `composer test` across PHP 7.4/8.0/8.2/8.4, and composer test drives tests/runTests.php — which includes PHP8CompatibilityUnitTest and PHP8CompatibilityIntegrationTest. Runtime 8.4 coverage is preserved; we just stop duplicating it through a broken Docker path. https://claude.ai/code/session_01DJ5jTLjq12Qt445KeJGKxR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR establishes PHP 8.4 compatibility for Xataface by adding automated compatibility checks and fixing identified issues in the codebase.
Key Changes
CI/CD Infrastructure
.github/workflows/php-compat.ymlwith four jobs:php -lphpcs.xml.distconfiguration for PHPCompatibility ruleset targeting PHP 8.4phpstan.neon.distconfiguration for static analysis at level 0composer.jsonwith dev dependencies (PHP_CodeSniffer, PHPCompatibility, PHPStan) and lint scripts.github/workflows/tests.ymlto test against PHP 7.4, 8.0, 8.2, and 8.4Code Compatibility Fixes
ENDtoENDSQLinxf/db/Binding.phpto comply with PHP 8.4 rules (heredoc/nowdoc identifiers cannot be reserved words)#[AllowDynamicProperties]attribute to 15+ classes that use dynamic properties:Dataface_Relationship,Dataface_Relationship_ForeignKeyDataface_Menu,Dataface_Menu_ItemDataface_Record,Dataface_RecordIteratorDataface_RelatedRecord,Dataface_QueryToolDataface_Application,Dataface_IO,Dataface_QueryBuilderDataface_RecordView,Dataface_RelatedList,Dataface_ResultControllerDataface_ResultList,Dataface_SearchForm,Dataface_SummaryList,Dataface_TableDataface/Clipboard.php(two instances)modules/XataJax/classes/xatacard/layout/Field.phpmodules/XataJax/classes/xatacard/layout/Record.phpmodules/XataJax/classes/xatacard/layout/MySQLDataSource.phpactions/commit.phputf8_encode()withmb_convert_encoding()intools/ini2csv.php?QueryTranslatorinxf/db/Database.phpDataface/FormTool/WidgetHandler.phpDataface/HelpTool.phpImplementation Details
continue-on-error: trueto establish a baseline before gating mergeshttps://claude.ai/code/session_01DJ5jTLjq12Qt445KeJGKxR