-
Notifications
You must be signed in to change notification settings - Fork 12
Modernize PHP 8.3+ support and add PostgreSQL #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the library for PHP 8.3+, adds PostgreSQL support to the ORM, and wires in a contemporary tooling/CI setup (PHPUnit 10, PHPStan, php-cs-fixer, and a PHP/DB matrix in GitHub Actions).
Changes:
- Raise the minimum PHP version to 8.3, upgrade PHPUnit to 10.x, and add PHPStan/php-cs-fixer configs and CI workflow.
- Extend the
ModelORM to support PostgreSQL (identifier quoting, schema discovery, insert/delete/update semantics) and update tests and example model to work against both MySQL/MariaDB and PostgreSQL. - Refresh documentation, contributor guidelines, and Docker compose to cover dual‑database development and local setup.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Model/Model.php |
Refactors the core ORM for PHP 8.3 (type hints, safer PDO access), adds driver-aware identifier quoting and field discovery, introduces PostgreSQL-specific insert logic and LIMIT handling for UPDATE/DELETE, and tightens helpers like datetimeToMysqldatetime(). |
tests/Model/CategoryTest.php |
Updates the test suite to PHPUnit 10 style, parameterizes DB connection via env vars, and adds setup/teardown DDL for both MySQL/MariaDB and PostgreSQL. |
test-src/Model/Category.php |
Namespaces the example model (App\Model), updates docblocks, and normalizes the table-name property visibility for use in tests. |
phpunit.xml.dist |
Migrates the PHPUnit configuration to the 10.5 schema, enabling Composer autoload and on-disk cache, with the existing tests suite preserved. |
phpstan.neon |
Introduces PHPStan level 9 analysis, covering src and tests, and configures Freshsauce\Model\Model as a universal object crate to handle dynamic properties. |
docker-compose.yml |
Simplifies the compose file and defines local MariaDB and PostgreSQL services suitable for running the test suite. |
.github/workflows/ci.yml |
Adds a GitHub Actions workflow to run PHP 8.3/8.4 against both MySQL and PostgreSQL, plus PHPStan and php-cs-fixer checks. |
composer.json |
Normalizes the package name, raises the PHP requirement to >=8.3, and adds dev tools (phpunit/phpunit 10.x, phpstan/phpstan, friendsofphp/php-cs-fixer) plus PDO driver suggestions. |
composer.lock |
Updates the dev dependency graph to match the new tooling stack (PHPUnit 10, PHPStan 1.12, php-cs-fixer 3.93, and related libraries). |
README.md |
Updates usage docs for PHP 8.3, switches examples to Freshsauce\Model\Model, and documents basic PostgreSQL schema/connection and test invocation. |
CONTRIBUTING.md |
Adds contributor guidance for setup, running tests, static analysis, formatting, and PR expectations. |
CHANGELOG.md |
Starts a changelog describing the PHP 8.3 requirement, PostgreSQL support, and CI/tooling updates. |
AGENTS.md |
Documents repository structure, tooling commands, coding conventions, and testing/CI norms for automated and human contributors. |
.php-cs-fixer.dist.php |
Introduces a PSR‑12-based php-cs-fixer configuration targeting src, tests, and test-src. |
.gitignore |
Ignores PHPUnit and php-cs-fixer caches in addition to vendor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e70c8dfa59
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!$hasData || !property_exists($this->data, $field) || !$this->isFieldDirty($field)) { | ||
| continue; | ||
| } | ||
| $columns[] = static::_quote_identifier($field); | ||
| if ($this->$field === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid inserting NULL for unspecified columns
In setString, using property_exists($this->data, $field) means fields that were auto-hydrated to null are now treated as set and dirty. Because hydrate() assigns null to every column not in the input array, inserts will explicitly include those columns as NULL, overriding database defaults and potentially violating NOT NULL constraints. This is a behavioral regression versus the prior isset($this->$field) check (which skipped nulls), and it will surface whenever a model is created with only a subset of columns but the table relies on defaults or NOT NULL columns.
Useful? React with 👍 / 👎.
Summary\n- Raise minimum PHP to 8.3 and upgrade PHPUnit\n- Add PostgreSQL support in ORM + tests\n- Add CI matrix (PHP + MySQL/Postgres), PHPStan, php-cs-fixer\n- Refresh docs and contributor guidance\n\n## Testing\n- vendor/bin/phpunit -c phpunit.xml.dist\n- MODEL_ORM_TEST_DSN=pgsql:host=127.0.0.1;port=5432;dbname=categorytest MODEL_ORM_TEST_USER=postgres MODEL_ORM_TEST_PASS=postgres vendor/bin/phpunit -c phpunit.xml.dist\n- vendor/bin/phpstan analyse --debug -c phpstan.neon\n- vendor/bin/php-cs-fixer fix --dry-run --diff