feat: initial commit of camelia/orm

Attribute-mapped Active Record ORM for MariaDB/MySQL over PDO.

- Attribute-driven metadata: TableName, PrimaryKey, AutoIncrement, Column,
  Guarded, Ignore, Required, Enum, Nullable, Length, Precision, Unique,
  UniqueGroup, Index, MaxLength.
- Relationship mapping: BelongsTo, HasOne, HasMany, BelongsToMany with
  batched eager loading and a 3-level depth limit.
- Orm entry point with fromArray, fromPdo, fromEnv and nested transactions.
- Immutable Query with Cond operators and GroupCond grouping.
- Repository read and write API, pagination, and typed exception hierarchy.
- Declares PHP >=8.3; Mago and PHPStan pin the parser to 8.3.
- MIT license.
This commit is contained in:
dgarcia committed 2026-11-15 10:14:22 -03:00
commit 66e93e3070
97 files changed
+12188

No files matched your search

+361
View File
@@ -0,0 +1,361 @@
variant = "loose"
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key 'CAMELIA_DB_HOST' accessed on `array{'CAMELIA_DB_HOST'?: string, 'CAMELIA_DB_NAME'?: string, 'CAMELIA_DB_PASS'?: string, 'CAMELIA_DB_USER'?: string}`."
count = 1
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key 'CAMELIA_DB_NAME' accessed on `array{'CAMELIA_DB_HOST'?: string, 'CAMELIA_DB_NAME'?: string, 'CAMELIA_DB_PASS'?: string, 'CAMELIA_DB_USER'?: string}`."
count = 1
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key 'CAMELIA_DB_PASS' accessed on `array{'CAMELIA_DB_HOST'?: string, 'CAMELIA_DB_NAME'?: string, 'CAMELIA_DB_PASS'?: string, 'CAMELIA_DB_USER'?: string}`."
count = 1
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key 'CAMELIA_DB_USER' accessed on `array{'CAMELIA_DB_HOST'?: string, 'CAMELIA_DB_NAME'?: string, 'CAMELIA_DB_PASS'?: string, 'CAMELIA_DB_USER'?: string}`."
count = 1
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key `string('database')` accessed on `array<string, mixed>`."
count = 1
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key `string('host')` accessed on `array<string, mixed>`."
count = 1
[[issues]]
file = "src/Connection/ConnectionFactory.php"
code = "possibly-undefined-string-array-index"
message = "Possibly undefined array key `string('user')` accessed on `array<string, mixed>`."
count = 1
[[issues]]
file = "src/Connection/PdoConnection.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 1
[[issues]]
file = "src/Metadata/MetadataFactory.php"
code = "less-specific-argument"
message = 'Argument type mismatch for argument #2 of `Camelia\Orm\Metadata\MetadataFactory::buildProperty`: expected `ReflectionClass<object>`, but provided type `ReflectionClass<Camelia\Orm\Model>` is less specific.'
count = 1
[[issues]]
file = "src/Metadata/MetadataFactory.php"
code = "redundant-docblock-type"
message = "Redundant docblock type for variable `$attribute`."
count = 4
[[issues]]
file = "src/Metadata/MetadataFactory.php"
code = "redundant-docblock-type"
message = "Redundant docblock type for variable `$table`."
count = 1
[[issues]]
file = "src/Metadata/MetadataFactory.php"
code = "redundant-type-comparison"
message = 'Redundant condition: variable `$class` (type `class-string<Camelia\Orm\Model>`) is already known to be `class-string<Camelia\Orm\Model>`.'
count = 1
[[issues]]
file = "src/Model.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 2
[[issues]]
file = "src/Model.php"
code = "redundant-cast"
message = "Redundant cast to `(string)`: the expression already has this type."
count = 1
[[issues]]
file = "src/Model.php"
code = "string-member-selector"
message = "This member selector uses a non-literal string type (`string`); its specific value cannot be statically determined."
count = 6
[[issues]]
file = "src/Orm.php"
code = "invalid-property-assignment-value"
message = '''Invalid type for property `$repositories`: expected `array<string, Camelia\Orm\Repository<Camelia\Orm\Model>>`, but got `non-empty-array<class-string<'T.camelia\orm\orm::repository() extends Camelia\Orm\Model>|string, Camelia\Orm\Repository<('T.camelia\orm\orm::repository() extends Camelia\Orm\Model)>|Camelia\Orm\Repository<Camelia\Orm\Model>>`.'''
count = 1
[[issues]]
file = "src/Orm.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 3
[[issues]]
file = "src/Orm.php"
code = "mixed-assignment"
message = "Assigning `nonnull` type to a variable may lead to unexpected behavior."
count = 1
[[issues]]
file = "src/Orm.php"
code = "non-existent-class-like"
message = 'Cannot find class, interface, enum, or type alias `Psr\Log\LoggerInterface`.'
count = 2
[[issues]]
file = "src/Orm.php"
code = "non-existent-class-like"
message = 'Class, Interface, or Trait `Psr\Log\LoggerInterface` does not exist.'
count = 1
[[issues]]
file = "src/Orm.php"
code = "non-existent-use-import"
message = 'Imported class, interface, trait, or enum `Psr\Log\LoggerInterface` does not exist.'
count = 1
[[issues]]
file = "src/Orm.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #4 of `Camelia\Orm\Orm::__construct`: expected `null|unknown-ref(Psr\Log\LoggerInterface)`, but possibly received `Psr\Log\LoggerInterface|null`.'
count = 1
[[issues]]
file = "src/Pagination/Page.php"
code = "impossible-condition"
message = "Redundant ternary operator: condition is always falsy."
count = 1
[[issues]]
file = "src/Pagination/Page.php"
code = "redundant-comparison"
message = "Redundant `===` comparison: left-hand side is never identical to right-hand side."
count = 1
[[issues]]
file = "src/Persistence/Persister.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 2
[[issues]]
file = "src/Persistence/Persister.php"
code = "redundant-cast"
message = "Redundant cast to `(string)`: the expression already has this type."
count = 1
[[issues]]
file = "src/Persistence/Persister.php"
code = "redundant-docblock-type"
message = "Redundant docblock type for variable `$class`."
count = 1
[[issues]]
file = "src/Query/CriteriaCompiler.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 1
[[issues]]
file = "src/Query/CriteriaCompiler.php"
code = "possibly-null-argument"
message = 'Argument #1 of method `Camelia\Orm\Query\Dialect::quoteIdentifier` is possibly `null`, but parameter type `string` does not accept it.'
count = 1
[[issues]]
file = "src/Query/CriteriaCompiler.php"
code = "possibly-undefined-int-array-index"
message = "Possibly undefined array index accessed on `non-empty-list<string>`."
count = 1
[[issues]]
file = "src/Query/CriteriaCompiler.php"
code = "redundant-cast"
message = "Redundant cast to `(string)`: the expression already has this type."
count = 1
[[issues]]
file = "src/Query/Query.php"
code = "invalid-type-cast"
message = "Casting `mixed` to `float`."
count = 1
[[issues]]
file = "src/Query/Query.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 4
[[issues]]
file = "src/Query/Query.php"
code = "possibly-undefined-int-array-index"
message = "Possibly undefined array key `int(0)` accessed on `non-empty-array<array-key, array<int|string, mixed>|string|true>`."
count = 1
[[issues]]
file = "src/Query/Query.php"
code = "redundant-cast"
message = "Redundant cast to `(float)`: the expression already has this type."
count = 2
[[issues]]
file = "src/Query/QueryBuilder.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 2
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = 'Invalid argument type for argument #2 of `Camelia\Orm\Query\QueryState::__construct`: expected `array<string, mixed>`, but found `nonnull`.'
count = 1
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = '''Invalid argument type for argument #3 of `Camelia\Orm\Query\QueryState::__construct`: expected `list<array{0: string, 1: string('ASC')|string('DESC')}>`, but found `nonnull`.'''
count = 1
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = '''Invalid argument type for argument #4 of `Camelia\Orm\Query\QueryState::__construct`: expected `list<array{0: string('AND')|string('OR'), 1: list<array{0: string, 1: mixed}>}>`, but found `nonnull`.'''
count = 1
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = 'Invalid argument type for argument #5 of `Camelia\Orm\Query\QueryState::__construct`: expected `list<string>|null`, but found `mixed`.'
count = 1
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = 'Invalid argument type for argument #6 of `Camelia\Orm\Query\QueryState::__construct`: expected `int|null`, but found `mixed`.'
count = 1
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = 'Invalid argument type for argument #7 of `Camelia\Orm\Query\QueryState::__construct`: expected `int|null`, but found `mixed`.'
count = 1
[[issues]]
file = "src/Query/QueryState.php"
code = "mixed-argument"
message = 'Invalid argument type for argument #8 of `Camelia\Orm\Query\QueryState::__construct`: expected `array<int|string, mixed>|false|true`, but found `mixed`.'
count = 1
[[issues]]
file = "src/Repository.php"
code = "invalid-argument"
message = '''Invalid argument type for argument #1 of `Camelia\Orm\Query\Query::start`: expected `Camelia\Orm\Repository<Camelia\Orm\Model>`, but found `$this(Camelia\Orm\Repository<('T.camelia\orm\repository extends Camelia\Orm\Model)>)`.'''
count = 1
[[issues]]
file = "src/Repository.php"
code = "invalid-return-statement"
message = 'Invalid return type for function `Camelia\Orm\Repository::relationMetadata`: expected `Camelia\Orm\Metadata\PropertyMetadata`, but found `Camelia\Orm\Metadata\PropertyMetadata|null`.'
count = 1
[[issues]]
file = "src/Repository.php"
code = "invalid-type-cast"
message = "Casting `mixed` to `float`."
count = 1
[[issues]]
file = "src/Repository.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 10
[[issues]]
file = "src/Repository.php"
code = "nullable-return-statement"
message = 'Function `Camelia\Orm\Repository::relationMetadata` is declared to return `Camelia\Orm\Metadata\PropertyMetadata` but possibly returns a nullable value (inferred as `Camelia\Orm\Metadata\PropertyMetadata|null`).'
count = 1
[[issues]]
file = "src/Repository.php"
code = "possibly-null-argument"
message = 'Argument #1 of method `Camelia\Orm\Repository::castDatabaseValue` is possibly `null`, but parameter type `Camelia\Orm\Metadata\PropertyMetadata` does not accept it.'
count = 1
[[issues]]
file = "src/Repository.php"
code = "possibly-null-property-access"
message = "Attempting to access a property on a possibly `null` value."
count = 3
[[issues]]
file = "src/Repository.php"
code = "possibly-undefined-string-array-index"
message = 'Possibly undefined array key `string` accessed on `array<string, Camelia\Orm\Metadata\PropertyMetadata>`.'
count = 5
[[issues]]
file = "src/Repository.php"
code = "redundant-cast"
message = "Redundant cast to `(float)`: the expression already has this type."
count = 2
[[issues]]
file = "src/Repository.php"
code = "redundant-cast"
message = "Redundant cast to `(string)`: the expression already has this type."
count = 4
[[issues]]
file = "src/Repository.php"
code = "unsafe-instantiation"
message = 'Unsafe `new $class_name`: constructor of `Camelia\Orm\Model` is not final and its signature might change in child classes, potentially leading to runtime errors.'
count = 3
[[issues]]
file = "src/Support/TypeCaster.php"
code = "invalid-type-cast"
message = 'Cannot cast object of type `Brick\Math\BigDecimal` to `string` because the class does not exist.'
count = 2
[[issues]]
file = "src/Support/TypeCaster.php"
code = "invalid-type-cast"
message = "Non numeric string of type `string` implicitly cast to `float`."
count = 1
[[issues]]
file = "src/Support/TypeCaster.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 1
[[issues]]
file = "src/Support/TypeCaster.php"
code = "no-value"
message = 'Argument #3 passed to method `Camelia\Orm\Support\TypeCaster::refusal` has type `never`, meaning it cannot produce a value.'
count = 1
[[issues]]
file = "src/Support/TypeCaster.php"
code = "non-existent-method"
message = 'Method `of` does not exist on type `Brick\Math\BigDecimal`.'
count = 2
[[issues]]
file = "src/Support/TypeCaster.php"
code = "possibly-static-access-on-interface"
message = "Potential static method call on interface `BackedEnum` via `class-string`."
count = 1