-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Introduce modifiers "final" and "abstract" for classes (#14)
* [FEATURE] Introduce modifiers "final" and "abstract" for classes * [TASK] Ignore rector rule The suggested change would make the method much longer and harder to read. * [TASK] Only use document context for debug information using the block context causes an exception due to a bug in the guides
- Loading branch information
Showing
17 changed files
with
150 additions
and
10 deletions.
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
3 changes: 3 additions & 0 deletions
3
resources/template/html/body/directive/php/component.html.twig
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
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 |
---|---|---|
|
@@ -48,7 +48,6 @@ protected function processSub( | |
$collectionNode->getChildren(), | ||
null, | ||
[], | ||
[], | ||
); | ||
} | ||
} |
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
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
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace T3Docs\GuidesPhpDomain\PhpDomain; | ||
|
||
use phpDocumentor\Guides\ReferenceResolvers\AnchorReducer; | ||
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext; | ||
use phpDocumentor\Guides\RestructuredText\Parser\Directive; | ||
use phpDocumentor\Guides\RestructuredText\Parser\Productions\Rule; | ||
use phpDocumentor\Guides\RestructuredText\TextRoles\GenericLinkProvider; | ||
use Psr\Log\LoggerInterface; | ||
use T3Docs\GuidesPhpDomain\Nodes\PhpModifierNode; | ||
|
||
final class ModifierService | ||
{ | ||
/** | ||
* @param list<string> $allowedModifiers | ||
* @return list<PhpModifierNode> | ||
*/ | ||
public function getModifiersFromDirectiveOptions(Directive $directive, array $allowedModifiers): array | ||
{ | ||
$modifiers = []; | ||
|
||
foreach ($allowedModifiers as $allowedModifier) { | ||
if ($directive->hasOption($allowedModifier)) { | ||
$modifiers[] = new PhpModifierNode($allowedModifier); | ||
} | ||
} | ||
return $modifiers; | ||
} | ||
|
||
} |
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,21 @@ | ||
<!-- content start --> | ||
<div class="section" id="abstract-class"> | ||
<h1>abstract class</h1> | ||
|
||
<dl class="php class"> | ||
<dt class="sig sig-object php" | ||
id="typo3-cms-core-abstracttest"> | ||
<span class="sig-name modifier"><span class="pre">abstract</span></span> | ||
<em class="property"><span class="pre">class</span> </em> | ||
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span> | ||
<span class="sig-name descname"><span class="pre">AbstractTest</span></span> | ||
|
||
</dt> | ||
<dd> | ||
<p>Lorem Ipsum Dolor!</p> | ||
</dd> | ||
</dl> | ||
|
||
</div> | ||
|
||
<!-- content end --> |
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,8 @@ | ||
============== | ||
abstract class | ||
============== | ||
|
||
.. php:class:: TYPO3\CMS\Core\AbstractTest | ||
:abstract: | ||
|
||
Lorem Ipsum Dolor! |
22 changes: 22 additions & 0 deletions
22
tests/integration/class-final-abstract/expected/index.html
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,22 @@ | ||
<!-- content start --> | ||
<div class="section" id="abstract-final-class-causes-warning"> | ||
<h1>abstract final class causes warning</h1> | ||
|
||
<dl class="php class"> | ||
<dt class="sig sig-object php" | ||
id="typo3-cms-core-test"> | ||
<span class="sig-name modifier"><span class="pre">abstract</span></span> | ||
<span class="sig-name modifier"><span class="pre">final</span></span> | ||
<em class="property"><span class="pre">class</span> </em> | ||
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span> | ||
<span class="sig-name descname"><span class="pre">Test</span></span> | ||
|
||
</dt> | ||
<dd> | ||
<p>Lorem Ipsum Dolor!</p> | ||
</dd> | ||
</dl> | ||
|
||
</div> | ||
|
||
<!-- content end --> |
1 change: 1 addition & 0 deletions
1
tests/integration/class-final-abstract/expected/logs/warning.log
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 @@ | ||
app.WARNING: A PHP class cannot be abstract and final at the same time. |
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,9 @@ | ||
=================================== | ||
abstract final class causes warning | ||
=================================== | ||
|
||
.. php:class:: TYPO3\CMS\Core\Test | ||
:abstract: | ||
:final: | ||
|
||
Lorem Ipsum Dolor! |
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,21 @@ | ||
<!-- content start --> | ||
<div class="section" id="final-class"> | ||
<h1>final class</h1> | ||
|
||
<dl class="php class"> | ||
<dt class="sig sig-object php" | ||
id="typo3-cms-core-test"> | ||
<span class="sig-name modifier"><span class="pre">final</span></span> | ||
<em class="property"><span class="pre">class</span> </em> | ||
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span> | ||
<span class="sig-name descname"><span class="pre">Test</span></span> | ||
|
||
</dt> | ||
<dd> | ||
<p>Lorem Ipsum Dolor!</p> | ||
</dd> | ||
</dl> | ||
|
||
</div> | ||
|
||
<!-- content end --> |
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,8 @@ | ||
=========== | ||
final class | ||
=========== | ||
|
||
.. php:class:: TYPO3\CMS\Core\Test | ||
:final: | ||
|
||
Lorem Ipsum Dolor! |