Skip to content

Commit

Permalink
refactor: remove psalm immutability
Browse files Browse the repository at this point in the history
  • Loading branch information
mecha committed Jan 24, 2024
1 parent d0f844b commit c765de9
Show file tree
Hide file tree
Showing 39 changed files with 13 additions and 134 deletions.
11 changes: 0 additions & 11 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
/**
* Creates a new column term.
*
* @psalm-pure
* @param string|ColumnTerm|Table|TableRef $arg1 The column name or term if only 1 arg is given. Otherwise, the table
* name, instance, or reference.
* @param string|null $arg2 The column name if the 1st arg is a table name, instance, or reference.
Expand Down Expand Up @@ -44,7 +43,6 @@ function col($arg1, ?string $arg2 = null): ColumnTerm
/**
* Creates a data source for a table. This is an alias for the {@link TableRef} constructor.
*
* @psalm-pure
* @param string $name The table name.
* @param string|null $alias Optional alias.
* @return TableRef The created data source.
Expand Down Expand Up @@ -84,7 +82,6 @@ function all($source): ColumnTerm
*
* Note that this creates a join with an empty table name. Be sure to call {@link Join::with()} to set the table name.
*
* @psalm-pure
* @param string $type The join type.
* @param DataSource|null $with The data source to join with.
* @param ExprInterface|null $on The condition to join on.
Expand All @@ -98,7 +95,6 @@ function using(string $type, ?DataSource $with = null, ?ExprInterface $on = null
/**
* Creates an ascending order instance for a column.
*
* @psalm-pure
* @param string|ColumnTerm $column The column name or term.
* @return Order|Group The order instance.
*/
Expand All @@ -110,7 +106,6 @@ function asc($column): Order
/**
* Creates a descending order instance for a column.
*
* @psalm-pure
* @param string|ColumnTerm $column The column name or term.
* @return Order|Group The order instance.
*/
Expand All @@ -126,7 +121,6 @@ function desc($column): Order
* three arguments, this function creates a binary expression using the first argument as the left-hand side, the second
* argument as the operator, and the third argument as the right-hand side.
*
* @psalm-pure
* @param mixed $value The value to create the term from.
* @param string|null $operator Optional operator to create a binary expression.
* @param mixed|null $value2 Optional second value to create a binary expression.
Expand All @@ -148,7 +142,6 @@ function expr($value, ?string $operator = null, $value2 = null): ExprInterface
* Creates a boolean NOT unary expression. This is an alias for calling the {@link ExprInterface::not()} method on the
* passed argument.
*
* @psalm-pure
* @param ExprInterface $expr The expression to negate.
* @return ExprInterface The created expression.
*/
Expand All @@ -161,7 +154,6 @@ function not(ExprInterface $expr): ExprInterface
* Creates a number negation unary expression. This is an alias for calling the {@link ExprInterface::not()} method on
* the passed argument.
*
* @psalm-pure
* @param ExprInterface $expr The expression to negate.
* @return ExprInterface The created expression.
*/
Expand All @@ -173,7 +165,6 @@ function neg(ExprInterface $expr): ExprInterface
/**
* Creates a distinct column term. This is an alias for calling the {@link ColumnTerm::distinct()} method on the column.
*
* @psalm-pure
* @param ColumnTerm $col The column term.
* @return ColumnTerm The distinct column term.
*/
Expand All @@ -185,7 +176,6 @@ function distinct(ColumnTerm $col): ColumnTerm
/**
* ORs a list of expressions into a single expression.
*
* @psalm-pure
* @param iterable<ExprInterface|null> $exprs The expressions to OR.
* @return ExprInterface|null The created expression.
*/
Expand All @@ -209,7 +199,6 @@ function orAll(iterable $exprs): ?ExprInterface
/**
* ANDs a list of expressions into a single expression.
*
* @psalm-pure
* @param iterable<ExprInterface|null> $exprs The expressions to AND.
* @return ExprInterface|null The created expression.
*/
Expand Down
3 changes: 0 additions & 3 deletions src/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface DataSource
/**
* Creates a copy with an alias.
*
* @psalm-mutation-free
* @param string|null $alias The string alias or null for no alias.
* @return static The new instance.
*/
Expand All @@ -21,15 +20,13 @@ public function as(?string $alias): self;
/**
* Retrieves the data source's alias, if it has one.
*
* @psalm-mutation-free
* @return string|null The string alias or null if the data source has no alias.
*/
public function getAlias(): ?string;

/**
* Compiles the source into an SQL fragment.
*
* @psalm-mutation-free
* @return string The compiled SQL fragment.
* @throws SqlCompileException If an error occurred while compiling.
*/
Expand Down
6 changes: 1 addition & 5 deletions src/DatabaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

use RebelCode\Atlas\Exception\DatabaseException;

