Skip to content

Commit 1f6db11

Browse files
committed
Improve static analysis
1 parent 17f3756 commit 1f6db11

36 files changed

+410
-50
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
]);
88

99
return (new PhpCsFixer\Config())
10+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
1011
->setRiskyAllowed(true)
1112
->setRules([
1213
'@Symfony' => true,

phpstan-baseline.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php declare(strict_types = 1);
2+
3+
$ignoreErrors = [];
4+
$ignoreErrors[] = [
5+
// identifier: missingType.iterableValue
6+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:filterAndroidBackgroundLayout\\(\\) has parameter \\$layouts with no value type specified in iterable type array\\.$#',
7+
'count' => 1,
8+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
9+
];
10+
$ignoreErrors[] = [
11+
// identifier: missingType.iterableValue
12+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:filterIosAttachments\\(\\) has parameter \\$attachments with no value type specified in iterable type array\\.$#',
13+
'count' => 1,
14+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
15+
];
16+
$ignoreErrors[] = [
17+
// identifier: missingType.iterableValue
18+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:filterWebButtons\\(\\) has parameter \\$buttons with no value type specified in iterable type array\\.$#',
19+
'count' => 1,
20+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
21+
];
22+
$ignoreErrors[] = [
23+
// identifier: missingType.iterableValue
24+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:normalizeButtons\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
25+
'count' => 1,
26+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
27+
];
28+
$ignoreErrors[] = [
29+
// identifier: missingType.iterableValue
30+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:normalizeButtons\\(\\) return type has no value type specified in iterable type array\\.$#',
31+
'count' => 1,
32+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
33+
];
34+
$ignoreErrors[] = [
35+
// identifier: missingType.iterableValue
36+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:normalizeFilters\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
37+
'count' => 1,
38+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
39+
];
40+
$ignoreErrors[] = [
41+
// identifier: missingType.iterableValue
42+
'message' => '#^Method OneSignal\\\\Resolver\\\\NotificationResolver\\:\\:normalizeFilters\\(\\) return type has no value type specified in iterable type array\\.$#',
43+
'count' => 1,
44+
'path' => __DIR__ . '/src/Resolver/NotificationResolver.php',
45+
];
46+
$ignoreErrors[] = [
47+
// identifier: missingType.iterableValue
48+
'message' => '#^Method OneSignal\\\\Resolver\\\\SegmentResolver\\:\\:normalizeFilters\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
49+
'count' => 1,
50+
'path' => __DIR__ . '/src/Resolver/SegmentResolver.php',
51+
];
52+
$ignoreErrors[] = [
53+
// identifier: missingType.iterableValue
54+
'message' => '#^Method OneSignal\\\\Resolver\\\\SegmentResolver\\:\\:normalizeFilters\\(\\) return type has no value type specified in iterable type array\\.$#',
55+
'count' => 1,
56+
'path' => __DIR__ . '/src/Resolver/SegmentResolver.php',
57+
];
58+
$ignoreErrors[] = [
59+
// identifier: argument.type
60+
'message' => '#^Parameter \\#1 \\$success of class OneSignal\\\\Response\\\\Segment\\\\CreateSegmentResponse constructor expects bool, mixed given\\.$#',
61+
'count' => 1,
62+
'path' => __DIR__ . '/src/Response/Segment/CreateSegmentResponse.php',
63+
];
64+
$ignoreErrors[] = [
65+
// identifier: argument.type
66+
'message' => '#^Parameter \\#2 \\$id of class OneSignal\\\\Response\\\\Segment\\\\CreateSegmentResponse constructor expects non\\-empty\\-string, mixed given\\.$#',
67+
'count' => 1,
68+
'path' => __DIR__ . '/src/Response/Segment/CreateSegmentResponse.php',
69+
];
70+
$ignoreErrors[] = [
71+
// identifier: argument.type
72+
'message' => '#^Parameter \\#1 \\$success of class OneSignal\\\\Response\\\\Segment\\\\DeleteSegmentResponse constructor expects bool, mixed given\\.$#',
73+
'count' => 1,
74+
'path' => __DIR__ . '/src/Response/Segment/DeleteSegmentResponse.php',
75+
];
76+
$ignoreErrors[] = [
77+
// identifier: argument.type
78+
'message' => '#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(array\\)\\: OneSignal\\\\Response\\\\Segment\\\\Segment given\\.$#',
79+
'count' => 1,
80+
'path' => __DIR__ . '/src/Response/Segment/ListSegmentsResponse.php',
81+
];
82+
$ignoreErrors[] = [
83+
// identifier: argument.type
84+
'message' => '#^Parameter \\#1 \\$totalCount of class OneSignal\\\\Response\\\\Segment\\\\ListSegmentsResponse constructor expects int\\<0, max\\>, mixed given\\.$#',
85+
'count' => 1,
86+
'path' => __DIR__ . '/src/Response/Segment/ListSegmentsResponse.php',
87+
];
88+
$ignoreErrors[] = [
89+
// identifier: argument.type
90+
'message' => '#^Parameter \\#2 \\$array of function array_map expects array, mixed given\\.$#',
91+
'count' => 1,
92+
'path' => __DIR__ . '/src/Response/Segment/ListSegmentsResponse.php',
93+
];
94+
$ignoreErrors[] = [
95+
// identifier: argument.type
96+
'message' => '#^Parameter \\#2 \\$offset of class OneSignal\\\\Response\\\\Segment\\\\ListSegmentsResponse constructor expects int\\<0, 2147483648\\>, mixed given\\.$#',
97+
'count' => 1,
98+
'path' => __DIR__ . '/src/Response/Segment/ListSegmentsResponse.php',
99+
];
100+
$ignoreErrors[] = [
101+
// identifier: argument.type
102+
'message' => '#^Parameter \\#3 \\$limit of class OneSignal\\\\Response\\\\Segment\\\\ListSegmentsResponse constructor expects int\\<0, 2147483648\\>, mixed given\\.$#',
103+
'count' => 1,
104+
'path' => __DIR__ . '/src/Response/Segment/ListSegmentsResponse.php',
105+
];
106+
$ignoreErrors[] = [
107+
// identifier: argument.type
108+
'message' => '#^Parameter \\#4 \\$segments of class OneSignal\\\\Response\\\\Segment\\\\ListSegmentsResponse constructor expects list\\<OneSignal\\\\Response\\\\Segment\\\\Segment\\>, array\\<OneSignal\\\\Response\\\\Segment\\\\Segment\\> given\\.$#',
109+
'count' => 1,
110+
'path' => __DIR__ . '/src/Response/Segment/ListSegmentsResponse.php',
111+
];
112+
113+
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

phpstan.neon.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
includes:
22
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
4+
- phpstan-baseline.php
35

46
parameters:
57
bootstrapFiles:
@@ -10,7 +12,6 @@ parameters:
1012
tmpDir: %currentWorkingDirectory%/.phpstan
1113
level: 9
1214
inferPrivatePropertyTypeFromConstructor: true
13-
checkMissingIterableValueType: false
1415
checkGenericClassInNonGenericObjectType: true
1516
checkUninitializedProperties: true
1617
ignoreErrors:

src/Apps.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function __construct(OneSignal $client, ResolverFactory $resolverFactory)
3232
* User authentication key must be set.
3333
*
3434
* @param string $id ID of your application
35+
*
36+
* @return array<mixed>
3537
*/
3638
public function getOne(string $id): array
3739
{
@@ -45,6 +47,8 @@ public function getOne(string $id): array
4547
* Get information about all your created applications.
4648
*
4749
* User authentication key must be set.
50+
*
51+
* @return array<mixed>
4852
*/
4953
public function getAll(): array
5054
{
@@ -59,7 +63,9 @@ public function getAll(): array
5963
*
6064
* User authentication key must be set.
6165
*
62-
* @param array $data Application data
66+
* @param array<mixed> $data Application data
67+
*
68+
* @return array<mixed>
6369
*/
6470
public function add(array $data): array
6571
{
@@ -78,8 +84,10 @@ public function add(array $data): array
7884
*
7985
* User authentication key must be set.
8086
*
81-
* @param string $id ID of your application
82-
* @param array $data New application data
87+
* @param string $id ID of your application
88+
* @param array<mixed> $data New application data
89+
*
90+
* @return array<mixed>
8391
*/
8492
public function update(string $id, array $data): array
8593
{
@@ -96,10 +104,12 @@ public function update(string $id, array $data): array
96104
/**
97105
* Create a new segment for application with provided data.
98106
*
99-
* @param string $appId ID of your application
100-
* @param array $data Segment Data
107+
* @param string $appId ID of your application
108+
* @param array<mixed> $data Segment Data
109+
*
110+
* @return array<mixed>
101111
*/
102-
public function createSegment($appId, array $data): array
112+
public function createSegment(string $appId, array $data): array
103113
{
104114
$resolvedData = $this->resolverFactory->createSegmentResolver()->resolve($data);
105115

@@ -118,6 +128,8 @@ public function createSegment($appId, array $data): array
118128
*
119129
* @param string $appId Application ID
120130
* @param string $segmentId Segment ID
131+
*
132+
* @return array<mixed>
121133
*/
122134
public function deleteSegment(string $appId, string $segmentId): array
123135
{
@@ -130,8 +142,10 @@ public function deleteSegment(string $appId, string $segmentId): array
130142
/**
131143
* View the details of all the outcomes associated with your app.
132144
*
133-
* @param string $appId Application ID
134-
* @param array $data Outcome data filters
145+
* @param string $appId Application ID
146+
* @param array<mixed> $data Outcome data filters
147+
*
148+
* @return array<mixed>
135149
*/
136150
public function outcomes(string $appId, array $data): array
137151
{

src/Config.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@
66

77
final class Config
88
{
9-
private $applicationId;
10-
private $applicationAuthKey;
11-
private $userAuthKey;
9+
/**
10+
* @var non-empty-string
11+
*/
12+
private string $applicationId;
13+
14+
/**
15+
* @var non-empty-string
16+
*/
17+
private string $applicationAuthKey;
1218

19+
/**
20+
* @var non-empty-string|null
21+
*/
22+
private ?string $userAuthKey;
23+
24+
/**
25+
* @param non-empty-string $applicationId
26+
* @param non-empty-string $applicationAuthKey
27+
* @param non-empty-string|null $userAuthKey
28+
*/
1329
public function __construct(string $applicationId, string $applicationAuthKey, ?string $userAuthKey = null)
1430
{
1531
$this->applicationId = $applicationId;
@@ -19,6 +35,8 @@ public function __construct(string $applicationId, string $applicationAuthKey, ?
1935

2036
/**
2137
* Get OneSignal application id.
38+
*
39+
* @return non-empty-string
2240
*/
2341
public function getApplicationId(): string
2442
{
@@ -27,6 +45,8 @@ public function getApplicationId(): string
2745

2846
/**
2947
* Get OneSignal application authentication key.
48+
*
49+
* @return non-empty-string
3050
*/
3151
public function getApplicationAuthKey(): string
3252
{
@@ -35,6 +55,8 @@ public function getApplicationAuthKey(): string
3555

3656
/**
3757
* Get user authentication key.
58+
*
59+
* @return non-empty-string|null
3860
*/
3961
public function getUserAuthKey(): ?string
4062
{

0 commit comments

Comments
 (0)