Skip to content

Commit c812db8

Browse files
committed
Types - Add strict types, missing types and fix some CS
1 parent 6ec4d41 commit c812db8

File tree

134 files changed

+941
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+941
-701
lines changed

src/ActivityPhp/Server/Configuration.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
/**
1717
* Server configuration dispatcher
18-
*/
18+
*/
1919
class Configuration
2020
{
21-
const CONFIG_NS_PATTERN = '\ActivityPhp\Server\Configuration\%sConfiguration';
21+
private const CONFIG_NS_PATTERN = '\ActivityPhp\Server\Configuration\%sConfiguration';
2222

2323
/**
2424
* @var \ActivityPhp\Server\Configuration\HttpConfiguration
@@ -66,10 +66,10 @@ public function dispatchParameters(array $params): void
6666
] as $config
6767
) {
6868

69-
if (isset($params[$config]) && !is_array($params[$config])) {
69+
if (isset($params[$config]) && ! is_array($params[$config])) {
7070
throw new Exception(
71-
"Configuration value for '$config' must be an array"
72-
);
71+
"Configuration value for '{$config}' must be an array"
72+
);
7373
}
7474

7575
if (is_null($this->$config)) {
@@ -95,12 +95,12 @@ public function dispatchParameters(array $params): void
9595
throw new Exception(
9696
"Following configuration parameters have been ignored:\n"
9797
. json_encode($params, JSON_PRETTY_PRINT)
98-
);
99-
}
98+
);
99+
}
100100
}
101101
/**
102102
* Get a configuration dedicated handler
103-
*
103+
*
104104
* @return \ActivityPhp\Server\Configuration\LoggerConfiguration
105105
* | \ActivityPhp\Server\Configuration\InstanceConfiguration
106106
* | \ActivityPhp\Server\Configuration\HttpConfiguration
@@ -111,16 +111,16 @@ public function getConfig(string $parameter)
111111
{
112112
// Get configuration identifier
113113
$xpt = explode('.', $parameter, 2);
114-
114+
115115
if (isset($this->{$xpt[0]})) {
116-
if (!isset($xpt[1])) {
116+
if (! isset($xpt[1])) {
117117
return $this->{$xpt[0]};
118118
}
119119
return $this->{$xpt[0]}->get($xpt[1]);
120120
}
121121

122122
throw new Exception(
123123
"Configuration handler '{$xpt[0]}' does not exist"
124-
);
124+
);
125125
}
126126
}
Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the ActivityPhp package.
57
*
@@ -16,9 +18,9 @@
1618
* attributes between Activity and IntransitiveActivity.
1719
*
1820
* It SHOULD NOT be used as if.
19-
*
21+
*
2022
* Please use IntransitiveActivity or Activity instead.
21-
*
23+
*
2224
* @see https://www.w3.org/TR/activitystreams-core/#activities
2325
* @see https://www.w3.org/TR/activitystreams-core/#intransitiveactivities
2426
*/
@@ -30,82 +32,82 @@ abstract class AbstractActivity extends ObjectType
3032
protected $id;
3133

3234
/**
33-
* Describes one or more entities that either performed or are
35+
* Describes one or more entities that either performed or are
3436
* expected to perform the activity.
3537
* Any single activity can have multiple actors.
3638
* The actor MAY be specified using an indirect Link.
3739
*
3840
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-actor
39-
*
41+
*
4042
* @var string
4143
* | \ActivityPhp\Type\Extended\AbstractActor
42-
* | \ActivityPhp\Type\Core\Actor[]
43-
* | \ActivityPhp\Type\Core\Link
44-
* | \ActivityPhp\Type\Core\Link[]
44+
* | array<Actor>
45+
* | array<Link>
46+
* | Link
4547
*/
4648
protected $actor;
4749

4850
/**
4951
* The indirect object, or target, of the activity.
50-
* The precise meaning of the target is largely dependent on the
52+
* The precise meaning of the target is largely dependent on the
5153
* type of action being described but will often be the object of
5254
* the English preposition "to".
53-
* For instance, in the activity "John added a movie to his
55+
* For instance, in the activity "John added a movie to his
5456
* wishlist", the target of the activity is John's wishlist.
55-
* An activity can have more than one target.
57+
* An activity can have more than one target.
5658
*
5759
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-target
58-
*
60+
*
5961
* @var string
60-
* | \ActivityPhp\Type\Core\ObjectType
61-
* | \ActivityPhp\Type\Core\ObjectType[]
62-
* | \ActivityPhp\Type\Core\Link
63-
* | \ActivityPhp\Type\Core\Link[]
62+
* | ObjectType
63+
* | array<ObjectType>
64+
* | Link
65+
* | array<Link>
6466
*/
6567
protected $target;
6668

6769
/**
6870
* Describes the result of the activity.
69-
* For instance, if a particular action results in the creation of
70-
* a new resource, the result property can be used to describe
71+
* For instance, if a particular action results in the creation of
72+
* a new resource, the result property can be used to describe
7173
* that new resource.
72-
*
74+
*
7375
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-result
74-
*
76+
*
7577
* @var string
78+
* | ObjectType
79+
* | Link
7680
* | null
77-
* | \ActivityPhp\Type\Core\ObjectType
78-
* | \ActivityPhp\Type\Core\Link
7981
*/
8082
protected $result;
8183

8284
/**
83-
* An indirect object of the activity from which the
85+
* An indirect object of the activity from which the
8486
* activity is directed.
85-
* The precise meaning of the origin is the object of the English
87+
* The precise meaning of the origin is the object of the English
8688
* preposition "from".
87-
* For instance, in the activity "John moved an item to List B
89+
* For instance, in the activity "John moved an item to List B
8890
* from List A", the origin of the activity is "List A".
89-
*
91+
*
9092
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-origin
91-
*
93+
*
9294
* @var string
95+
* | ObjectType
96+
* | Link
9397
* | null
94-
* | \ActivityPhp\Type\Core\ObjectType
95-
* | \ActivityPhp\Type\Core\Link
9698
*/
9799
protected $origin;
98100

99101
/**
100-
* One or more objects used (or to be used) in the completion of an
102+
* One or more objects used (or to be used) in the completion of an
101103
* Activity.
102-
*
104+
*
103105
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-instrument
104-
*
106+
*
105107
* @var string
108+
* | ObjectType
109+
* | Link
106110
* | null
107-
* | \ActivityPhp\Type\Core\ObjectType
108-
* | \ActivityPhp\Type\Core\Link
109111
*/
110112
protected $instrument;
111113
}

