Skip to content

Conversation

@simon-mundy
Copy link
Collaborator

@simon-mundy simon-mundy commented Jan 9, 2026

Q A
Documentation no
Bugfix yes
BC Break yes
New Feature no
RFC no
QA yes
House Keeping yes

Description

Adds PHP8.2+ modernisation, strong typing and general code cleanup.
Adds new RowPrototypeInterface to solve issues with new ResultSet and RowGateway
Adds 100% code coverage testing

Closes #63

  Refactor RowGateway and TableGateway classes to use PHP 8+ features:

  - Replace docblock type hints with native property type declarations using union types and nullable types
  - Add return type declarations to methods (offsetExists(): bool, offsetGet(): mixed, count(): int, etc.)
  - Use static return type for fluent interface methods
  - Convert constructor parameters to use union types in RowGateway and TableGateway

  Improve type safety and code quality:
  - Replace loose equality (==) with strict equality (===) in primary key comparisons
  - Simplify initialization checks using null comparisons instead of instanceof checks
  - Add proper instanceof StatementInterface guards before executing statements
  - Add lazy initialization to getFeatureSet(), getResultSetPrototype(), and getSql() getters
  - Add default case to match expression in TableGateway constructor
  - Update TableGatewayInterface::getTable() to return proper union type

  Cleanup:
  - Remove unused imports (is_string)
  - Remove redundant comments and phpcs ignore directives
  - Remove unused $alias variable in foreach loop
  - Fix @todo annotation format

  Update tests:
  - Change primaryKeyColumn to array format to match expected type
  - Remove unnecessary setAccessible(true) calls (not needed in PHP 8.1+)

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Reverted constructor in TableGateway to allow nullable args and pass existing tests

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Introduced spread operators instead of call_user_func_array
Modified existing files to add RowPrototypeInterface
Updated tests
@simon-mundy simon-mundy added this to the 0.6.0 milestone Jan 9, 2026
@simon-mundy simon-mundy self-assigned this Jan 9, 2026
@simon-mundy simon-mundy added bug Something isn't working enhancement New feature or request qa Improvements in quality assurance of the project Lang Feature Refactor Refactoring to new language features labels Jan 9, 2026
@github-project-automation github-project-automation bot moved this to Todo in @phpdb Jan 9, 2026
@simon-mundy simon-mundy merged commit d01d3fe into 0.6.x Jan 12, 2026
29 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in @phpdb Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request Lang Feature Refactor Refactoring to new language features qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[RFC]: Refactor Typing in \TableGateway

3 participants