Skip to content

Commit bb427f2

Browse files
authored
Merge pull request #1661 from CarlSchwan/carl/add-type-annotations
Add some type annotations
2 parents 6d78bff + acb56a5 commit bb427f2

57 files changed

Lines changed: 251 additions & 458 deletions

Some content is hidden

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

lib/CalDAV/CalendarHome.php

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,18 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL
2828

2929
/**
3030
* CalDAV backend.
31-
*
32-
* @var Backend\BackendInterface
3331
*/
34-
protected $caldavBackend;
32+
protected Backend\BackendInterface $caldavBackend;
3533

3634
/**
3735
* Principal information.
38-
*
39-
* @var array
4036
*/
41-
protected $principalInfo;
37+
protected array $principalInfo;
4238

4339
/**
4440
* Constructor.
45-
*
46-
* @param array $principalInfo
4741
*/
48-
public function __construct(Backend\BackendInterface $caldavBackend, $principalInfo)
42+
public function __construct(Backend\BackendInterface $caldavBackend, array $principalInfo)
4943
{
5044
$this->caldavBackend = $caldavBackend;
5145
$this->principalInfo = $principalInfo;
@@ -65,10 +59,8 @@ public function getName()
6559

6660
/**
6761
* Updates the name of this object.
68-
*
69-
* @param string $name
7062
*/
71-
public function setName($name)
63+
public function setName(string $name)
7264
{
7365
throw new DAV\Exception\Forbidden();
7466
}
@@ -96,10 +88,9 @@ public function getLastModified()
9688
*
9789
* This is currently not allowed
9890
*
99-
* @param string $name
10091
* @param resource $data
10192
*/
102-
public function createFile($name, $data = null)
93+
public function createFile(string $name, $data = null)
10394
{
10495
throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported');
10596
}
@@ -108,22 +99,18 @@ public function createFile($name, $data = null)
10899
* Creates a new directory under this object.
109100
*
110101
* This is currently not allowed.
111-
*
112-
* @param string $filename
113102
*/
114-
public function createDirectory($filename)
103+
public function createDirectory(string $filename)
115104
{
116105
throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported');
117106
}
118107

119108
/**
120109
* Returns a single calendar, by name.
121110
*
122-
* @param string $name
123-
*
124111
* @return Calendar
125112
*/
126-
public function getChild($name)
113+
public function getChild(string $name)
127114
{
128115
// Special nodes
129116
if ('inbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) {
@@ -161,11 +148,9 @@ public function getChild($name)
161148
/**
162149
* Checks if a calendar exists.
163150
*
164-
* @param string $name
165-
*
166151
* @return bool
167152
*/
168-
public function childExists($name)
153+
public function childExists(string $name)
169154
{
170155
try {
171156
return (bool) $this->getChild($name);
@@ -214,11 +199,9 @@ public function getChildren()
214199
/**
215200
* Creates a new calendar or subscription.
216201
*
217-
* @param string $name
218-
*
219202
* @throws DAV\Exception\InvalidResourceType
220203
*/
221-
public function createExtendedCollection($name, MkCol $mkCol)
204+
public function createExtendedCollection(string $name, MkCol $mkCol)
222205
{
223206
$isCalendar = false;
224207
$isSubscription = false;
@@ -274,7 +257,7 @@ public function getOwner()
274257
* * 'protected' (optional), indicating that this ACE is not allowed to
275258
* be updated.
276259
*
277-
* @return array
260+
* @return list<array{principal: string, privilege: string, protected?: bool}>
278261
*/
279262
public function getACL()
280263
{

lib/CalDAV/CalendarObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function getOwner()
192192
* * 'protected' (optional), indicating that this ACE is not allowed to
193193
* be updated.
194194
*
195-
* @return array
195+
* @return list<array{principal: string, privilege: string, protected?: bool}>
196196
*/
197197
public function getACL()
198198
{

lib/CalDAV/Principal/Collection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ class Collection extends DAVACL\PrincipalCollection
2222
{
2323
/**
2424
* Returns a child object based on principal information.
25-
*
26-
* @return User
2725
*/
28-
public function getChildForPrincipal(array $principalInfo)
26+
public function getChildForPrincipal(array $principalInfo): User
2927
{
3028
return new User($this->principalBackend, $principalInfo);
3129
}

lib/CalDAV/Principal/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function childExists($name)
115115
* * 'protected' (optional), indicating that this ACE is not allowed to
116116
* be updated.
117117
*
118-
* @return array
118+
* @return list<array{principal: string, privilege: string, protected?: bool}>
119119
*/
120120
public function getACL()
121121
{

lib/CalDAV/Schedule/Inbox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function getOwner()
128128
* * 'protected' (optional), indicating that this ACE is not allowed to
129129
* be updated.
130130
*
131-
* @return array
131+
* @return list<array{principal: string, privilege: string, protected?: bool}>
132132
*/
133133
public function getACL()
134134
{

lib/CalDAV/Schedule/Outbox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getOwner()
8484
* * 'protected' (optional), indicating that this ACE is not allowed to
8585
* be updated.
8686
*
87-
* @return array
87+
* @return list<array{principal: string, privilege: string, protected?: bool}>
8888
*/
8989
public function getACL()
9090
{

lib/CalDAV/Subscriptions/Subscription.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function getOwner()
179179
* * 'protected' (optional), indicating that this ACE is not allowed to
180180
* be updated.
181181
*
182-
* @return array
182+
* @return list<array{principal: string, privilege: string, protected?: bool}>
183183
*/
184184
public function getACL()
185185
{

lib/CardDAV/AddressBook.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,9 @@ public function propPatch(DAV\PropPatch $propPatch)
192192
*
193193
* If the array is empty, it means 'all properties' were requested.
194194
*
195-
* @param array $properties
196-
*
197195
* @return array
198196
*/
199-
public function getProperties($properties)
197+
public function getProperties(array $properties)
200198
{
201199
$response = [];
202200
foreach ($properties as $propertyName) {

lib/CardDAV/AddressBookRoot.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection
1919
{
2020
/**
2121
* Principal Backend.
22-
*
23-
* @var DAVACL\PrincipalBackend\BackendInterface
2422
*/
25-
protected $principalBackend;
23+
protected DAVACL\PrincipalBackend\BackendInterface $principalBackend;
2624

2725
/**
2826
* CardDAV backend.
29-
*
30-
* @var Backend\BackendInterface
3127
*/
32-
protected $carddavBackend;
28+
protected Backend\BackendInterface $carddavBackend;
3329

3430
/**
3531
* Constructor.
@@ -40,10 +36,8 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection
4036
* principals in the 'principals' collection. If your main principals are
4137
* actually located in a different path, use the $principalPrefix argument
4238
* to override this.
43-
*
44-
* @param string $principalPrefix
4539
*/
46-
public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals')
40+
public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, string $principalPrefix = 'principals')
4741
{
4842
$this->carddavBackend = $carddavBackend;
4943
parent::__construct($principalBackend, $principalPrefix);

lib/CardDAV/Card.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function getOwner()
181181
* * 'protected' (optional), indicating that this ACE is not allowed to
182182
* be updated.
183183
*
184-
* @return array
184+
* @return list<array{principal: string, privilege: string, protected?: bool}>
185185
*/
186186
public function getACL()
187187
{

0 commit comments

Comments
 (0)