mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-01 19:27:39 +08:00
Added @mixin into Model, you can use static methods friendly. (#2709)
Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
db6313ccdd
commit
6d08156a83
@ -1,5 +1,9 @@
|
||||
# v2.0.17 - TBD
|
||||
|
||||
## Added
|
||||
|
||||
- [#2709](https://github.com/hyperf/hyperf/pull/2709) Added `@mixin` into Model, you can use static methods friendly.
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#2719](https://github.com/hyperf/hyperf/pull/2719) Fixed method `Arr::merge` does not works when `array1` does not constains the `$key`.
|
||||
|
@ -96,7 +96,7 @@ class ModelUpdateVisitor extends NodeVisitorAbstract
|
||||
}
|
||||
return $node;
|
||||
case $node instanceof Node\Stmt\Class_:
|
||||
$node->setDocComment(new Doc($this->parseProperty()));
|
||||
$node->setDocComment(new Doc($this->parse()));
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
@ -167,9 +167,16 @@ class ModelUpdateVisitor extends NodeVisitorAbstract
|
||||
is_subclass_of($caster, CastsInboundAttributes::class);
|
||||
}
|
||||
|
||||
protected function parseProperty(): string
|
||||
protected function parse(): string
|
||||
{
|
||||
$doc = '/**' . PHP_EOL;
|
||||
$doc = $this->parseProperty($doc);
|
||||
$doc .= ' */';
|
||||
return $doc;
|
||||
}
|
||||
|
||||
protected function parseProperty(string $doc): string
|
||||
{
|
||||
foreach ($this->columns as $column) {
|
||||
[$name, $type, $comment] = $this->getProperty($column);
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
@ -191,7 +198,6 @@ class ModelUpdateVisitor extends NodeVisitorAbstract
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$doc .= ' */';
|
||||
return $doc;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ use JsonSerializable;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\EventDispatcher\StoppableEventInterface;
|
||||
|
||||
/**
|
||||
* @mixin Builder
|
||||
* @mixin QueryBuilder
|
||||
*/
|
||||
abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, CompressInterface
|
||||
{
|
||||
use Concerns\HasAttributes;
|
||||
|
@ -1414,7 +1414,7 @@ class Builder
|
||||
* Handles dynamic "where" clauses to the query.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $parameters
|
||||
* @param array $parameters
|
||||
* @return $this
|
||||
*/
|
||||
public function dynamicWhere($method, $parameters)
|
||||
|
@ -53,6 +53,9 @@ class ConfigProvider
|
||||
AspectCollector::class,
|
||||
],
|
||||
],
|
||||
'ignore_annotations' => [
|
||||
'mixin',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -25,9 +25,6 @@ class ConfigProvider
|
||||
__DIR__,
|
||||
],
|
||||
],
|
||||
'ignore_annotations' => [
|
||||
'mixin',
|
||||
],
|
||||
],
|
||||
'publish' => [
|
||||
[
|
||||
|
Loading…
Reference in New Issue
Block a user