Skip to content

Commit 82ea0e9

Browse files
authored
Merge pull request #1329 from phil-davis/phpstan-level-1
phpstan level 1 and other fixes
2 parents 4258420 + 0939a25 commit 82ea0e9

File tree

19 files changed

+74
-26
lines changed

19 files changed

+74
-26
lines changed

lib/CalDAV/Schedule/Plugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ public function scheduleLocalDelivery(ITip\Message $iTipMessage)
486486

487487
$currentObject = null;
488488
$objectNode = null;
489+
$oldICalendarData = null;
489490
$isNewNode = false;
490491

491492
$result = $home->getCalendarObjectByUID($uid);

lib/DAV/Browser/Plugin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
157157
public function httpPOST(RequestInterface $request, ResponseInterface $response)
158158
{
159159
$contentType = $request->getHeader('Content-Type');
160+
if (!\is_string($contentType)) {
161+
return;
162+
}
160163
list($contentType) = explode(';', $contentType);
161164
if ('application/x-www-form-urlencoded' !== $contentType &&
162165
'multipart/form-data' !== $contentType) {

lib/DAV/FSExt/File.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function put($data)
4141
*
4242
* The second argument is the type of update we're doing.
4343
* This is either:
44-
* * 1. append
44+
* * 1. append (default)
4545
* * 2. update based on a start byte
4646
* * 3. update based on an end byte
4747
*;
@@ -75,6 +75,9 @@ public function patch($data, $rangeType, $offset = null)
7575
$f = fopen($this->path, 'c');
7676
fseek($f, $offset, SEEK_END);
7777
break;
78+
default:
79+
$f = fopen($this->path, 'a');
80+
break;
7881
}
7982
if (is_string($data)) {
8083
fwrite($f, $data);

lib/DAV/Tree.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ protected function copyNode(INode $source, ICollection $destinationParent, $dest
292292
$destinationName = $source->getName();
293293
}
294294

295+
$destination = null;
296+
295297
if ($source instanceof IFile) {
296298
$data = $source->get();
297299

lib/DAV/Xml/Property/Href.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ class Href implements Element, HtmlOutput
3939
*
4040
* You must either pass a string for a single href, or an array of hrefs.
4141
*
42-
* If auto-prefix is set to false, the hrefs will be treated as absolute
43-
* and not relative to the servers base uri.
44-
*
4542
* @param string|string[] $hrefs
4643
*/
4744
public function __construct($hrefs)

phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
parameters:
2-
level: 0
2+
level: 1
3+
bootstrapFiles:
4+
- tests/bootstrap.php

tests/Sabre/CalDAV/Backend/AbstractPDOTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ public function testGetChangesBadId()
963963
public function testCreateSubscriptions()
964964
{
965965
$props = [
966-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
966+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics'),
967967
'{DAV:}displayname' => 'cal',
968968
'{http://apple.com/ns/ical/}refreshrate' => 'P1W',
969969
'{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
@@ -1004,7 +1004,7 @@ public function testCreateSubscriptionFail()
10041004
public function testUpdateSubscriptions()
10051005
{
10061006
$props = [
1007-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
1007+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics'),
10081008
'{DAV:}displayname' => 'cal',
10091009
'{http://apple.com/ns/ical/}refreshrate' => 'P1W',
10101010
'{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
@@ -1018,7 +1018,7 @@ public function testUpdateSubscriptions()
10181018

10191019
$newProps = [
10201020
'{DAV:}displayname' => 'new displayname',
1021-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false),
1021+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics'),
10221022
];
10231023

10241024
$propPatch = new DAV\PropPatch($newProps);
@@ -1046,7 +1046,7 @@ public function testUpdateSubscriptions()
10461046
public function testUpdateSubscriptionsFail()
10471047
{
10481048
$props = [
1049-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
1049+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics'),
10501050
'{DAV:}displayname' => 'cal',
10511051
'{http://apple.com/ns/ical/}refreshrate' => 'P1W',
10521052
'{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
@@ -1060,7 +1060,7 @@ public function testUpdateSubscriptionsFail()
10601060

10611061
$propPatch = new DAV\PropPatch([
10621062
'{DAV:}displayname' => 'new displayname',
1063-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false),
1063+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics'),
10641064
'{DAV:}unknown' => 'foo',
10651065
]);
10661066

@@ -1077,7 +1077,7 @@ public function testUpdateSubscriptionsFail()
10771077
public function testDeleteSubscriptions()
10781078
{
10791079
$props = [
1080-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
1080+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics'),
10811081
'{DAV:}displayname' => 'cal',
10821082
'{http://apple.com/ns/ical/}refreshrate' => 'P1W',
10831083
'{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
@@ -1091,7 +1091,7 @@ public function testDeleteSubscriptions()
10911091

10921092
$newProps = [
10931093
'{DAV:}displayname' => 'new displayname',
1094-
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false),
1094+
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics'),
10951095
];
10961096

10971097
$backend->deleteSubscription(1);

tests/Sabre/CalDAV/Schedule/SchedulingObjectTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public function testInvalidArg1()
7575
$this->expectException('InvalidArgumentException');
7676
$obj = new SchedulingObject(
7777
new Backend\MockScheduling([], []),
78-
[],
7978
[]
8079
);
8180
}
@@ -85,7 +84,6 @@ public function testInvalidArg2()
8584
$this->expectException('InvalidArgumentException');
8685
$obj = new SchedulingObject(
8786
new Backend\MockScheduling([], []),
88-
[],
8987
['calendarid' => '1']
9088
);
9189
}

tests/Sabre/CalDAV/Subscriptions/SubscriptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function getSub($override = [])
1616
$caldavBackend = new \Sabre\CalDAV\Backend\MockSubscriptionSupport([], []);
1717

1818
$info = [
19-
'{http://calendarserver.org/ns/}source' => new Href('http://example.org/src', false),
19+
'{http://calendarserver.org/ns/}source' => new Href('http://example.org/src'),
2020
'lastmodified' => date('2013-04-06 11:40:00'), // tomorrow is my birthday!
2121
'{DAV:}displayname' => 'displayname',
2222
];
@@ -43,7 +43,7 @@ public function testValues()
4343
$this->assertEquals(
4444
[
4545
'{DAV:}displayname' => 'displayname',
46-
'{http://calendarserver.org/ns/}source' => new Href('http://example.org/src', false),
46+
'{http://calendarserver.org/ns/}source' => new Href('http://example.org/src'),
4747
],
4848
$sub->getProperties(['{DAV:}displayname', '{http://calendarserver.org/ns/}source'])
4949
);

tests/Sabre/DAV/Browser/PluginTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ public function testPostOtherContentType()
104104
$this->assertEquals(501, $this->response->status);
105105
}
106106

107+
public function testPostNoContentType()
108+
{
109+
$request = new HTTP\Request('POST', '/', []);
110+
$this->server->httpRequest = $request;
111+
$this->server->exec();
112+
113+
$this->assertEquals(501, $this->response->status);
114+
}
115+
107116
public function testPostNoSabreAction()
108117
{
109118
$request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']);

0 commit comments

Comments
 (0)