diff --git a/docs/persistence/sql/queries.rst b/docs/persistence/sql/queries.rst index d2528703ce..a204add96b 100644 --- a/docs/persistence/sql/queries.rst +++ b/docs/persistence/sql/queries.rst @@ -473,11 +473,11 @@ and overwrite this simple method to support expressions like this, for example: Joining with other tables ------------------------- -.. php:method:: join($foreign_table, $master_field, $join_kind) +.. php:method:: join($foreignTable, $master_field, $join_kind) Join results with additional table using "JOIN" statement in your query. - :param string|array $foreign_table: table to join (may include field and alias) + :param string|array $foreignTable: table to join (may include field and alias) :param mixed $master_field: main field (and table) to join on or Expression :param string $join_kind: 'left' (default), 'inner', 'right' etc - which join type to use :returns: $this diff --git a/src/Model/Join.php b/src/Model/Join.php index d062d8a1b6..9c1ce50635 100644 --- a/src/Model/Join.php +++ b/src/Model/Join.php @@ -33,7 +33,7 @@ class Join /** * Foreign model or WITH/CTE alias when used with SQL persistence. * - * @var Model|string + * @var string */ protected $foreign_table; @@ -119,15 +119,12 @@ class Join /** @var array> Data indexed by spl_object_id(entity) which is populated here as the save/insert progresses. */ private $saveBufferByOid = []; - /** - * @param Model|string $foreignTable - */ - public function __construct($foreignTable = null) + public function __construct(string $foreignTable = null) { $this->foreign_table = $foreignTable; // handle foreign table containing a dot - that will be reverse join - if (is_string($this->foreign_table) && strpos($this->foreign_table, '.') !== false) { + if (strpos($this->foreign_table, '.') !== false) { // split by LAST dot in foreign_table name [$this->foreign_table, $this->foreign_field] = preg_split('~\.+(?=[^.]+$)~', $this->foreign_table); $this->reverse = true; @@ -320,10 +317,9 @@ public function addFields(array $fields = [], array $defaults = []) /** * Another join will be attached to a current join. * - * @param Model|string $foreignTable * @param array $defaults */ - public function join($foreignTable, array $defaults = []): self + public function join(string $foreignTable, array $defaults = []): self { $defaults['joinName'] = $this->short_name; @@ -333,10 +329,9 @@ public function join($foreignTable, array $defaults = []): self /** * Another leftJoin will be attached to a current join. * - * @param Model|string $foreignTable * @param array $defaults */ - public function leftJoin($foreignTable, array $defaults = []): self + public function leftJoin(string $foreignTable, array $defaults = []): self { $defaults['joinName'] = $this->short_name; diff --git a/src/Model/JoinsTrait.php b/src/Model/JoinsTrait.php index ead134f8a6..02ed7d7127 100644 --- a/src/Model/JoinsTrait.php +++ b/src/Model/JoinsTrait.php @@ -5,7 +5,6 @@ namespace Atk4\Data\Model; use Atk4\Data\Exception; -use Atk4\Data\Model; /** * Provides native Model methods for join functionality. @@ -22,10 +21,9 @@ trait JoinsTrait * join will also query $foreignTable in order to find additional fields. When inserting * the record will be also added inside $foreignTable and relationship will be maintained. * - * @param Model|string $foreignTable * @param array $defaults */ - public function join($foreignTable, array $defaults = []): Join + public function join(string $foreignTable, array $defaults = []): Join { $this->assertIsModel(); @@ -49,10 +47,9 @@ public function join($foreignTable, array $defaults = []): Join * * @see join() * - * @param Model|string $foreignTable * @param array $defaults */ - public function leftJoin($foreignTable, array $defaults = []): Join + public function leftJoin(string $foreignTable, array $defaults = []): Join { $defaults['weak'] = true;