Skip to content

Commit 39a7c0f

Browse files
committed
boyscout
1 parent 9a05cc0 commit 39a7c0f

1 file changed

Lines changed: 7 additions & 29 deletions

File tree

src/Components/Path.php

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,12 @@
99
*/
1010
final class Path {
1111

12-
/**
13-
* @var bool
14-
*/
15-
private $absolute;
16-
17-
/**
18-
* @var bool
19-
*/
20-
private $hasTail;
12+
private bool $absolute;
13+
private bool $hasTail;
14+
private string $fileExtension;
2115

22-
/**
23-
* @var string[]
24-
*/
25-
private $parts;
26-
/**
27-
* @var string
28-
*/
29-
private $fileExtension;
16+
/** @var string[] */
17+
private array $parts;
3018

3119
/**
3220
* @param string $path
@@ -67,20 +55,14 @@ static function createFromString (string $path) : Path {
6755
function __construct (bool $absolute, bool $hasTail, string $fileExtension, string ...$parts) {
6856
$this->absolute = $absolute;
6957
$this->hasTail = $hasTail;
70-
$this->parts = $parts;
7158
$this->fileExtension = $fileExtension;
59+
$this->parts = $parts;
7260
}
7361

74-
/**
75-
* @return bool
76-
*/
7762
function isAbsolute () : bool {
7863
return $this->absolute;
7964
}
8065

81-
/**
82-
* @return bool
83-
*/
8466
function hasTail () : bool {
8567
return $this->hasTail;
8668
}
@@ -122,7 +104,7 @@ function getFileExtension () {
122104
* This might be dangerous in some cases, e.g. when allowing multiple slashes
123105
* in a URI that has no authority part
124106
*
125-
* (It would allow XSS or open redirects by omitting the scheme, but setting a new
107+
* (It would allow XSS or open redirects by omitting the scheme by setting a new
126108
* authority like `//malicious-website.com/foo/bar`).
127109
*
128110
* @see https://framework.zend.com/security/advisory/ZF2015-05.html
@@ -155,10 +137,6 @@ function __toString () : string {
155137
return $this->compose();
156138
}
157139

158-
/**
159-
* @param string $part
160-
* @return string
161-
*/
162140
private function encodePathPart (string $part) : string {
163141
// To ensure compliance to php-http/psr7-integration-tests, we have to lowercase all replaced url entities
164142
// PSR-7 itself does not specify this and allows upper- as well as lowercase

0 commit comments

Comments
 (0)