Drop support for PHP 8.3 and lower. The package now declares >=8.4, and CI runs only on 8.4. - composer.json: require php >=8.4. - mago.toml: php-version = "8.4", matching the minimum supported version. - phpstan.neon: phpVersion 80400. - Upgrade phpstan/phpstan to ^2.3: 1.x cannot parse `new Foo()->bar()`, which the 8.4 formatter now emits. - Fix the type errors PHPStan 2 reports: class-string<static> variance, optional array offsets in fromEnvironment, list vs array for PdoConnection::$lru, ReflectionClass<Model> docblocks, Repository made covariant in T, and a redundant null comparison in validateRelationPath. - CI: single PHP 8.4 job using the php:8.4-cli container instead of setup-php, which failed with a TLS handshake timeout on the runner. BREAKING CHANGE: PHP 8.4 is now required.
This commit is contained in:
1 parent
c15015d809
commit
0e756e45c7
20 files changed
+97
-107
No files matched your search
@@ -23,7 +23,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
#[Test]
|
||||
public function it_reads_table_and_primary_key(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Usuario::class);
|
||||
$metadata = new MetadataFactory()->forClass(Usuario::class);
|
||||
|
||||
self::assertSame('usuarios', $metadata->table());
|
||||
self::assertSame('codigo', $metadata->primaryKey());
|
||||
@@ -33,7 +33,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
#[Test]
|
||||
public function it_converts_property_names_to_columns(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Usuario::class);
|
||||
$metadata = new MetadataFactory()->forClass(Usuario::class);
|
||||
|
||||
self::assertSame('password_hash', $metadata->column('passwordHash'));
|
||||
self::assertSame('passwordHash', $metadata->property('password_hash'));
|
||||
@@ -43,7 +43,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
#[Test]
|
||||
public function it_honours_an_explicit_column_name(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Factura::class);
|
||||
$metadata = new MetadataFactory()->forClass(Factura::class);
|
||||
|
||||
self::assertSame('importe_total', $metadata->column('total'));
|
||||
}
|
||||
@@ -51,7 +51,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
#[Test]
|
||||
public function it_excludes_relations_from_writable_columns(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Factura::class);
|
||||
$metadata = new MetadataFactory()->forClass(Factura::class);
|
||||
|
||||
self::assertSame(['usuarioCodigo', 'total'], $metadata->writable());
|
||||
self::assertCount(2, $metadata->relations());
|
||||
@@ -60,7 +60,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
#[Test]
|
||||
public function it_resolves_belongs_to_metadata(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Factura::class);
|
||||
$metadata = new MetadataFactory()->forClass(Factura::class);
|
||||
$relation = $metadata->properties()['usuario']->relation;
|
||||
|
||||
self::assertNotNull($relation);
|
||||
@@ -72,7 +72,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
#[Test]
|
||||
public function it_resolves_belongs_to_many_pivot_metadata(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Articulo::class);
|
||||
$metadata = new MetadataFactory()->forClass(Articulo::class);
|
||||
$relation = $metadata->properties()['etiquetas']->relation;
|
||||
|
||||
self::assertNotNull($relation);
|
||||
@@ -89,7 +89,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
$this->expectException(MetadataException::class);
|
||||
$this->expectExceptionMessage('[M2]');
|
||||
|
||||
(new MetadataFactory())->forClass(SinTableName::class);
|
||||
new MetadataFactory()->forClass(SinTableName::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -98,7 +98,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
$this->expectException(MetadataException::class);
|
||||
$this->expectExceptionMessage('[M3]');
|
||||
|
||||
(new MetadataFactory())->forClass(SinPrimaryKey::class);
|
||||
new MetadataFactory()->forClass(SinPrimaryKey::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -107,7 +107,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
$this->expectException(MetadataException::class);
|
||||
$this->expectExceptionMessage('[M3]');
|
||||
|
||||
(new MetadataFactory())->forClass(DosPrimaryKeys::class);
|
||||
new MetadataFactory()->forClass(DosPrimaryKeys::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -116,7 +116,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
$this->expectException(MetadataException::class);
|
||||
$this->expectExceptionMessage('[M4]');
|
||||
|
||||
(new MetadataFactory())->forClass(SinTipo::class);
|
||||
new MetadataFactory()->forClass(SinTipo::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -125,7 +125,7 @@ final class MetadataFactoryTest extends TestCase
|
||||
$this->expectException(MetadataException::class);
|
||||
$this->expectExceptionMessage('[M7]');
|
||||
|
||||
(new MetadataFactory())->forClass(ColumnaDuplicada::class);
|
||||
new MetadataFactory()->forClass(ColumnaDuplicada::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -134,6 +134,6 @@ final class MetadataFactoryTest extends TestCase
|
||||
$this->expectException(MetadataException::class);
|
||||
$this->expectExceptionMessage('[M5]');
|
||||
|
||||
(new MetadataFactory())->forClass(RelacionNoNulable::class);
|
||||
new MetadataFactory()->forClass(RelacionNoNulable::class);
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -33,7 +33,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_hydrates_by_property_name(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana', 'activo' => false]);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana', 'activo' => false]);
|
||||
|
||||
self::assertSame('Ana', $usuario->nombre);
|
||||
self::assertFalse($usuario->activo);
|
||||
@@ -42,7 +42,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_hydrates_by_column_name(): void
|
||||
{
|
||||
$factura = (new Factura())->hydrate(['importe_total' => '12.5']);
|
||||
$factura = new Factura()->hydrate(['importe_total' => '12.5']);
|
||||
|
||||
self::assertSame(12.5, $factura->total);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_prefers_the_property_when_both_forms_are_present(): void
|
||||
{
|
||||
$factura = (new Factura())->hydrate(['total' => 1.0, 'importe_total' => 2.0]);
|
||||
$factura = new Factura()->hydrate(['total' => 1.0, 'importe_total' => 2.0]);
|
||||
|
||||
self::assertSame(1.0, $factura->total);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_skips_guarded_properties(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['passwordHash' => 'secreto']);
|
||||
$usuario = new Usuario()->hydrate(['passwordHash' => 'secreto']);
|
||||
|
||||
self::assertSame('', $usuario->passwordHash);
|
||||
}
|
||||
@@ -68,13 +68,13 @@ final class ModelTest extends TestCase
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
(new Usuario())->hydrateStrict(['passwordHash' => 'secreto']);
|
||||
new Usuario()->hydrateStrict(['passwordHash' => 'secreto']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_ignores_unknown_keys(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['inexistente' => 1, 'nombre' => 'Ana']);
|
||||
$usuario = new Usuario()->hydrate(['inexistente' => 1, 'nombre' => 'Ana']);
|
||||
|
||||
self::assertSame('Ana', $usuario->nombre);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_never_hydrates_the_primary_key(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['codigo' => 99]);
|
||||
$usuario = new Usuario()->hydrate(['codigo' => 99]);
|
||||
|
||||
self::assertNull($usuario->codigo);
|
||||
}
|
||||
@@ -92,13 +92,13 @@ final class ModelTest extends TestCase
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
(new Usuario())->hydrate(['activo' => 'no-es-bool']);
|
||||
new Usuario()->hydrate(['activo' => 'no-es-bool']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_serializes_writable_columns_by_column_name(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana']);
|
||||
$array = $usuario->toArray();
|
||||
|
||||
self::assertSame('Ana', $array['nombre']);
|
||||
@@ -109,7 +109,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_serializes_json(): void
|
||||
{
|
||||
$json = (new Usuario())->hydrate(['nombre' => 'Ana'])->toJson();
|
||||
$json = new Usuario()->hydrate(['nombre' => 'Ana'])->toJson();
|
||||
$decoded = json_decode($json, true);
|
||||
|
||||
self::assertIsArray($decoded);
|
||||
@@ -129,7 +129,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_reports_a_too_long_value(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['clave' => 'supercalifragilistico']);
|
||||
$usuario = new Usuario()->hydrate(['clave' => 'supercalifragilistico']);
|
||||
|
||||
self::assertStringContainsString('10', $usuario->validate()['clave'][0]);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_is_valid_when_no_rule_fails(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['clave' => 'abc']);
|
||||
$usuario = new Usuario()->hydrate(['clave' => 'abc']);
|
||||
|
||||
self::assertTrue($usuario->isValid());
|
||||
}
|
||||
@@ -145,7 +145,7 @@ final class ModelTest extends TestCase
|
||||
#[Test]
|
||||
public function it_replicates_without_the_primary_key(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana']);
|
||||
$usuario->codigo = 5;
|
||||
|
||||
$copy = $usuario->replicate();
|
||||
|
||||
@@ -31,7 +31,7 @@ final class PersisterTest extends TestCase
|
||||
public function it_inserts_and_assigns_the_generated_key(): void
|
||||
{
|
||||
$this->connection->lastInsertId = '42';
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
|
||||
$key = $this->persister->insert($usuario);
|
||||
|
||||
@@ -44,7 +44,7 @@ final class PersisterTest extends TestCase
|
||||
public function it_only_writes_writable_columns(): void
|
||||
{
|
||||
$this->connection->lastInsertId = '1';
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
|
||||
$this->persister->insert($usuario);
|
||||
|
||||
@@ -57,7 +57,7 @@ final class PersisterTest extends TestCase
|
||||
#[Test]
|
||||
public function it_saves_as_update_when_the_key_is_present(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario->codigo = 9;
|
||||
|
||||
$this->persister->save($usuario);
|
||||
@@ -69,7 +69,7 @@ final class PersisterTest extends TestCase
|
||||
public function it_saves_as_insert_when_the_key_is_absent(): void
|
||||
{
|
||||
$this->connection->lastInsertId = '3';
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
|
||||
$this->persister->save($usuario);
|
||||
|
||||
@@ -81,13 +81,13 @@ final class PersisterTest extends TestCase
|
||||
{
|
||||
$this->expectException(ValidationException::class);
|
||||
|
||||
$this->persister->insert((new Usuario())->hydrate(['nombre' => 'Ana']));
|
||||
$this->persister->insert(new Usuario()->hydrate(['nombre' => 'Ana']));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_refuses_to_write_a_partial_model(): void
|
||||
{
|
||||
$usuario = (new Usuario())->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario = new Usuario()->hydrate(['nombre' => 'Ana', 'clave' => 'abc']);
|
||||
$usuario->codigo = 1;
|
||||
$usuario->markPartial();
|
||||
|
||||
@@ -149,7 +149,7 @@ final class PersisterTest extends TestCase
|
||||
$listener,
|
||||
);
|
||||
|
||||
$persister->insert((new Usuario())->hydrate(['nombre' => 'Ana', 'clave' => 'abc']));
|
||||
$persister->insert(new Usuario()->hydrate(['nombre' => 'Ana', 'clave' => 'abc']));
|
||||
|
||||
self::assertSame([['action' => 'insert', 'pk' => 7]], $listener->calls);
|
||||
}
|
||||
|
||||
@@ -143,6 +143,6 @@ final class CriteriaCompilerTest extends TestCase
|
||||
|
||||
private function metadata(): \Camelia\Orm\Metadata\ClassMetadata
|
||||
{
|
||||
return (new MetadataFactory())->forClass(Usuario::class);
|
||||
return new MetadataFactory()->forClass(Usuario::class);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ final class QueryBuilderTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->builder = new QueryBuilder(new MySqlDialect());
|
||||
$this->usuarios = (new MetadataFactory())->forClass(Usuario::class);
|
||||
$this->usuarios = new MetadataFactory()->forClass(Usuario::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -42,7 +42,7 @@ final class QueryBuilderTest extends TestCase
|
||||
#[Test]
|
||||
public function it_excludes_relations_from_the_select_list(): void
|
||||
{
|
||||
$metadata = (new MetadataFactory())->forClass(Factura::class);
|
||||
$metadata = new MetadataFactory()->forClass(Factura::class);
|
||||
$compiled = $this->builder->select($metadata, []);
|
||||
|
||||
self::assertStringNotContainsString('`usuario`', $compiled['sql']);
|
||||
|
||||
Reference in new issue
Block a user