/**
* An adapter for a database connection that allows queries created by Atlas to be executed.
*
* @psalm-immutable
*/
/** An adapter for a database connection that allows queries created by Atlas to be executed. */
interface DatabaseAdapter
{
/**
Expand Down
1 change: 0 additions & 1 deletion src/Expression/BaseExpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RebelCode\Atlas\Expression;

/** @psalm-immutable */
abstract class BaseExpr implements ExprInterface
{
protected ?string $alias = null;
Expand Down
1 change: 0 additions & 1 deletion src/Expression/BetweenExpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RebelCode\Atlas\Expression;

/** @psalm-immutable */
class BetweenExpr extends BaseExpr
{
const BETWEEN = 'BETWEEN';
Expand Down
1 change: 0 additions & 1 deletion src/Expression/BinaryExpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RebelCode\Atlas\Expression;

/** @psalm-immutable */
class BinaryExpr extends BaseExpr
{
const EQ = '=';
Expand Down
6 changes: 1 addition & 5 deletions src/Expression/ColumnTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace RebelCode\Atlas\Expression;

/**
* An expression that represents a column name.
*
* @psalm-immutable
*/
/** An expression that represents a column name. */
class ColumnTerm extends BaseExpr
{
protected ?string $table;
Expand Down
1 change: 0 additions & 1 deletion src/Expression/ExprInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RebelCode\Atlas\Expression;

/** @psalm-immutable */
interface ExprInterface
{
/**
Expand Down
6 changes: 1 addition & 5 deletions src/Expression/FnExpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace RebelCode\Atlas\Expression;

/**
* Represents a SQL function expression.
*
* @psalm-immutable
*/
/** Represents a SQL function expression. */
class FnExpr extends BaseExpr
{
protected string $name;
Expand Down
8 changes: 1 addition & 7 deletions src/Expression/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use InvalidArgumentException;
use Traversable;

/** @psalm-immutable */
class Term extends BaseExpr
{
public const NUMBER = 0;
Expand Down Expand Up @@ -77,8 +76,6 @@ protected function toBaseString(): string
/**
* Creates a term from a value, automatically detecting the type.
*
* @psalm-mutation-free
*
* @param mixed $value
* @return ExprInterface
*/
Expand All @@ -103,10 +100,7 @@ public static function create($value): ExprInterface
return new self($type, $value);
}

/**
* @psalm-mutation-free
* @psalm-return Term::*
*/
/** @psalm-return Term::* */
public static function detectType($value): int
{
$type = gettype($value);
Expand Down
1 change: 0 additions & 1 deletion src/Expression/UnaryExpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace RebelCode\Atlas\Expression;

/** @psalm-immutable */
class UnaryExpr extends BaseExpr
{
public const NOT = '!';
Expand Down
1 change: 0 additions & 1 deletion src/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use RebelCode\Atlas\Expression\ExprInterface;

/** @psalm-immutable */
class Join
{
const INNER = 'INNER';
Expand Down
1 change: 0 additions & 1 deletion src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use RebelCode\Atlas\Expression\ColumnTerm;

/** @psalm-immutable */
class Order
{
public const ASC = 'ASC';
Expand Down
2 changes: 0 additions & 2 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use RebelCode\Atlas\Exception\DatabaseException;
use RebelCode\Atlas\Exception\QuerySqlException;

/** @psalm-immutable */
abstract class Query
{
protected ?DatabaseAdapter $adapter;
Expand Down Expand Up @@ -39,7 +38,6 @@ protected function getAdapter(): DatabaseAdapter
/**
* Compiles the query into an SQL string.
*
* @psalm-mutation-free
* @return string The compiled SQL string.
* @throws QuerySqlException If an error occurred while compiling the SQL.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Query/CompoundQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*
* This is intended to allow multiple queries to be executed in a single call to the database adapter. Rendering the
* queries to SQL will concatenate the SQL of each query and a semicolon after each query.
*
* @psalm-immutable
*/
class CompoundQuery extends Query
{
Expand Down
6 changes: 1 addition & 5 deletions src/Query/CreateIndexQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use RebelCode\Atlas\Schema\Index;
use Throwable;

/** @psalm-immutable */
class CreateIndexQuery extends Query
{
protected string $table;
Expand All @@ -37,10 +36,7 @@ public function __construct(
$this->index = $index;
}

/**
* @inheritDoc
* @psalm-mutation-free
*/
/** @inheritDoc */
public function toSql(): string
{
try {
Expand Down
8 changes: 1 addition & 7 deletions src/Query/CreateTableQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Throwable;
use UnexpectedValueException;

/** @psalm-immutable */
class CreateTableQuery extends Query
{
protected string $name;
Expand Down Expand Up @@ -41,10 +40,7 @@ public function __construct(
$this->collate = $collate;
}

/**
* @inheritDoc
* @psalm-mutation-free
*/
/** @inheritDoc */
public function toSql(): string
{
try {
Expand Down Expand Up @@ -75,8 +71,6 @@ public function toSql(): string
/**
* Compiles the schema for a table.
*
* @psalm-mutation-free
*
* @param Schema $schema The table schema.
* @return string
*/
Expand Down
7 changes: 1 addition & 6 deletions src/Query/DeleteQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use RebelCode\Atlas\Query;
use Throwable;

/** @psalm-immutable */
class DeleteQuery extends Query
{
use Query\Traits\HasWhereTrait;
Expand Down Expand Up @@ -45,7 +44,6 @@ public function __construct(
/**
* Creates a copy with a different FROM clause.
*
* @psalm-mutation-free
* @param string $from The table name.
* @return static The new instance.
*/
Expand All @@ -56,10 +54,7 @@ public function from(string $from): self
return $clone;
}

/**
* @inheritDoc
* @psalm-mutation-free
*/
/** @inheritDoc */
public function toSql(): string
{
try {
Expand Down
6 changes: 1 addition & 5 deletions src/Query/DropTableQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use RebelCode\Atlas\Query;
use Throwable;

/** @psalm-immutable */
class DropTableQuery extends Query
{
protected string $table;
Expand All @@ -35,10 +34,7 @@ public function __construct(
$this->cascade = $cascade;
}

/**
* @inheritDoc
* @psalm-mutation-free
*/
/** @inheritDoc */
public function toSql(): string
{
try {
Expand Down
Loading

0 comments on commit c765de9

Please sign in to comment.