Skip to content

Commit

Permalink
Support attributes in parameter and on methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed May 21, 2024
1 parent 60f9d8a commit a1d8656
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Templates/highlight.php/php.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
{
"$ref": "#contains.9"
},
{
"$ref": "#contains.0"
},
{
"$ref": "#contains.1"
},
{
"className": "comment",
"begin": "/\\*",
Expand Down
25 changes: 23 additions & 2 deletions tests/fixtures/expected/blocks/code-blocks/php-attributes.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div translate="no" data-loc="54" class="notranslate codeblock codeblock-length-md codeblock-php-attributes codeblock-php">
<div translate="no" data-loc="65" class="notranslate codeblock codeblock-length-md codeblock-php-attributes codeblock-php">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1
2
Expand Down Expand Up @@ -53,7 +53,18 @@
51
52
53
54</pre>
54
55
56
57
58
59
60
61
62
63
64
65</pre>
<pre class="codeblock-code">
<code>
<span class="hljs-comment">// src/SomePath/SomeClass.php</span>
Expand Down Expand Up @@ -135,6 +146,16 @@
<span class="hljs-variable">
<span class="hljs-variable-other-marker">$</span> property12</span>
;
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">__construct</span><span class="hljs-params">(
<span class="hljs-meta">#[TaggedIterator</span>(<span class="hljs-string">'app.handlers'</span>)<span class="hljs-meta">]</span>
iterable <span class="hljs-variable"><span class="hljs-variable-other-marker">$</span>handlers</span>,
)</span></span>{
}

<span class="hljs-meta">#[AsController]</span>
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-title">someAction</span><span class="hljs-params">(<span class="hljs-meta">#[CurrentUser]</span> User <span class="hljs-variable"><span class="hljs-variable-other-marker">$</span>user</span>)</span></span>
{
}
}</code></pre>
</div>
</div>
11 changes: 11 additions & 0 deletions tests/fixtures/source/blocks/code-blocks/php-attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@
new Assert\Length(min: 10),
])]
private $property12;
public function __construct(
#[TaggedIterator('app.handlers')]
iterable $handlers,
) {
}
#[AsController]
public function someAction(#[CurrentUser] User $user)
{
}
}

0 comments on commit a1d8656

Please sign in to comment.