Skip to content

Commit 5961e2c

Browse files
committed
Merge #54 - Support @category tags
Pull-request: #54
2 parents b8c451a + 811de93 commit 5961e2c

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

src/Reflection/Reflection.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,24 @@ public function isInternal(): bool
323323
return ! empty($this->getTags('internal'));
324324
}
325325

326+
public function hasCategories(): bool
327+
{
328+
return ! empty($this->getCategories());
329+
}
330+
326331
public function hasExamples(): bool
327332
{
328333
return ! empty($this->getExamples());
329334
}
330335

336+
/**
337+
* @return array[]
338+
*/
339+
public function getCategories(): array
340+
{
341+
return $this->getTags('category');
342+
}
343+
331344
/**
332345
* @return array[]
333346
*/

src/Resources/themes/default/class.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "layout/layout.twig" %}
2-
{% from "macros.twig" import render_classes, breadcrumbs, namespace_link, class_link, property_link, method_link, hint_link, source_link, method_source_link, deprecated, deprecations, internals, todo, todos, class_category_name %}
2+
{% from "macros.twig" import render_classes, breadcrumbs, namespace_link, class_link, property_link, method_link, hint_link, source_link, method_source_link, deprecated, deprecations, internals, categories, todo, todos, class_category_name %}
33
{% block title %}{{ class|raw }} | {{ parent() }}{% endblock %}
44
{% block body_class 'class' %}
55
{% block page_id 'class:' ~ (class.name|replace({'\\': '_'})) %}
@@ -33,6 +33,7 @@
3333

3434
<p>{{ block('class_signature') }}</p>
3535

36+
{{ categories(class) }}
3637
{{ deprecations(class) }}
3738
{{ internals(class) }}
3839

@@ -284,6 +285,7 @@
284285
<i>{{ 'Since:'|trans }} {{ method.getSince() }}</i>
285286
<br>
286287
{%- endif -%}
288+
{{ categories(method) }}
287289
{{ deprecations(method) }}
288290
{{ internals(method) }}
289291

src/Resources/themes/default/macros.twig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@
159159
{% endif %}
160160
{% endmacro %}
161161

162+
{% macro categories(reflection) %}
163+
{% if reflection.hasCategories() %}
164+
<p>
165+
{% for categoryTag in reflection.getCategories() %}
166+
{% for category in categoryTag %}
167+
<span class="label label-default">{{ category }}</span>
168+
{% endfor %}
169+
{% endfor %}
170+
</p>
171+
{% endif %}
172+
{% endmacro %}
173+
162174
{% macro todo(reflection) %}
163175
{% if project.config('insert_todos') == true %}
164176
{% if reflection.todo %}<small><span class="label label-info">{% trans 'todo' %}</span></small>{% endif %}

tests/phar/data/src/ElloquentBuilder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* @source https://github.com/netpok/larastan/blob/master/stubs/EloquentBuilder.stub
88
* @license MIT
99
* @copyright Nuno Maduro enunomaduro@gmail.com
10+
*
11+
* @category laravel
12+
* @category builder
1013
*/
1114
class Builder
1215
{
@@ -42,6 +45,7 @@ public function fromQuery($query, $bindings = []);
4245
* @param mixed $id
4346
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
4447
* @phpstan-return TModelClass|\Illuminate\Database\Eloquent\Collection<TModelClass>|null
48+
* @category find
4549
*/
4650
public function find($id, $columns = ['*']);
4751

@@ -51,6 +55,7 @@ public function find($id, $columns = ['*']);
5155
* @param \Illuminate\Contracts\Support\Arrayable|array<mixed> $ids
5256
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
5357
* @phpstan-return \Illuminate\Database\Eloquent\Collection<TModelClass>
58+
* @category find
5459
*/
5560
public function findMany($ids, $columns = ['*']);
5661

@@ -60,6 +65,7 @@ public function findMany($ids, $columns = ['*']);
6065
* @param mixed $id
6166
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
6267
* @phpstan-return TModelClass|\Illuminate\Database\Eloquent\Collection<TModelClass>
68+
* @category find
6369
*
6470
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
6571
*/
@@ -71,6 +77,7 @@ public function findOrFail($id, $columns = ['*']);
7177
* @param mixed $id
7278
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
7379
* @phpstan-return TModelClass
80+
* @category find
7481
*/
7582
public function findOrNew($id, $columns = ['*']);
7683

0 commit comments

Comments
 (0)