Skip to content

Add type declarations, final classes, and modern PHP patterns#91

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:modernize-php
Mar 15, 2026
Merged

Add type declarations, final classes, and modern PHP patterns#91
alganet merged 1 commit intoRespect:masterfrom
alganet:modernize-php

Conversation

@alganet
Copy link
Member

@alganet alganet commented Mar 15, 2026

Type declarations:

  • Add typed properties to Db, Sql, and Mapper (PDO, Sql, Db, string, array, bool)
  • Add return types to all methods (static, Sql, PDOStatement, SplObjectStorage|false, void, mixed, bool, array)
  • Constructor typed as PDO|Db union, simplified to ternary
  • Fix bare return statements, replace array() with []
  • Update test to expect TypeError for invalid constructor args

Modern patterns:

  • Mark all three classes final (Db, Mapper, Sql)
  • Convert Db::prepare() if/elseif chain to match expression
  • Convert Sql::build() switch to match expression with extracted helper methods
  • Simplify Sql::preBuild() switch to in_array check
  • Remove redundant docblocks and unused imports
  • Add local path repository for respect/data

Raise PHPStan to level 5.

Type declarations:
- Add typed properties to Db, Sql, and Mapper (PDO, Sql, Db,
  string, array, bool)
- Add return types to all methods (static, Sql, PDOStatement,
  SplObjectStorage|false, void, mixed, bool, array)
- Constructor typed as PDO|Db union, simplified to ternary
- Fix bare return statements, replace array() with []
- Update test to expect TypeError for invalid constructor args

Modern patterns:
- Mark all three classes final (Db, Mapper, Sql)
- Convert Db::prepare() if/elseif chain to match expression
- Convert Sql::build() switch to match expression with extracted
  helper methods
- Simplify Sql::preBuild() switch to in_array check
- Remove redundant docblocks and unused imports
- Add local path repository for respect/data

Raise PHPStan to level 5.
@alganet alganet marked this pull request as ready for review March 15, 2026 01:53
@alganet alganet merged commit 1e76079 into Respect:master Mar 15, 2026
2 checks passed
@alganet alganet deleted the modernize-php branch March 15, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant