Skip to content

Commit a931b28

Browse files
committed
[TASK] Clean up code
* adjust method/function signatures were applicable * remove superfluous phpdoc comments * simplify conditions
1 parent e23a301 commit a931b28

26 files changed

+64
-459
lines changed

src/Assertable.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,5 @@
1414

1515
interface Assertable
1616
{
17-
/**
18-
* @param string $path
19-
* @param string $command
20-
* @return bool
21-
*/
2217
public function assert(string $path, string $command): bool;
2318
}

src/Behavior.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ class Behavior implements Assertable
4242
*/
4343
private $assertions;
4444

45-
/**
46-
* @param Assertable $assertable
47-
* @param string ...$commands
48-
* @return static
49-
*/
5045
public function withAssertion(Assertable $assertable, string ...$commands): self
5146
{
5247
$this->assertCommands($commands);
@@ -59,11 +54,6 @@ public function withAssertion(Assertable $assertable, string ...$commands): self
5954
return $target;
6055
}
6156

62-
/**
63-
* @param string $path
64-
* @param string $command
65-
* @return bool
66-
*/
6757
public function assert(string $path, string $command): bool
6858
{
6959
$this->assertCommand($command);
@@ -72,13 +62,10 @@ public function assert(string $path, string $command): bool
7262
return $this->assertions[$command]->assert($path, $command);
7363
}
7464

75-
/**
76-
* @param array $commands
77-
*/
7865
private function assertCommands(array $commands)
7966
{
8067
$unknownCommands = array_diff($commands, $this->availableCommands);
81-
if (empty($unknownCommands)) {
68+
if ($unknownCommands === []) {
8269
return;
8370
}
8471
throw new \LogicException(
@@ -110,7 +97,7 @@ private function assertAssertionCompleteness()
11097
$this->availableCommands,
11198
array_keys($this->assertions)
11299
);
113-
if (empty($undefinedAssertions)) {
100+
if ($undefinedAssertions === []) {
114101
return;
115102
}
116103
throw new \LogicException(

src/Collectable.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,14 @@
1616

1717
interface Collectable
1818
{
19-
/**
20-
* @param PharInvocation $invocation
21-
* @return bool
22-
*/
2319
public function has(PharInvocation $invocation): bool;
2420

2521
/**
26-
* @param PharInvocation $invocation
2722
* @param int|null $flags
28-
* @return bool
2923
*/
3024
public function collect(PharInvocation $invocation, int $flags = null): bool;
3125

3226
/**
33-
* @param callable $callback
3427
* @param bool $reverse
3528
* @return null|PharInvocation
3629
*/

src/Helper.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public static function resetOpCache()
4242
* For e.g. "phar:///home/user/bundle.phar/content.txt" that would result
4343
* into "/home/user/bundle.phar".
4444
*
45-
* @param string $path
4645
* @return string|null
4746
*/
4847
public static function determineBaseFile(string $path)
@@ -60,19 +59,11 @@ public static function determineBaseFile(string $path)
6059
return null;
6160
}
6261

63-
/**
64-
* @param string $path
65-
* @return bool
66-
*/
6762
public static function hasPharPrefix(string $path): bool
6863
{
6964
return stripos($path, 'phar://') === 0;
7065
}
7166

72-
/**
73-
* @param string $path
74-
* @return string
75-
*/
7667
public static function removePharPrefix(string $path): string
7768
{
7869
$path = trim($path);
@@ -84,10 +75,7 @@ public static function removePharPrefix(string $path): string
8475

8576
/**
8677
* Normalizes a path, removes phar:// prefix, fixes Windows directory
87-
* separators. Result is without trailing slash.
88-
*
89-
* @param string $path
90-
* @return string
78+
* separators. The result is without a trailing slash.
9179
*/
9280
public static function normalizePath(string $path): string
9381
{
@@ -101,9 +89,6 @@ public static function normalizePath(string $path): string
10189

10290
/**
10391
* Fixes a path for windows-backslashes and reduces double-slashes to single slashes
104-
*
105-
* @param string $path File path to process
106-
* @return string
10792
*/
10893
public static function normalizeWindowsPath(string $path): string
10994
{
@@ -113,10 +98,9 @@ public static function normalizeWindowsPath(string $path): string
11398
/**
11499
* Resolves all dots, slashes and removes spaces after or before a path...
115100
*
116-
* @param string $path Input string
117101
* @return string Canonical path, always without trailing slash
118102
*/
119-
private static function getCanonicalPath($path): string
103+
private static function getCanonicalPath(string $path): string
120104
{
121105
$path = static::normalizeWindowsPath($path);
122106

@@ -173,11 +157,8 @@ private static function getCanonicalPath($path): string
173157
/**
174158
* Checks if the $path is absolute or relative (detecting either '/' or
175159
* 'x:/' as first part of string) and returns TRUE if so.
176-
*
177-
* @param string $path File path to evaluate
178-
* @return bool
179160
*/
180-
private static function isAbsolutePath($path): bool
161+
private static function isAbsolutePath(string $path): bool
181162
{
182163
// Path starting with a / is always absolute, on every system
183164
// On Windows also a path starting with a drive letter is absolute: X:/

src/Interceptor/ConjunctionInterceptor.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class ConjunctionInterceptor implements Assertable
2222
*/
2323
private $assertions;
2424

25+
/**
26+
* @param Assertable[] $assertions
27+
*/
2528
public function __construct(array $assertions)
2629
{
2730
$this->assertAssertions($assertions);
@@ -31,9 +34,6 @@ public function __construct(array $assertions)
3134
/**
3235
* Executes assertions based on all contained assertions.
3336
*
34-
* @param string $path
35-
* @param string $command
36-
* @return bool
3737
* @throws Exception
3838
*/
3939
public function assert(string $path, string $command): bool
@@ -68,11 +68,6 @@ private function assertAssertions(array $assertions)
6868
}
6969
}
7070

71-
/**
72-
* @param string $path
73-
* @param string $command
74-
* @return bool
75-
*/
7671
private function invokeAssertions(string $path, string $command): bool
7772
{
7873
try {

src/Interceptor/PharExtensionInterceptor.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ class PharExtensionInterceptor implements Assertable
2121
/**
2222
* Determines whether the base file name has a ".phar" suffix.
2323
*
24-
* @param string $path
25-
* @param string $command
26-
* @return bool
2724
* @throws Exception
2825
*/
2926
public function assert(string $path, string $command): bool
@@ -40,10 +37,6 @@ public function assert(string $path, string $command): bool
4037
);
4138
}
4239

43-
/**
44-
* @param string $path
45-
* @return bool
46-
*/
4740
private function baseFileContainsPharExtension(string $path): bool
4841
{
4942
$invocation = Manager::instance()->resolve($path);

src/Interceptor/PharMetaDataInterceptor.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ class PharMetaDataInterceptor implements Assertable
2828
* Determines whether the according Phar archive contains
2929
* (potential insecure) serialized objects.
3030
*
31-
* @param string $path
32-
* @param string $command
33-
* @return bool
3431
* @throws Exception
3532
*/
3633
public function assert(string $path, string $command): bool
@@ -47,10 +44,6 @@ public function assert(string $path, string $command): bool
4744
);
4845
}
4946

50-
/**
51-
* @param string $path
52-
* @return bool
53-
*/
5447
private function baseFileDoesNotHaveMetaDataIssues(string $path): bool
5548
{
5649
$invocation = Manager::instance()->resolve($path);

src/Manager.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ class Manager
3838
*/
3939
private $collection;
4040

41-
/**
42-
* @param Behavior $behaviour
43-
* @param Resolvable $resolver
44-
* @param Collectable $collection
45-
* @return self
46-
*/
4741
public static function initialize(
4842
Behavior $behaviour,
4943
Resolvable $resolver = null,
@@ -59,9 +53,6 @@ public static function initialize(
5953
);
6054
}
6155

62-
/**
63-
* @return self
64-
*/
6556
public static function instance(): self
6657
{
6758
if (self::$instance !== null) {
@@ -73,9 +64,6 @@ public static function instance(): self
7364
);
7465
}
7566

76-
/**
77-
* @return bool
78-
*/
7967
public static function destroy(): bool
8068
{
8169
if (self::$instance === null) {
@@ -85,11 +73,6 @@ public static function destroy(): bool
8573
return true;
8674
}
8775

88-
/**
89-
* @param Behavior $behaviour
90-
* @param Resolvable $resolver
91-
* @param Collectable $collection
92-
*/
9376
private function __construct(
9477
Behavior $behaviour,
9578
Resolvable $resolver = null,
@@ -100,29 +83,19 @@ private function __construct(
10083
$this->behavior = $behaviour;
10184
}
10285

103-
/**
104-
* @param string $path
105-
* @param string $command
106-
* @return bool
107-
*/
10886
public function assert(string $path, string $command): bool
10987
{
11088
return $this->behavior->assert($path, $command);
11189
}
11290

11391
/**
114-
* @param string $path
115-
* @param null|int $flags
11692
* @return PharInvocation|null
11793
*/
11894
public function resolve(string $path, int $flags = null)
11995
{
12096
return $this->resolver->resolve($path, $flags);
12197
}
12298

123-
/**
124-
* @return Collectable
125-
*/
12699
public function getCollection(): Collectable
127100
{
128101
return $this->collection;

src/Phar/Container.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,22 @@ class Container
2424
*/
2525
private $manifest;
2626

27-
/**
28-
* @param Stub $stub
29-
* @param Manifest $manifest
30-
*/
3127
public function __construct(Stub $stub, Manifest $manifest)
3228
{
3329
$this->stub = $stub;
3430
$this->manifest = $manifest;
3531
}
3632

37-
/**
38-
* @return Stub
39-
*/
4033
public function getStub(): Stub
4134
{
4235
return $this->stub;
4336
}
4437

45-
/**
46-
* @return Manifest
47-
*/
4838
public function getManifest(): Manifest
4939
{
5040
return $this->manifest;
5141
}
5242

53-
/**
54-
* @return string
55-
*/
5643
public function getAlias(): string
5744
{
5845
return $this->manifest->getAlias() ?: $this->stub->getMappedAlias();

0 commit comments

Comments
 (0)