-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds support for 'known' attributes on method and function parameters. 'Known' in this context means an attribute that has been declared in the documentation with an ID in the `class.attribute_name` format (all current predefined attributes are supported). Current limitations are: - No support for namespaced attributes - No support for attributes on a return type Co-authored-by: haszi <[email protected]>
- Loading branch information
Showing
3 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--TEST-- | ||
Attribute formatting 001 | ||
--FILE-- | ||
<?php | ||
namespace phpdotnet\phd; | ||
|
||
require_once __DIR__ . "/../../setup.php"; | ||
|
||
$xml_file = __DIR__ . "/data/attribute_formatting_001.xml"; | ||
|
||
Config::init(["xml_file" => $xml_file]); | ||
|
||
$format = new TestGenericChunkedXHTML; | ||
|
||
$format->SQLiteIndex( | ||
null, // $context, | ||
null, // $index, | ||
"class.knownattribute", // $id, | ||
"file.knownattribute.is.in", // $filename, | ||
"", // $parent, | ||
"", // $sdesc, | ||
"", // $ldesc, | ||
"", // $element, | ||
"", // $previous, | ||
"", // $next, | ||
0, // $chunk | ||
); | ||
|
||
$render = new TestRender(new Reader, new Config, $format); | ||
|
||
$render->run(); | ||
?> | ||
--EXPECT-- | ||
Filename: attribute-formatting.html | ||
Content: | ||
<div id="attribute-formatting" class="chapter"> | ||
<div class="section"> | ||
<p class="para">1. Class methodparameter with unknown attribute</p> | ||
<div class="constructorsynopsis dc-description"><span class="modifier">public</span> <span class="methodname">mysqli::__construct</span>(<span class="methodparam"><span class="attribute">#[\UnknownAttribute]</span><span class="type"><span class="type">string</span><span class="type">null</span></span> <code class="parameter">$password</code><span class="initializer"> = <span class="type">null</span></span></span>)</div> | ||
|
||
</div> | ||
|
||
<div class="section"> | ||
<p class="para">2. Class methodparameter with known attribute</p> | ||
<div class="constructorsynopsis dc-description"><span class="modifier">public</span> <span class="methodname">mysqli::__construct</span>(<span class="methodparam"><span class="attribute"><a href="file.knownattribute.is.in.html">#[\KnownAttribute]</a> </span><span class="type"><span class="type">string</span><span class="type">null</span></span> <code class="parameter">$password</code><span class="initializer"> = <span class="type">null</span></span></span>)</div> | ||
|
||
</div> | ||
|
||
<div class="section"> | ||
<p class="para">3. Function parameter with unknown attribute</p> | ||
<div class="methodsynopsis dc-description"><span class="type">bool</span> <span class="methodname">password_verify</span><span class="attribute">#[\UnknownAttribute]</span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$hash</code></span>)</div> | ||
|
||
</div> | ||
|
||
<div class="section"> | ||
<p class="para">4. Function parameter with known attribute</p> | ||
<div class="methodsynopsis dc-description"><span class="type">bool</span> <span class="methodname">password_verify</span><span class="attribute"><a href="file.knownattribute.is.in.html">#[\KnownAttribute]</a> </span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$hash</code></span>)</div> | ||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<chapter xml:id="attribute-formatting"> | ||
<section> | ||
<para>1. Class methodparameter with unknown attribute</para> | ||
<constructorsynopsis role="mysqli"> | ||
<modifier>public</modifier> <methodname>mysqli::__construct</methodname> | ||
<methodparam><modifier role="attribute">#[\UnknownAttribute]</modifier><type class="union"><type>string</type><type>null</type></type><parameter>password</parameter><initializer><type>null</type></initializer></methodparam> | ||
</constructorsynopsis> | ||
</section> | ||
|
||
<section> | ||
<para>2. Class methodparameter with known attribute</para> | ||
<constructorsynopsis role="mysqli"> | ||
<modifier>public</modifier> <methodname>mysqli::__construct</methodname> | ||
<methodparam><modifier role="attribute">#[\KnownAttribute]</modifier><type class="union"><type>string</type><type>null</type></type><parameter>password</parameter><initializer><type>null</type></initializer></methodparam> | ||
</constructorsynopsis> | ||
</section> | ||
|
||
<section> | ||
<para>3. Function parameter with unknown attribute</para> | ||
<methodsynopsis> | ||
<type>bool</type><methodname>password_verify</methodname> | ||
<modifier role="attribute">#[\UnknownAttribute]</modifier><methodparam><type>string</type><parameter>password</parameter></methodparam> | ||
<methodparam><type>string</type><parameter>hash</parameter></methodparam> | ||
</methodsynopsis> | ||
</section> | ||
|
||
<section> | ||
<para>4. Function parameter with known attribute</para> | ||
<methodsynopsis> | ||
<type>bool</type><methodname>password_verify</methodname> | ||
<modifier role="attribute">#[\KnownAttribute]</modifier><methodparam><type>string</type><parameter>password</parameter></methodparam> | ||
<methodparam><type>string</type><parameter>hash</parameter></methodparam> | ||
</methodsynopsis> | ||
</section> | ||
</chapter> |