Skip to content

Commit 46f5dac

Browse files
authored
Merge branch 'main' into dependabot/composer/phpstan/phpstan-1.11.3
2 parents 4181b48 + 617d47e commit 46f5dac

File tree

15 files changed

+24550
-21
lines changed

15 files changed

+24550
-21
lines changed

.github/workflows/dependabot-review.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
persist-credentials: "false"
1919
- name: "Dependabot metadata"
2020
id: "dependabot-metadata"
21-
uses: "dependabot/fetch-metadata@v2.1.0"
21+
uses: "dependabot/fetch-metadata@v2.2.0"
2222
- name: "Enable auto-merge for Dependabot PRs"
2323
run: "gh pr merge --auto --merge $PR_URL"
2424
env:

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ test-functional: ## Runs functional tests with phpunit/phpunit
4242
test-integration: ## Runs integration tests with phpunit/phpunit
4343
$(PHP_BIN) vendor/bin/phpunit --testsuite=integration
4444

45+
.PHONY: integration-baseline
46+
integration-baseline: ## Copies the output files of the integration tests into the expected directories, making a new baseline.
47+
$(PHP_BIN) tools/integration-test-copy-baseline.php
48+
4549
.PHONY: test-xml
4650
test-xml: ## Lint all guides.xml
4751
./tools/xmllint.sh

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"rector/rector": "^1.1.0",
6868
"squizlabs/php_codesniffer": "^3.10",
6969
"symfony/finder": "^6.4.8",
70-
"symplify/phpstan-rules": "^12.6",
70+
"symplify/phpstan-rules": "^12.7",
7171
"vimeo/psalm": "^5.22"
7272
},
7373
"suggest": {

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/guides-restructured-text/resources/config/guides-restructured-text.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
use phpDocumentor\Guides\RestructuredText\Parser\Productions\TitleRule;
107107
use phpDocumentor\Guides\RestructuredText\Parser\Productions\TransitionRule;
108108
use phpDocumentor\Guides\RestructuredText\TextRoles\AbbreviationTextRole;
109+
use phpDocumentor\Guides\RestructuredText\TextRoles\ApiClassTextRole;
109110
use phpDocumentor\Guides\RestructuredText\TextRoles\DefaultTextRoleFactory;
110111
use phpDocumentor\Guides\RestructuredText\TextRoles\DocReferenceTextRole;
111112
use phpDocumentor\Guides\RestructuredText\TextRoles\GenericLinkProvider;
@@ -168,6 +169,7 @@
168169
->set(GenericReferenceTextRole::class)
169170
->set(ReferenceTextRole::class)
170171
->set(AbbreviationTextRole::class)
172+
->set(ApiClassTextRole::class)
171173
->set(MathTextRole::class)
172174
->set(LiteralTextRole::class)
173175
->set(SpanTextRole::class)

packages/guides-restructured-text/src/RestructuredText/TextRoles/AbstractReferenceTextRole.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ abstract class AbstractReferenceTextRole implements TextRole
2222
{
2323
use EmbeddedReferenceParser;
2424

25+
protected bool $useRawContent = false;
26+
2527
public function processNode(
2628
DocumentParserContext $documentParserContext,
2729
string $role,
2830
string $content,
2931
string $rawContent,
3032
): AbstractLinkInlineNode {
31-
$referenceData = $this->extractEmbeddedReference($content);
33+
$referenceData = $this->extractEmbeddedReference($this->useRawContent ? $rawContent : $content);
3234

3335
return $this->createNode($referenceData->reference, $referenceData->text, $role);
3436
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link https://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Guides\RestructuredText\TextRoles;
15+
16+
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
17+
use phpDocumentor\Guides\Nodes\Inline\ReferenceNode;
18+
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
19+
use phpDocumentor\Guides\RestructuredText\Parser\Interlink\InterlinkParser;
20+
21+
final class ApiClassTextRole extends AbstractReferenceTextRole
22+
{
23+
final public const NAME = 'api-class';
24+
final public const TYPE = 'api-class';
25+
protected bool $useRawContent = true;
26+
27+
public function __construct(
28+
private readonly GenericLinkProvider $genericLinkProvider,
29+
private readonly AnchorNormalizer $anchorReducer,
30+
private readonly InterlinkParser $interlinkParser,
31+
) {
32+
}
33+
34+
public function getName(): string
35+
{
36+
return self::NAME;
37+
}
38+
39+
/** @inheritDoc */
40+
public function getAliases(): array
41+
{
42+
return [];
43+
}
44+
45+
/** @return ReferenceNode */
46+
protected function createNode(string $referenceTarget, string|null $referenceName, string $role): AbstractLinkInlineNode
47+
{
48+
$interlinkData = $this->interlinkParser->extractInterlink($referenceTarget);
49+
$reference = $this->anchorReducer->reduceAnchor($interlinkData->reference);
50+
$prefix = $this->genericLinkProvider->getLinkPrefix($role);
51+
52+
return new ReferenceNode($reference, $referenceName ?? '', $interlinkData->interlink, self::TYPE, $prefix);
53+
}
54+
}

packages/guides/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"league/uri": "^7.4.1",
3131
"phpdocumentor/flyfinder": "^1.1",
3232
"psr/event-dispatcher": "^1.0",
33-
"symfony/clock": "^6.4.7",
34-
"symfony/string": "^6.4.7",
33+
"symfony/clock": "^6.4.8",
34+
"symfony/string": "^6.4.9",
3535
"symfony/translation-contracts": "^3.5.0",
36-
"symfony/http-client": "^6.4.7",
36+
"symfony/http-client": "^6.4.9",
3737
"twig/twig": "~2.15 || ^3.0",
3838
"webmozart/assert": "^1.11"
3939
},

packages/guides/src/ReferenceResolvers/Interlink/InventoryLink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525
private string $path,
2626
private readonly string $title,
2727
) {
28-
if (preg_match('/^([a-zA-Z0-9-_.]+\/)*([a-zA-Z0-9-_.])+\.html(#[^#]*)?$/', $path) < 1) {
28+
if (preg_match('/^([a-zA-Z0-9-_.]+\/)*([a-zA-Z0-9-_.]+)(\.html)?(#[^#]*)?$/', $path) < 1) {
2929
throw new InvalidInventoryLink('Inventory link "' . $path . '" has an invalid scheme. ', 1_671_398_986);
3030
}
3131
}

packages/guides/tests/unit/Interlink/InventoryLinkTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ public function testLinkMayContaintDot(): void
5454
self::assertEquals($inventoryLink->getPath(), $link);
5555
}
5656

57-
public function testPhpLinkThrowsError(): void
58-
{
59-
$link = 'Some/Path/SomeThing.php#anchor';
60-
$this->expectException(InvalidInventoryLink::class);
61-
new InventoryLink('', '', $link, '');
62-
}
63-
6457
public function testJavaScriptLinkThrowsError(): void
6558
{
6659
$link = 'javascript:alert()';

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,8 @@ parameters:
159159
message: "#^Return type \\(iterable\\<phpDocumentor\\\\Guides\\\\Compiler\\\\NodeTransformers\\\\MoveAnchorTransformer\\>\\) of method class@anonymous/packages/guides/tests/unit/Compiler/NodeTransformers/MoveAnchorTransformerTest\\.php\\:32\\:\\:getTransformers\\(\\) should be compatible with return type \\(iterable\\<phpDocumentor\\\\Guides\\\\Compiler\\\\NodeTransformer\\<phpDocumentor\\\\Guides\\\\Nodes\\\\Node\\>\\>\\) of method phpDocumentor\\\\Guides\\\\Compiler\\\\NodeTransformers\\\\NodeTransformerFactory\\:\\:getTransformers\\(\\)$#"
160160
count: 1
161161
path: packages/guides/tests/unit/Compiler/NodeTransformers/MoveAnchorTransformerTest.php
162+
163+
-
164+
message: "#^Binary operation \"\\.\" between array\\|DateTimeImmutable\\|int\\|string\\|null and '\\: ' results in an error\\.$#"
165+
count: 1
166+
path: tests/Functional/FunctionalTest.php
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- content start -->
2+
<div class="section" id="document-title">
3+
<h1>Document title</h1>
4+
5+
<p>See <a href="https://api.typo3.org/main/classes/TYPO3-CMS-Adminpanel-Controller-AjaxController.html">AjaxController</a> or
6+
<a href="https://api.typo3.org/main/classes/TYPO3-CMS-Adminpanel-Controller-MainController.html">that other controller</a>.</p>
7+
8+
</div>
9+
<!-- content end -->

0 commit comments

Comments
 (0)