diff --git a/CHANGELOG.md b/CHANGELOG.md index 71def4435..c8c3af159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## 1.0.1 under development -- no changes in this release. +- Bug #527: Fix PHPDoc tags `@see` (@mspirkov) ## 1.0.0 December 09, 2025 -- Initial release. \ No newline at end of file +- Initial release. diff --git a/src/AbstractActiveRecord.php b/src/AbstractActiveRecord.php index 701780b4d..878693f6b 100644 --- a/src/AbstractActiveRecord.php +++ b/src/AbstractActiveRecord.php @@ -794,7 +794,7 @@ abstract protected function populateProperty(string $name, mixed $value): void; /** * Internal method to insert or update a record in the database. * - * @see upsert() + * @see AbstractActiveRecord::upsert() */ abstract protected function upsertInternal( ?array $insertProperties = null, @@ -823,8 +823,8 @@ protected function retrieveRelation(string $name): ActiveRecordInterface|array|n * @psalm-param ModelClass $modelClass * @psalm-param array $link * - * {@see hasOne()} - * {@see hasMany()} + * @see AbstractActiveRecord::hasOne() + * @see AbstractActiveRecord::hasMany() */ protected function createRelationQuery( ActiveRecordInterface|string $modelClass, @@ -835,12 +835,12 @@ protected function createRelationQuery( } /** - * {@see delete()} - * * @throws Exception * @throws Throwable * * @return int The number of rows deleted. + * + * @see AbstractActiveRecord::delete() */ protected function deleteInternal(): int { @@ -875,7 +875,7 @@ protected function deleteInternal(): int * You may specify the properties to be returned as list of name or name-value pairs. * If name-value pair specified, the corresponding property values will be modified. * - * Only the {@see newValues() changed property values} will be returned. + * Only the {@see AbstractActiveRecord::newValues() changed property values} will be returned. * * @param array|null $properties List of property names or name-values pairs that need to be returned. * Defaults to `null`, meaning all changed property values will be returned. @@ -911,7 +911,7 @@ protected function newPropertyValues(?array $properties = null): array * * @return bool Whether refresh was successful. * - * {@see refresh()} + * @see AbstractActiveRecord::refresh() */ protected function refreshInternal(array|ActiveRecordInterface|null $record = null): bool { @@ -931,14 +931,14 @@ protected function refreshInternal(array|ActiveRecordInterface|null $record = nu } /** - * {@see update()} - * * @param array|null $properties Property names or name-values pairs to update, `null` means all properties. * * @throws Exception * @throws NotSupportedException * * @return int The number of rows affected. + * + * @see AbstractActiveRecord::update() */ protected function updateInternal(?array $properties = null): int { diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index 8dabebdaa..b18b94507 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -15,6 +15,7 @@ use Yiisoft\ActiveRecord\Internal\RelationPopulator; use Yiisoft\ActiveRecord\Internal\TableNameAndAliasResolver; use Yiisoft\ActiveRecord\Internal\Typecaster; +use Yiisoft\ActiveRecord\Trait\RepositoryTrait; use Yiisoft\Db\Command\CommandInterface; use Yiisoft\Db\Exception\Exception; use Yiisoft\Db\Exception\InvalidConfigException; @@ -47,35 +48,36 @@ * * An ActiveQuery can be a normal query or be used in a relational context. * - * ActiveQuery instances are usually created by {@see findOne()}, {@see findBySql()}, {@see findAll()}. + * ActiveQuery instances are usually created by {@see RepositoryTrait::findOne()}, + * {@see RepositoryTrait::findBySql()}, {@see RepositoryTrait::findAll()}. * - * Relational queries are created by {@see ActiveRecord::hasOne()} and {@see ActiveRecord::hasMany()}. + * Relational queries are created by {@see ActiveRecordInterface::hasOne()} and {@see ActiveRecordInterface::hasMany()}. * * Normal Query * ------------ * * ActiveQuery mainly provides the following methods to retrieve the query results: * - * - {@see one()}: returns a single record populated with the first row of data. - * - {@see all()}: returns all records based on the query results. - * - {@see count()}: returns the number of records. - * - {@see sum()}: returns the sum over the specified column. - * - {@see average()}: returns the average over the specified column. - * - {@see min()}: returns the min over the specified column. - * - {@see max()}: returns the max over the specified column. - * - {@see scalar()}: returns the value of the first column in the first row of the query result. - * - {@see column()}: returns the value of the first column in the query result. - * - {@see exists()}: returns a value indicating whether the query result has data or not. + * - {@see Query::one()}: returns a single record populated with the first row of data. + * - {@see Query::all()}: returns all records based on the query results. + * - {@see Query::count()}: returns the number of records. + * - {@see Query::sum()}: returns the sum over the specified column. + * - {@see Query::average()}: returns the average over the specified column. + * - {@see Query::min()}: returns the min over the specified column. + * - {@see Query::max()}: returns the max over the specified column. + * - {@see Query::scalar()}: returns the value of the first column in the first row of the query result. + * - {@see Query::column()}: returns the value of the first column in the query result. + * - {@see Query::exists()}: returns a value indicating whether the query result has data or not. * - * Because ActiveQuery extends from {@see Query}, one can use query methods, such as {@see where()}, {@see orderBy()} to - * customize the query options. + * Because ActiveQuery extends from {@see Query}, one can use query methods, such as {@see Query::where()}, + * {@see Query::orderBy()} to customize the query options. * * ActiveQuery also provides the following more query options: * - * - {@see with()}: list of relations that this query should be performed with. - * - {@see joinWith()}: reuse a relation query definition to add a join to a query. - * - {@see indexBy()}: the name of the column by which the query result should be indexed. - * - {@see asArray()}: whether to return each record as an array. + * - {@see ActiveQuery::with()}: list of relations that this query should be performed with. + * - {@see ActiveQuery::joinWith()}: reuse a relation query definition to add a join to a query. + * - {@see Query::indexBy()}: the name of the column by which the query result should be indexed. + * - {@see ActiveQuery::asArray()}: whether to return each record as an array. * * These options can be configured using methods of the same name. For example: * @@ -89,17 +91,19 @@ * * In relational context, ActiveQuery represents a relation between two Active Record classes. * - * Relational ActiveQuery instances are usually created by calling {@see ActiveRecord::hasOne()} and - * {@see ActiveRecord::hasMany()}. An Active Record class declares a relation by defining a getter method which calls + * Relational ActiveQuery instances are usually created by calling {@see ActiveRecordInterface::hasOne()} and + * {@see ActiveRecordInterface::hasMany()}. An Active Record class declares a relation by defining a getter method which calls * one of the above methods and returns the created ActiveQuery object. * - * A relation is specified by {@see link()} which represents the association between columns of different tables; and - * the multiplicity of the relation is indicated by {@see multiple()}. + * A relation is specified by {@see ActiveQuery::link()} which represents the association between columns + * of different tables; and the multiplicity of the relation is indicated by {@see ActiveQuery::multiple()}. * - * If a relation involves a junction table, it may be specified by {@see via()} or {@see viaTable()} method. + * If a relation involves a junction table, it may be specified by {@see ActiveQuery::via()} + * or {@see ActiveQuery::viaTable()} method. * - * These methods may only be called in a relational context. The same is true for {@see inverseOf()}, which marks a relation - * as inverse of another relation and {@see onCondition()} which adds a condition that is to be added to relational + * These methods may only be called in a relational context. The same is true for + * {@see ActiveQuery::inverseOf()}, which marks a relation as inverse of another relation + * and {@see ActiveQuery::on()} which adds a condition that is to be added to relational * query join condition. * * @psalm-type ModelClass = ActiveRecordInterface|class-string @@ -140,7 +144,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface * * This property is only used in relational context. * - * @see inverseOf() + * @see ActiveQuery::inverseOf() */ private ?string $inverseOf = null; @@ -638,7 +642,7 @@ public function link(array $value): static } /** - * Queries a scalar value by setting {@see select()} first. + * Queries a scalar value by setting {@see Query::select()} first. * * Restores the value of select to make this query reusable. * @@ -786,8 +790,8 @@ private function populateOne(array $row): ActiveRecordInterface|array /** * Finds records corresponding to one or multiple relations and populates them into the primary models. * - * @param array $with a list of relations that this query should be performed with. Please refer to {@see with()} - * for details about specifying this parameter. + * @param array $with a list of relations that this query should be performed with. Please refer + * to {@see ActiveQuery::with()} for details about specifying this parameter. * @param ActiveRecordInterface[]|array[] $models the primary models (can be either AR instances or arrays) * * @throws Exception @@ -865,7 +869,8 @@ private function normalizeRelations(ActiveRecordInterface $model, array $with): /** * If applicable, populate the query's primary model into the related records' inverse relationship. * - * @param ActiveRecordInterface[]|array[] $result the array of related records as generated by {@see populate()} + * @param ActiveRecordInterface[]|array[] $result the array of related records as generated + * by {@see ActiveQuery::populate()} * * @throws InvalidConfigException * diff --git a/src/ActiveQueryInterface.php b/src/ActiveQueryInterface.php index 55f830fce..214646d0e 100644 --- a/src/ActiveQueryInterface.php +++ b/src/ActiveQueryInterface.php @@ -13,6 +13,7 @@ use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Expression\ExpressionInterface; use Yiisoft\Db\Query\QueryInterface; +use Yiisoft\Db\Query\QueryPartsInterface; use Yiisoft\Definitions\Exception\CircularReferenceException; use Yiisoft\Definitions\Exception\NotInstantiableException; @@ -35,7 +36,8 @@ interface ActiveQueryInterface extends QueryInterface * @throws Throwable * * @return ActiveRecordInterface[]|array[] All rows of the query result. Each array element is an `array` or - * instance of {@see ActiveRecordInterface} representing a row of data, depends on {@see isAsArray()} result. + * instance of {@see ActiveRecordInterface} representing a row of data, depends + * on {@see ActiveQueryInterface::isAsArray()} result. * Empty array if the query results in nothing. * * @psalm-return array @@ -43,7 +45,7 @@ interface ActiveQueryInterface extends QueryInterface public function all(): array; /** - * Sets the {@see asArray} property. + * Sets the {@see ActiveQuery::$asArray} property. * * @param bool|null $value Whether to return the query results in terms of arrays instead of Active Records. * @@ -57,8 +59,8 @@ public function asArray(?bool $value = true): static; * The parameters to this method can be either one or multiple strings, or a single array of relation names and the * optional callbacks to customize the relations. * - * A relation name can refer to a relation defined in {@see modelClass} or a sub-relation that stands for a relation - * of a related record. + * A relation name can refer to a relation defined in {@see ActiveQuery::$model} or a sub-relation that stands + * for a relation of a related record. * * For example, `orders.address` means the `address` relation defined in the model class corresponding to the * `orders` relation. @@ -102,8 +104,8 @@ public function getWith(): array; /** * Resets the relations that this query should be performed with. * - * This method clears all relations set via {@see with()} and disables eager loading for relations - * set via {@see joinWith()}, while keeping the JOIN clauses intact. + * This method clears all relations set via {@see ActiveQueryInterface::with()} and disables eager + * loading for relations set via {@see ActiveQueryInterface::joinWith()}, while keeping the JOIN clauses intact. * * @return static The query object itself. */ @@ -127,7 +129,8 @@ public function resetWith(): static; * } * ``` * - * @param string $relationName The relation name. This refers to a relation declared in {@see primaryModel}. + * @param string $relationName The relation name. This refers to a relation declared + * in {@see ActiveQueryInterface::primaryModel()}. * @param callable|null $callable A PHP callback for customizing the relation associated with the junction table. * Its signature should be `function($query)`, where `$query` is the query to be customized. * @@ -140,12 +143,12 @@ public function resetVia(): static; /** * @return array|ExpressionInterface|string|null the join condition to be used when this query is used in a relational context. * - * The condition will be used in the ON part when {@see joinWith()} is called. Otherwise, the condition will be used - * in the `WHERE` part of a query. + * The condition will be used in the ON part when {@see ActiveQueryInterface::joinWith()} is called. Otherwise, + * the condition will be used in the `WHERE` part of a query. * * Please refer to {@see Query::where()} on how to specify this parameter. * - * @see on() + * @see ActiveQueryInterface::on() */ public function getOn(): array|ExpressionInterface|string|null; @@ -162,12 +165,13 @@ public function getJoinsWith(): array; * the specified relation(s), the method will append one or many `JOIN` statements to the current query. * * If the `$eagerLoading` parameter is true, the method will also perform eager loading for the specified relations, - * which is equal to calling {@see with()} using the specified relations. + * which is equal to calling {@see ActiveQueryInterface::with()} using the specified relations. * * Note: That because a `JOIN` query will be performed, you're responsible for disambiguated column names. * - * This method differs from {@see with()} in that it will build up and execute a `JOIN` SQL statement for the primary - * table. And when `$eagerLoading` is true, it will call {@see with()} also with the specified relations. + * This method differs from {@see ActiveQueryInterface::with()} in that it will build up and execute a `JOIN` SQL + * statement for the primary table. And when `$eagerLoading` is true, it will + * call {@see ActiveQueryInterface::with()} also with the specified relations. * * Note: Relations specified in `$with` cannot have `GROUP BY`, `HAVING`, or `UNION` clauses. Using these clauses * will result in a {@see \LogicException}. @@ -182,7 +186,7 @@ public function getJoinsWith(): array; * * The relation name may optionally contain an alias for the relation table (for example, `books b`). * - * Sub-relations can also be specified, see {@see with()} for the syntax. + * Sub-relations can also be specified, see {@see ActiveQueryInterface::with()} for the syntax. * * In the following, you find some examples: * @@ -226,16 +230,16 @@ public function resetJoinsWith(): void; /** * Inner joins with the specified relations. * - * This is a shortcut method to {@see joinWith()} with the join type set as "INNER JOIN". + * This is a shortcut method to {@see ActiveQueryInterface::joinWith()} with the join type set as "INNER JOIN". * - * Please refer to {@see joinWith()} for detailed usage of this method. + * Please refer to {@see ActiveQueryInterface::joinWith()} for detailed usage of this method. * * @param array|string $with The relations to be joined with. * @param array|bool $eagerLoading Whether to eager load the relations. * Note: That this doesn't mean that the relations are populated from the query result. * An extra query will still be performed to bring in the related data. * - * @see joinWith() + * @see ActiveQueryInterface::joinWith() * * @psalm-param array|string $with */ @@ -244,7 +248,7 @@ public function innerJoinWith(array|string $with, array|bool $eagerLoading = tru /** * Sets the ON condition for a relational query. * - * The condition will be used in the ON part when {@see joinWith()} is called. + * The condition will be used in the ON part when {@see ActiveQueryInterface::joinWith()} is called. * * Otherwise, the condition will be used in the `WHERE` part of a query. * @@ -253,7 +257,7 @@ public function innerJoinWith(array|string $with, array|bool $eagerLoading = tru * ```php * public function getActiveUsers(): ActiveQuery * { - * return $this->hasMany(User::class, ['id' => 'user_id'])->onCondition(['active' => true]); + * return $this->hasMany(User::class, ['id' => 'user_id'])->on(['active' => true]); * } * ``` * @@ -272,12 +276,12 @@ public function on(array|ExpressionInterface|string $condition, array $params = * * The new condition and the existing one will be joined using the `AND` operator. * - * @param array|ExpressionInterface|string $condition The new `ON` condition. Please refer to {@see where()} on how - * to specify this parameter. + * @param array|ExpressionInterface|string $condition The new `ON` condition. Please refer + * to {@see Query::where()} on how to specify this parameter. * @param array $params the parameters (name => value) to be bound to the query. * - * @see on() - * @see orOn() + * @see ActiveQueryInterface::on() + * @see ActiveQueryInterface::orOn() */ public function andOn(array|ExpressionInterface|string $condition, array $params = []): static; @@ -286,12 +290,12 @@ public function andOn(array|ExpressionInterface|string $condition, array $params * * The new condition and the existing one will be joined using the `OR` operator. * - * @param array|ExpressionInterface|string $condition The new `ON` condition. Please refer to {@see where()} on how - * to specify this parameter. + * @param array|ExpressionInterface|string $condition The new `ON` condition. Please refer + * to {@see Query::where()} on how to specify this parameter. * @param array $params The parameters (name => value) to be bound to the query. * - * @see on() - * @see andOn() + * @see ActiveQueryInterface::on() + * @see ActiveQueryInterface::andOn() */ public function orOn(array|ExpressionInterface|string $condition, array $params = []): static; @@ -308,24 +312,24 @@ public function orOn(array|ExpressionInterface|string $condition, array $params * ``` * * @param string $tableName The name of the junction table. - * @param string[] $link The link between the junction table and the table associated with {@see primaryModel}. - * The keys of the array represent the columns in the junction table, and the values represent the columns in the - * {@see primaryModel} table. + * @param string[] $link The link between the junction table and the table associated + * with {@see ActiveQueryInterface::primaryModel()}. The keys of the array represent the columns in the + * junction table, and the values represent the columns in the {@see ActiveQueryInterface::primaryModel()} table. * @param callable|null $callable A PHP callback for customizing the relation associated with the junction table. * Its signature should be `function($query)`, where `$query` is the query to be customized. * * @psalm-param array $link * - * @see via() + * @see ActiveQueryInterface::via() */ public function viaTable(string $tableName, array $link, ?callable $callable = null): static; /** * Define an alias for the table defined in {@see ActiveRecordInterface}. * - * This method will adjust {@see from()} so that an already defined alias will be overwritten. + * This method will adjust {@see QueryPartsInterface::from()} so that an already defined alias will be overwritten. * - * If none was defined, {@see from()} will be populated with the given alias. + * If none was defined, {@see QueryPartsInterface::from()} will be populated with the given alias. * * @param string $alias The table alias. * @@ -336,7 +340,7 @@ public function viaTable(string $tableName, array $link, ?callable $callable = n public function alias(string $alias): static; /** - * Returns table names used in {@see from} indexed by aliases. + * Returns table names used in {@see QueryPartsInterface::from()} indexed by aliases. * * Both aliases and names are enclosed into `{{` and `}}`. * @@ -512,18 +516,18 @@ public function link(array $value): static; * * @param bool $value Whether this query represents a relation to more than one record. * This property is only used in relational context. If true, this relation will populate all query results into AR - * instances using {@see all()}. - * If false, only the first row of the results will be retrieved using {@see one()}. + * instances using {@see ActiveQueryInterface::all()}. + * If false, only the first row of the results will be retrieved using {@see ActiveQueryInterface::one()}. */ public function multiple(bool $value): static; /** * @return ActiveQueryInterface|array|null The query associated with the junction table. - * Please call {@see via()} to set this property instead of directly setting it. + * Please call {@see ActiveQueryInterface::via()} to set this property instead of directly setting it. * * This property is only used in relational context. * - * @see via() + * @see ActiveQueryInterface::via() * * @psalm-return Via|null */ @@ -559,9 +563,10 @@ public function getPrimaryModel(): ?ActiveRecordInterface; * * This property is only used in relational context. * - * If `true`, this relation will populate all query results into active record instances using {@see all()}. + * If `true`, this relation will populate all query results into active record instances + * using {@see ActiveQueryInterface::all()}. * - * If `false`, only the first row of the results will be retrieved using {@see one()}. + * If `false`, only the first row of the results will be retrieved using {@see ActiveQueryInterface::one()}. */ public function isMultiple(): bool; @@ -576,7 +581,7 @@ public function isMultiple(): bool; * @throws Throwable * * @return ActiveRecordInterface|array|null The first row as an `array` or instance of {@see ActiveRecordInterface} - * of the query result, depends on {@see isAsArray()} result. `null` if the query results in nothing. + * of the query result, depends on {@see ActiveQueryInterface::isAsArray()} result. `null` if the query results in nothing. */ public function one(): array|ActiveRecordInterface|null; @@ -587,8 +592,8 @@ public function one(): array|ActiveRecordInterface|null; * @param ActiveRecordInterface[]|array[] $primaryModels Primary models. * * @throws Exception - * @throws InvalidArgumentException|InvalidConfigException|NotSupportedException|Throwable If {@see link()} is - * invalid. + * @throws InvalidArgumentException|InvalidConfigException|NotSupportedException|Throwable If + * {@see ActiveQueryInterface::link()} is invalid. * @return ActiveRecordInterface[]|array[] The related models. * * @psalm-param non-empty-list $primaryModels diff --git a/src/ActiveRecordInterface.php b/src/ActiveRecordInterface.php index 0099203d0..fcf37768a 100644 --- a/src/ActiveRecordInterface.php +++ b/src/ActiveRecordInterface.php @@ -100,7 +100,7 @@ public function deleteAll(array $condition = []): int; * Returns a value indicating whether the given active record is the same as the current one. * * The comparison is made by comparing the table names and the primary key values of the two active records. If one - * of the records {@see isNew} they're also considered not equal. + * of the records {@see ActiveRecordInterface::isNew()} they're also considered not equal. * * @param self $record Record to compare to. * @@ -117,7 +117,7 @@ public function equals(self $record): bool; * * @return mixed The property value. `null` if the property isn't set or doesn't exist. * - * @see hasProperty() + * @see ActiveRecordInterface::hasProperty() */ public function get(string $propertyName): mixed; @@ -125,7 +125,7 @@ public function get(string $propertyName): mixed; * Returns property values. * * @param array|null $names List of property names whose value needs to be returned. Defaults to `null`, meaning all - * properties listed in {@see propertyNames()} will be returned. + * properties listed in {@see ActiveRecordInterface::propertyNames()} will be returned. * @param array $except List of property names whose value shouldn't be returned. * * @throws Exception @@ -140,7 +140,7 @@ public function propertyValues(?array $names = null, array $except = []): array; /** * Returns a value indicating whether the current record is new (not saved in the database). * - * @return bool Whether the record is new and should be inserted when calling {@see save()}. + * @return bool Whether the record is new and should be inserted when calling {@see ActiveRecordInterface::save()}. */ public function isNew(): bool; @@ -153,7 +153,7 @@ public function isNew(): bool; * * @return mixed The old property value. `null` if the property is not loaded before or doesn't exist. * - * @see hasProperty() + * @see ActiveRecordInterface::hasProperty() */ public function oldValue(string $propertyName): mixed; @@ -163,11 +163,11 @@ public function oldValue(string $propertyName): mixed; * This refers to the primary key value that is populated into the record after data is retrieved from the database * by an instance of {@see ActiveQueryInterface}. * - * The value remains unchanged while the record will not be {@see update() updated}. + * The value remains unchanged while the record will not be {@see ActiveRecordInterface::update() updated}. * * @throw Exception If multiple primary keys or no primary key. * - * @see primaryKeyOldValues() + * @see ActiveRecordInterface::primaryKeyOldValues() */ public function primaryKeyOldValue(): float|int|string|null; @@ -177,11 +177,11 @@ public function primaryKeyOldValue(): float|int|string|null; * This refers to the primary key values that is populated into the record after data is retrieved from the database * by an instance of {@see ActiveQueryInterface}. * - * The value remains unchanged while the record will not be {@see update() updated}. + * The value remains unchanged while the record will not be {@see ActiveRecordInterface::update() updated}. * * @throw Exception If no primary key or multiple primary keys. * - * @see primaryKeyOldValues() + * @see ActiveRecordInterface::primaryKeyOldValues() * * @psalm-return array */ @@ -192,14 +192,14 @@ public function primaryKeyOldValues(): array; * * @throw Exception If multiple primary keys or no primary key. * - * @see primaryKeyValues() + * @see ActiveRecordInterface::primaryKeyValues() */ public function primaryKeyValue(): float|int|string|null; /** * Returns the values of the primary key as an array with property names as keys and property values as values. * - * @see primaryKeyValue() + * @see ActiveRecordInterface::primaryKeyValue() * * @psalm-return array */ @@ -256,7 +256,7 @@ public function loadDefaultValues(bool $skipIfSet = true): static; * * @return array An array of related records indexed by relation names. * - * @see relationQuery() + * @see ActiveRecordInterface::relationQuery() */ public function relatedRecords(): array; @@ -346,7 +346,7 @@ public function hasOne(self|string $modelClass, array $link): ActiveQueryInterfa * You may specify the properties to be inserted as list of name or name-value pairs. * If name-value pair specified, the corresponding property values will be modified. * - * Only the {@see newValues()} changed property values will be inserted into a database. + * Only the {@see ActiveRecordInterface::newValues()} changed property values will be inserted into a database. * * If the table's primary key is auto incremental and is `null` during insertion, it will be populated with the * actual value after insertion. @@ -369,14 +369,14 @@ public function hasOne(self|string $modelClass, array $link): ActiveQueryInterfa * @param array|null $properties List of property names or name-values pairs that need to be saved. * Defaults to `null`, meaning all changed property values will be saved. * - * @throws InvalidCallException If the record {@see isNew() is not new}. + * @throws InvalidCallException If the record {@see ActiveRecordInterface::isNew() is not new}. * @throws InvalidConfigException * @throws Throwable In case insert failed. */ public function insert(?array $properties = null): void; /** - * Checks if any property returned by {@see propertyNames()} method has changed. + * Checks if any property returned by {@see ActiveRecordInterface::propertyNames()} method has changed. * A new active record instance is considered changed if any property has been set including default values. */ public function isChanged(): bool; @@ -416,7 +416,7 @@ public function isPropertyChangedNonStrict(string $name): bool; * * @return bool Whether relation has been populated with records. * - * {@see relationQuery()} + * @see ActiveRecordInterface::relationQuery() */ public function isRelationPopulated(string $name): bool; @@ -495,7 +495,8 @@ public function relation(string $name): self|array|null; * A relation is defined by a getter method which returns an object implementing the {@see ActiveQueryInterface} * (normally this would be a relational {@see ActiveQuery} object). * - * Relations can be defined using {@see hasOne()} and {@see hasMany()} methods. For example: + * Relations can be defined using {@see ActiveRecordInterface::hasOne()} and + * {@see ActiveRecordInterface::hasMany()} methods. For example: * * ```php * public function relationQuery(string $name): ActiveQueryInterface @@ -528,10 +529,10 @@ public function resetRelation(string $name): void; * You may specify the properties to be updated as list of name or name-value pairs. * If name-value pair specified, the corresponding property values will be modified. * - * Only the {@see newValues()} changed property values will be saved into a database. + * Only the {@see ActiveRecordInterface::newValues()} changed property values will be saved into a database. * - * This method will call {@see insert()} when {@see isNew()} is true, or {@see update()} when - * {@see isNew()} is false. + * This method will call {@see ActiveRecordInterface::insert()} when {@see ActiveRecordInterface::isNew()} + * is true, or {@see ActiveRecordInterface::update()} when {@see ActiveRecordInterface::isNew()} is false. * * For example, to save a customer record: * @@ -563,20 +564,20 @@ public function save(?array $properties = null): void; public function set(string $propertyName, mixed $value): void; /** - * Marks this record as new. The record should be inserted when calling {@see save()}. + * Marks this record as new. The record should be inserted when calling {@see ActiveRecordInterface::save()}. * - * @see isNew() - * @see markAsExisting() + * @see ActiveRecordInterface::isNew() + * @see ActiveRecordInterface::markAsExisting() */ public function markAsNew(): void; /** - * Marks this record as existing. The record should be updated when calling {@see save()}. + * Marks this record as existing. The record should be updated when calling {@see ActiveRecordInterface::save()}. * * Note: all current properties will be considered unchanged after calling this method. * - * @see isNew() - * @see markAsNew() + * @see ActiveRecordInterface::isNew() + * @see ActiveRecordInterface::markAsNew() */ public function markAsExisting(): void; @@ -587,7 +588,7 @@ public function markAsExisting(): void; * * The method will then save the specified properties into a database. * - * Only the {@see newValues()} changed property values will be saved into a database. + * Only the {@see ActiveRecordInterface::newValues()} changed property values will be saved into a database. * * For example, to update a customer record: * @@ -619,7 +620,7 @@ public function markAsExisting(): void; * @param array|null $properties List of property names or name-values pairs that need to be saved. * Defaults to `null`, meaning all changed property values will be saved. * - * @throws InvalidCallException If the record {@see isNew() is new}. + * @throws InvalidCallException If the record {@see ActiveRecordInterface::isNew() is new}. * @throws OptimisticLockException If the instance implements {@see OptimisticLockInterface} and the data being * updated is outdated. * @throws Throwable In case update failed. @@ -671,7 +672,7 @@ public function updateAll(array $propertyValues, array|string $condition = [], a * Insert a row into the associated database table if the record doesn't already exist (matching unique constraints) * or update the record if it exists, with populating model by the returning record values. * - * Only the {@see newValues()} changed property values will be inserted or updated. + * Only the {@see ActiveRecordInterface::newValues()} changed property values will be inserted or updated. * * If the table's primary key is auto incremental and is `null` during execution, it will be populated with the * actual value after insertion or update. @@ -740,10 +741,10 @@ public function unlink(string $relationName, self $linkedModel, bool $delete = f public function unlinkAll(string $relationName, bool $delete = false): void; /** - * Updates one or several counters for the current AR object. + * Updates one or several counters for the current active record object. * - * Note that this method differs from {@see updateAllCounters()} in that it only saves counters for the current AR - * object. + * Note that this method differs from {@see ActiveRecordInterface::updateAllCounters()} in that it only + * saves counters for the current active record object. * * An example usage is as follows: * @@ -757,7 +758,7 @@ public function unlinkAll(string $relationName, bool $delete = false): void; * * @psalm-param array $counters * - * @see updateAllCounters() + * @see ActiveRecordInterface::updateAllCounters() */ public function updateCounters(array $counters): void; @@ -808,7 +809,7 @@ public function oldValues(): array; * The comparison of new and old values uses `===`. * * @param array|null $propertyNames The names of the properties whose values may be returned if they're changed - * recently. If `null`, {@see propertyNames()} will be used. + * recently. If `null`, {@see ActiveRecordInterface::propertyNames()} will be used. * * @return array The changed property values (name-value pairs). * @@ -819,8 +820,8 @@ public function newValues(?array $propertyNames = null): array; /** * Marks a property as changed. * - * This method may be called to force updating a record when calling {@see update()}, even if there is no change - * being made to the record. + * This method may be called to force updating a record when calling {@see ActiveRecordInterface::update()}, + * even if there is no change being made to the record. * * @param string $name The property name. */ @@ -847,7 +848,7 @@ public function populateRecord(array|object $row): static; * * @param array $values Property values (name => value) to be assigned to the model. * - * @see propertyNames() + * @see ActiveRecordInterface::propertyNames() * * @psalm-param array $values */ @@ -860,7 +861,7 @@ public function populateProperties(array $values): void; * * @throws InvalidArgumentException If the named property doesn't exist. * - * @see hasProperty() + * @see ActiveRecordInterface::hasProperty() */ public function assignOldValue(string $propertyName, mixed $value): void; @@ -870,7 +871,7 @@ public function assignOldValue(string $propertyName, mixed $value): void; * All existing old property values will be discarded. * * @param array|null $propertyValues Old property values (name => value) to be set. If set to `null` this record - * is {@see isNew()}. + * is {@see ActiveRecordInterface::isNew()}. */ public function assignOldValues(?array $propertyValues = null): void; } diff --git a/src/Event/AbstractEvent.php b/src/Event/AbstractEvent.php index 310f32f2d..ab54c92b7 100644 --- a/src/Event/AbstractEvent.php +++ b/src/Event/AbstractEvent.php @@ -28,7 +28,7 @@ public function __construct( /** * Returns the value that will be returned by the method that triggered this event - * if the {@see isDefaultPrevented() default action is prevented}. + * if the {@see AbstractEvent::isDefaultPrevented() default action is prevented}. */ public function getReturnValue(): mixed { @@ -51,7 +51,7 @@ public function isPropagationStopped(): bool /** * Prevents the default action associated with this event from being executed. * - * @see returnValue() + * @see AbstractEvent::returnValue() */ public function preventDefault(): void { @@ -60,9 +60,9 @@ public function preventDefault(): void /** * Sets the return value which will be returned by the method that triggered this event - * if the {@see isDefaultPrevented() default action is prevented}. + * if the {@see AbstractEvent::isDefaultPrevented() default action is prevented}. * - * @see preventDefault() + * @see AbstractEvent::preventDefault() */ public function returnValue(mixed $returnValue): void { diff --git a/src/Event/AfterInsert.php b/src/Event/AfterInsert.php index 2b321bd5d..4f44816f4 100644 --- a/src/Event/AfterInsert.php +++ b/src/Event/AfterInsert.php @@ -9,7 +9,7 @@ /** * Event triggered after the record has been inserted into the database. * - * @see ActiveRecordInterface::insert + * @see ActiveRecordInterface::insert() */ final class AfterInsert extends AbstractEvent { diff --git a/src/Internal/JoinsWithBuilder.php b/src/Internal/JoinsWithBuilder.php index 140315283..aeb11d817 100644 --- a/src/Internal/JoinsWithBuilder.php +++ b/src/Internal/JoinsWithBuilder.php @@ -42,8 +42,8 @@ public static function build(ActiveQueryInterface $query): void } /** - * Remove duplicated joins added by {@see joinWithRelations()} that may be added, for example, when joining a relation - * and a via relation at the same time. + * Remove duplicated joins added by {@see JoinsWithBuilder::joinWithRelations()} that may be added, + * for example, when joining a relation and a via relation at the same time. */ $uniqueJoins = []; foreach ($query->getJoins() as $join) { diff --git a/src/OptimisticLockInterface.php b/src/OptimisticLockInterface.php index b57aa2f70..e943f97c8 100644 --- a/src/OptimisticLockInterface.php +++ b/src/OptimisticLockInterface.php @@ -11,12 +11,13 @@ * If a user attempts to save the record upon some stale data (because another user has modified the data), an * {@see OptimisticLockException} exception will be thrown, and the update or deletion is skipped. * - * Optimistic locking is only supported by {@see update()} and {@see delete()} methods. + * Optimistic locking is only supported by {@see AbstractActiveRecord::update()} and + * {@see AbstractActiveRecord::delete()} methods. * * To use optimistic locking: * * 1. Create a column to store the version number of each row. The column type should be `BIGINT DEFAULT 0`. - * Implement {@see optimisticLockPropertyName()} method to return the name of this column. + * Implement {@see OptimisticLockInterface::optimisticLockPropertyName()} method to return the name of this column. * 2. In the Web form that collects the user input, add a hidden field that stores the lock version of the recording * being updated. * 3. In the controller action that does the data updating, try to catch the {@see OptimisticLockException} and diff --git a/src/Trait/ArrayableTrait.php b/src/Trait/ArrayableTrait.php index 75d54c65e..eb6ae24ab 100644 --- a/src/Trait/ArrayableTrait.php +++ b/src/Trait/ArrayableTrait.php @@ -28,11 +28,12 @@ trait ArrayableTrait use \Yiisoft\Arrays\ArrayableTrait; /** - * Returns the list of fields that can be expanded further and returned by {@see toArray()}. + * Returns the list of fields that can be expanded further and returned by {@see \Yiisoft\Arrays\ArrayableTrait::toArray()}. * - * This method is similar to {@see fields()} except that the list of fields returned by this method are not returned - * by default by {@see toArray()}. Only when field names to be expanded are explicitly specified when calling - * {@see toArray()}, will their values be exported. + * This method is similar to {@see ArrayableTrait::fields()} except that the list of fields returned by this + * method are not returned by default by {@see \Yiisoft\Arrays\ArrayableTrait::toArray()}. Only when field + * names to be expanded are explicitly specified when calling {@see \Yiisoft\Arrays\ArrayableTrait::toArray()}, + * will their values be exported. * * The default implementation returns the names of the relations defined in this `ActiveRecord` class indexed by * themselves. @@ -40,7 +41,7 @@ trait ArrayableTrait * You may override this method to return a list of expandable fields. * * @return (Closure|string)[] The list of expandable field names or field definitions. Please refer - * to {@see fields()} on the format of the return value. + * to {@see ArrayableTrait::fields()} on the format of the return value. * * @psalm-return FieldsArray */ @@ -52,9 +53,9 @@ public function extraFields(): array } /** - * Returns the list of fields that should be returned by default by {@see toArray()}. + * Returns the list of fields that should be returned by default by {@see \Yiisoft\Arrays\ArrayableTrait::toArray()}. * - * A field is a named element in the returned array by {@see toArray()}. + * A field is a named element in the returned array by {@see \Yiisoft\Arrays\ArrayableTrait::toArray()}. * * This method should return an array of field names or field definitions. * If the former, the field name will be treated as an object property name whose value will be used diff --git a/src/Trait/MagicPropertiesTrait.php b/src/Trait/MagicPropertiesTrait.php index eaccd4a6a..3be39cb42 100644 --- a/src/Trait/MagicPropertiesTrait.php +++ b/src/Trait/MagicPropertiesTrait.php @@ -57,7 +57,7 @@ trait MagicPropertiesTrait * @throws Exception * @return mixed Property or relation value. * - * @see get() + * @see ActiveRecordInterface::get() */ public function __get(string $name) { @@ -188,8 +188,8 @@ public function set(string $propertyName, mixed $value): void * * @return bool Whether the property is defined. * - * {@see canGetProperty()} - * {@see canSetProperty()} + * @see MagicPropertiesTrait::canGetProperty() + * @see MagicPropertiesTrait::canSetProperty() */ public function isProperty(string $name, bool $checkVars = true): bool { diff --git a/src/Trait/RepositoryTrait.php b/src/Trait/RepositoryTrait.php index a73971161..9b5a6923b 100644 --- a/src/Trait/RepositoryTrait.php +++ b/src/Trait/RepositoryTrait.php @@ -8,9 +8,11 @@ use Yiisoft\ActiveRecord\ActiveRecordInterface; use Yiisoft\Db\Expression\ExpressionInterface; use Yiisoft\ActiveRecord\NotFoundException; +use Yiisoft\Db\Query\Query; /** - * Trait to support static methods {@see find()}, {@see findOne()}, {@see findAll()}, {@see findBySql()} to find records. + * Trait to support static methods {@see RepositoryTrait::find()}, {@see RepositoryTrait::findOne()}, + * {@see RepositoryTrait::findAll()}, {@see RepositoryTrait::findBySql()} to find records. * * For example: * @@ -43,7 +45,7 @@ trait RepositoryTrait /** * Returns an instance of {@see ActiveQueryInterface} instantiated by {@see ActiveRecordInterface::query()} method. * If the `$condition` parameter is not null, it calls {@see ActiveQueryInterface::andWhere()} method. - * Do not to pass user input to this method, use {@see findByPk()} instead. + * Do not to pass user input to this method, use {@see RepositoryTrait::findByPk()} instead. * * @param array|ExpressionInterface|string|null $condition The condition to be applied to the query where clause. * No condition is applied if `null` (by default). @@ -61,8 +63,8 @@ public static function find(array|string|ExpressionInterface|null $condition = n } /** - * Shortcut for {@see find()} method with calling {@see ActiveQueryInterface::all()} method to get all records. - * Do not to pass user input to this method, use {@see findByPk()} instead. + * Shortcut for {@see RepositoryTrait::find()} method with calling {@see ActiveQueryInterface::all()} method + * to get all records. Do not to pass user input to this method, use {@see RepositoryTrait::findByPk()} instead. * * ```php * // find the customers whose primary key value is 10, 11 or 12. @@ -88,7 +90,7 @@ public static function find(array|string|ExpressionInterface|null $condition = n * * ```php * $posts = Post::findAll(['id' => $id]); - * // or use {@see findByPk()} method + * // or use {@see RepositoryTrait::findByPk()} method * $post = Post::findByPk($id); * ``` * @@ -104,7 +106,7 @@ public static function findAll(array|string|ExpressionInterface|null $condition } /** - * Shortcut for {@see findAll()} method with throwing {@see NotFoundException} if no records found. + * Shortcut for {@see RepositoryTrait::findAll()} method with throwing {@see NotFoundException} if no records found. * * ```php * $customers = Customer::findAllOrFail(['is_active' => true]); @@ -164,7 +166,7 @@ public static function findByPk(array|float|int|string $values): array|ActiveRec } /** - * Shortcut for {@see findByPk()} method with throwing {@see NotFoundException} if no records found. + * Shortcut for {@see RepositoryTrait::findByPk()} method with throwing {@see NotFoundException} if no records found. * * ```php * $customer = Customer::findByPkOrFail(1); @@ -186,9 +188,11 @@ public static function findByPkOrFail(array|float|int|string $values): array|Act * Creates an {@see ActiveQueryInterface} instance with a given SQL statement. * * Note: That because the SQL statement is already specified, calling more query modification methods - * (such as {@see where()}, {@see order()) on the created {@see ActiveQueryInterface} instance will have no effect. + * (such as {@see Query::where()}, {@see Query::orderBy()}) on the + * created {@see ActiveQueryInterface} instance will have no effect. * - * However, calling {@see with()}, {@see asArray()}, {@see indexBy()} or {@see resultCallback()} is still fine. + * However, calling {@see ActiveQueryInterface::with()}, {@see ActiveQueryInterface::asArray()}, + * {@see Query::indexBy()} or {@see Query::resultCallback()} is still fine. * * Below is an example: * @@ -208,7 +212,7 @@ public static function findBySql(string $sql, array $params = []): ActiveQueryIn /** * Shortcut for {@see find()} method with calling {@see ActiveQueryInterface::one()} method to get one record. - * Do not to pass user input to this method, use {@see findByPk()} instead. + * Do not to pass user input to this method, use {@see RepositoryTrait::findByPk()} instead. * * ```php * // find a single customer whose primary key value is 10 @@ -234,7 +238,7 @@ public static function findBySql(string $sql, array $params = []): ActiveQueryIn * * ```php * $post = Post::findOne(['id' => $id]); - * // or use {@see findByPk()} method + * // or use {@see RepositoryTrait::findByPk()} method * $post = Post::findByPk($id); * ``` * @@ -252,7 +256,7 @@ public static function findOne( } /** - * Shortcut for {@see findOne()} method with throwing {@see NotFoundException} if no records found. + * Shortcut for {@see RepositoryTrait::findOne()} method with throwing {@see NotFoundException} if no records found. * * ```php * $customer = Customer::findOneOrFail(['id' => 1]);