src/ActivityPhp/Type/Core/Activity.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the ActivityPhp package.
57
*
@@ -12,11 +14,11 @@
1214
namespace ActivityPhp\Type\Core;
1315

1416
/**
15-
* \ActivityPhp\Type\Core\Activity is an implementation of one of the
17+
* \ActivityPhp\Type\Core\Activity is an implementation of one of the
1618
* Activity Streams Core Types.
1719
*
1820
* Activity objects are specializations of the base Object type that
19-
* provide information about actions that have either already occurred,
21+
* provide information about actions that have either already occurred,
2022
* are in the process of occurring, or may occur in the future.
2123
*
2224
* @see https://www.w3.org/TR/activitystreams-core/#activities
@@ -30,15 +32,15 @@ class Activity extends AbstractActivity
3032

3133
/**
3234
* Describes the direct object of the activity.
33-
* For instance, in the activity "John added a movie to his
35+
* For instance, in the activity "John added a movie to his
3436
* wishlist", the object of the activity is the movie added.
35-
*
37+
*
3638
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object-term
37-
*
39+
*
3840
* @var string
41+
* | ObjectType
42+
* | Link
3943
* | null
40-
* | \ActivityPhp\Type\Core\Object
41-
* | \ActivityPhp\Type\Core\Link
4244
*/
4345
protected $object;
4446
}
Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the ActivityPhp package.
57
*
@@ -12,7 +14,7 @@
1214
namespace ActivityPhp\Type\Core;
1315

1416
/**
15-
* \ActivityPhp\Type\Core\Collection is an implementation of one of the
17+
* \ActivityPhp\Type\Core\Collection is an implementation of one of the
1618
* Activity Streams Core Types.
1719
*
1820
* Collection objects are a specialization of the base Object that serve
@@ -33,75 +35,77 @@ class Collection extends ObjectType
3335
protected $id;
3436

3537
/**
36-
* A non-negative integer specifying the total number of objects
38+
* A non-negative integer specifying the total number of objects
3739
* contained by the logical view of the collection.
38-
* This number might not reflect the actual number of items
40+
* This number might not reflect the actual number of items
3941
* serialized within the Collection object instance.
40-
*
42+
*
4143
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-totalitems
4244
*
4345
* @var int
4446
*/
4547
protected $totalItems;
4648

4749
/**
48-
* In a paged Collection, indicates the page that contains the most
49-
* recently updated member items.
50-
*
50+
* In a paged Collection, indicates the page that contains the most
51+
* recently updated member items.
52+
*
5153
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-current
52-
*
54+
*
5355
* @var string
56+
* | Link
57+
* | CollectionPage
5458
* | null
55-
* | \ActivityPhp\Type\Core\Link
56-
* | \ActivityPhp\Type\Core\CollectionPage
5759
*/
5860
protected $current;
5961

6062
/**
6163
* The furthest preceeding page of items in the collection.
62-
*
64+
*
6365
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-last
64-
*
66+
*
6567
* @var string
68+
* | Link
69+
* | CollectionPage
6670
* | null
67-
* | \ActivityPhp\Type\Core\Link
68-
* | \ActivityPhp\Type\Core\CollectionPage
6971
*/
7072
protected $first;
7173

7274
/**
7375
* The furthest proceeding page of the collection.
74-
*
76+
*
7577
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-last
76-
*
78+
*
7779
* @var string
80+
* | Link
81+
* | CollectionPage
7882
* | null
79-
* | \ActivityPhp\Type\Core\Link
80-
* | \ActivityPhp\Type\Core\CollectionPage
8183
*/
8284
protected $last;
8385

8486
/**
85-
* The items contained in a collection.
87+
* The items contained in a collection.
8688
* The items are considered as unordered.
87-
*
89+
*
8890
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-items
89-
*
91+
*
9092
* @var array
91-
* | \ActivityPhp\Type\Core\Link
92-
* | \ActivityPhp\Type\Core\ObjectType[]
93+
* | Link
94+
* | array<Link>
95+
* | array<ObjectType>
9396
*/
9497
protected $items = [];
9598

9699
/**
97-
* The items contained in a collection.
100+
* The items contained in a collection.
98101
* The items are considered as ordered.
99-
*
102+
*
100103
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-items
101-
*
104+
*
102105
* @var array
103-
* | \ActivityPhp\Type\Core\Link
104-
* | \ActivityPhp\Type\Core\ObjectType[]
106+
* | Link
107+
* | array<Link>
108+
* | array<ObjectType>
105109
*/
106110
protected $orderedItems = [];
107111
}

0 commit comments

Comments
 (0)