Skip to content

Commit e2d91bd

Browse files
authored
Merge pull request #1 from artemeon/feat/phpstan
feat: PHPStan Level 5
2 parents 75063a0 + 110b7e0 commit e2d91bd

14 files changed

+55
-18
lines changed

Diff for: .github/workflows/phpstan.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: PHPStan
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
phpstan:
11+
uses: artemeon/.shared/.github/workflows/phpstan.yml@main

Diff for: composer.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"description": "Connect to the Atlassian Confluence API",
44
"license": "MIT",
55
"type": "library",
6+
"scripts": {
7+
"phpstan": "php ./vendor/bin/phpstan analyse --memory-limit=4G"
8+
},
69
"require": {
710
"php": ">=8.1",
811
"guzzlehttp/guzzle": "~7.4",
@@ -11,7 +14,9 @@
1114
},
1215
"require-dev": {
1316
"phpunit/phpunit": "^8.0",
14-
"vimeo/psalm": "^3.16"
17+
"phpstan/phpstan": "^1.10",
18+
"phpstan/extension-installer": "^1.3",
19+
"phpstan/phpstan-phpunit": "^1.3"
1520
},
1621
"autoload": {
1722
"psr-4": {
@@ -22,5 +27,10 @@
2227
"psr-4": {
2328
"Artemeon\\Confluence\\Tests\\": "tests/"
2429
}
30+
},
31+
"config": {
32+
"allow-plugins": {
33+
"phpstan/extension-installer": true
34+
}
2535
}
26-
}
36+
}

Diff for: phpstan.neon

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
4+
parameters:
5+
level: 5
6+
paths:
7+
- src
8+
- tests

Diff for: src/ConfluencePageContentDownloader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public function downloadPageContent(ConfluencePage $page): void
4545
}
4646
}
4747

48-
}
48+
}

Diff for: src/Endpoint/Auth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ public function getAuthenticationArray(): array
1919
{
2020
return ['auth' => [$this->username, $this->password]];
2121
}
22-
}
22+
}

Diff for: src/Endpoint/Content.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ public function findChildAttachments(string $pageId): array
6666
throw new Exception('Fehler beim Abrufen der Attachments. HTTP-Statuscode: ' . $response->getStatusCode());
6767
}
6868
}
69-
}
69+
}

Diff for: src/Endpoint/Download.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ public function downloadAttachment(ConfluenceAttachment $attachment): void
5858

5959
file_put_contents($this->downloadFolder . '/' . $attachment->getTitle(), $attachmentContent);
6060
}
61-
}
61+
}

Diff for: src/Endpoint/Dto/ConfluenceAttachment.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public function __construct(array $rawData)
1919

2020
public function findDownloadPath(): ?string
2121
{
22-
return (string)$this->rawData['_links']['download'] ?? null;
22+
return $this->rawData['_links']['download'] ?? null;
2323
}
2424

2525
public function getTitle(): string
2626
{
2727
return $this->title;
2828
}
29-
}
29+
}

Diff for: src/Endpoint/Dto/ConfluenceLabel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ public function getLabel(): string
3838
{
3939
return $this->label;
4040
}
41-
}
41+
}

Diff for: src/Endpoint/Dto/ConfluencePage.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ public function __construct(array $rawData)
2222
{
2323
$this->rawData = $rawData;
2424

25-
$this->id = $rawData['id'];
26-
$this->title = $rawData['title'];
27-
$this->body = $rawData['body'];
28-
$this->metadata = $rawData['metadata'];
25+
$this->id = $rawData['id'] ?? null;
26+
$this->type = $rawData['type'] ?? null;
27+
$this->status = $rawData['status'] ?? null;
28+
$this->title = $rawData['title'] ?? null;
29+
$this->space = $rawData['space'] ?? null;
30+
$this->version = $rawData['version'] ?? null;
31+
$this->body = $rawData['body'] ?? null;
32+
$this->metadata = $rawData['metadata'] ?? null;
2933
}
3034

3135
public function getId(): ?string
@@ -91,4 +95,9 @@ public function getLabels(): array {
9195

9296
return $labels;
9397
}
98+
99+
public function getRawData(): array
100+
{
101+
return $this->rawData;
102+
}
94103
}

Diff for: src/MacroReplacer/ImageAndVideoMacroReplacer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ function ($match) {
4141
$haystack
4242
);
4343
}
44-
}
44+
}

Diff for: src/MacroReplacer/MacroReplacerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
interface MacroReplacerInterface
88
{
99
public function replace(string $haystack) : string;
10-
}
10+
}

Diff for: src/MacroReplacer/OtherMacroRemover.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
*/
1010
class OtherMacroRemover implements MacroReplacerInterface
1111
{
12-
1312
public function replace(string $haystack): string
1413
{
1514
return preg_replace('/<ac:[^>]*>.*?<\/ac:[^>]*>/is', '', $haystack);
1615
}
17-
}
16+
}

Diff for: src/MacroReplacer/StructuredMacroReplacer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ function ($match) {
2121
$haystack
2222
);
2323
}
24-
}
24+
}

0 commit comments

Comments
 (0)