Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,16 @@
?string $prefix = null,
?string $separator = null,
): TableIdentifier {
$name = Type\non_empty_string()->assert($schema->value);
$enumSchema = '' === $schema::NAME ? null : $schema::NAME;
$schemas = $this->config['schemas'] ?? [];
$name = Type\non_empty_string()->assert($schema->value);

// mago infers string('') from SchemaInterface::NAME and ignores that an implementing
// enum may override it; see SchemaInterface::NAME docblock and itPreservesSchemaFromEnumConstant.
$enumSchema = '' === $schema::NAME ? null : $schema::NAME; // @mago-expect analysis:redundant-comparison, analysis:redundant-condition
$schemas = $this->config['schemas'] ?? [];

return new TableIdentifier(
table : $name,
schema : $schemaName ?? $schemas[$name] ?? $this->getBackupSchema() ?? $this->getSchema() ?? $enumSchema,

Check warning on line 104 in src/SchemaFactory.php

View workflow job for this annotation

GitHub Actions / Mutation testing

Escaped Mutant for Mutator "Coalesce": @@ @@ return new TableIdentifier( table : $name, - schema : $schemaName ?? $schemas[$name] ?? $this->getBackupSchema() ?? $this->getSchema() ?? $enumSchema, + schema : $schemaName ?? $schemas[$name] ?? $this->getBackupSchema() ?? $enumSchema ?? $this->getSchema(), prefix : $prefix ?? $this->getBackupPrefix(), separator: $separator ?? $this->getSeparator(), );
prefix : $prefix ?? $this->getBackupPrefix(),
separator: $separator ?? $this->getSeparator(),
);
Expand Down Expand Up @@ -139,10 +142,13 @@
?string $prefix = null,
?string $separator = null,
): TableIdentifier {
$name = Type\non_empty_string()->assert($schema->value);
$enumSchema = '' === $schema::NAME ? null : $schema::NAME;
$prefixes = $this->config['prefixes'] ?? [];
$schemas = $this->config['schemas'] ?? [];
$name = Type\non_empty_string()->assert($schema->value);

// mago infers string('') from SchemaInterface::NAME and ignores that an implementing
// enum may override it; see SchemaInterface::NAME docblock and itPreservesSchemaFromEnumConstant.
$enumSchema = '' === $schema::NAME ? null : $schema::NAME; // @mago-expect analysis:redundant-comparison, analysis:redundant-condition
$prefixes = $this->config['prefixes'] ?? [];
$schemas = $this->config['schemas'] ?? [];

return new TableIdentifier(
table : $name,
Expand Down
5 changes: 4 additions & 1 deletion src/Session/DbSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ public function read(string $id): string|false
->where(['id' => $id]);
$select->where->greaterThan('expires_at', date(format: self::TIMESTAMP_FORMAT));

$row = $this->sql->prepareStatementForSqlObject($select)->execute()?->current();
/** @var mixed $row */
$row = $this->sql->prepareStatementForSqlObject($select)->execute()?->current();

/** @var mixed $payload */
$payload = is_array($row) ? $row['payload'] ?? false : false;

return is_string($payload) ? $payload : false;
Expand Down
1 change: 1 addition & 0 deletions src/Session/PhpDbSessionPersistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function initializeSessionFromRequest(ServerRequestInterface $request): S
->where(['id' => $id]);
$select->where->greaterThan('expires_at', date(format: self::TIMESTAMP_FORMAT));

/** @var mixed $row */
$row = $this->sql->prepareStatementForSqlObject($select)->execute()?->current();

if (! is_array($row)) {
Expand Down
1 change: 1 addition & 0 deletions src/Session/SessionPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class SessionPayload
*/
public static function decode(string $payload): array
{
/** @var mixed $data */
$data = unserialize(data: $payload);

/** @var array<string, mixed> */
Expand Down
Loading