diff --git a/src/Assertable.php b/src/Assertable.php index 32add3e..a6c027c 100644 --- a/src/Assertable.php +++ b/src/Assertable.php @@ -14,10 +14,5 @@ interface Assertable { - /** - * @param string $path - * @param string $command - * @return bool - */ public function assert(string $path, string $command): bool; } diff --git a/src/Behavior.php b/src/Behavior.php index a145e26..46e5fa9 100644 --- a/src/Behavior.php +++ b/src/Behavior.php @@ -42,11 +42,6 @@ class Behavior implements Assertable */ private $assertions; - /** - * @param Assertable $assertable - * @param string ...$commands - * @return static - */ public function withAssertion(Assertable $assertable, string ...$commands): self { $this->assertCommands($commands); @@ -59,11 +54,6 @@ public function withAssertion(Assertable $assertable, string ...$commands): self return $target; } - /** - * @param string $path - * @param string $command - * @return bool - */ public function assert(string $path, string $command): bool { $this->assertCommand($command); @@ -72,13 +62,10 @@ public function assert(string $path, string $command): bool return $this->assertions[$command]->assert($path, $command); } - /** - * @param array $commands - */ private function assertCommands(array $commands) { $unknownCommands = array_diff($commands, $this->availableCommands); - if (empty($unknownCommands)) { + if ($unknownCommands === []) { return; } throw new \LogicException( @@ -110,7 +97,7 @@ private function assertAssertionCompleteness() $this->availableCommands, array_keys($this->assertions) ); - if (empty($undefinedAssertions)) { + if ($undefinedAssertions === []) { return; } throw new \LogicException( diff --git a/src/Collectable.php b/src/Collectable.php index 97c9356..719478c 100644 --- a/src/Collectable.php +++ b/src/Collectable.php @@ -16,21 +16,14 @@ interface Collectable { - /** - * @param PharInvocation $invocation - * @return bool - */ public function has(PharInvocation $invocation): bool; /** - * @param PharInvocation $invocation * @param int|null $flags - * @return bool */ public function collect(PharInvocation $invocation, int $flags = null): bool; /** - * @param callable $callback * @param bool $reverse * @return null|PharInvocation */ diff --git a/src/Helper.php b/src/Helper.php index f880ece..be536e4 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -42,7 +42,6 @@ public static function resetOpCache() * For e.g. "phar:///home/user/bundle.phar/content.txt" that would result * into "/home/user/bundle.phar". * - * @param string $path * @return string|null */ public static function determineBaseFile(string $path) @@ -60,19 +59,11 @@ public static function determineBaseFile(string $path) return null; } - /** - * @param string $path - * @return bool - */ public static function hasPharPrefix(string $path): bool { return stripos($path, 'phar://') === 0; } - /** - * @param string $path - * @return string - */ public static function removePharPrefix(string $path): string { $path = trim($path); @@ -84,10 +75,7 @@ public static function removePharPrefix(string $path): string /** * Normalizes a path, removes phar:// prefix, fixes Windows directory - * separators. Result is without trailing slash. - * - * @param string $path - * @return string + * separators. The result is without a trailing slash. */ public static function normalizePath(string $path): string { @@ -101,9 +89,6 @@ public static function normalizePath(string $path): string /** * Fixes a path for windows-backslashes and reduces double-slashes to single slashes - * - * @param string $path File path to process - * @return string */ public static function normalizeWindowsPath(string $path): string { @@ -113,10 +98,9 @@ public static function normalizeWindowsPath(string $path): string /** * Resolves all dots, slashes and removes spaces after or before a path... * - * @param string $path Input string * @return string Canonical path, always without trailing slash */ - private static function getCanonicalPath($path): string + private static function getCanonicalPath(string $path): string { $path = static::normalizeWindowsPath($path); @@ -173,11 +157,8 @@ private static function getCanonicalPath($path): string /** * Checks if the $path is absolute or relative (detecting either '/' or * 'x:/' as first part of string) and returns TRUE if so. - * - * @param string $path File path to evaluate - * @return bool */ - private static function isAbsolutePath($path): bool + private static function isAbsolutePath(string $path): bool { // Path starting with a / is always absolute, on every system // On Windows also a path starting with a drive letter is absolute: X:/ diff --git a/src/Interceptor/ConjunctionInterceptor.php b/src/Interceptor/ConjunctionInterceptor.php index 1a85f59..589ac55 100644 --- a/src/Interceptor/ConjunctionInterceptor.php +++ b/src/Interceptor/ConjunctionInterceptor.php @@ -22,6 +22,9 @@ class ConjunctionInterceptor implements Assertable */ private $assertions; + /** + * @param Assertable[] $assertions + */ public function __construct(array $assertions) { $this->assertAssertions($assertions); @@ -31,9 +34,6 @@ public function __construct(array $assertions) /** * Executes assertions based on all contained assertions. * - * @param string $path - * @param string $command - * @return bool * @throws Exception */ public function assert(string $path, string $command): bool @@ -68,11 +68,6 @@ private function assertAssertions(array $assertions) } } - /** - * @param string $path - * @param string $command - * @return bool - */ private function invokeAssertions(string $path, string $command): bool { try { diff --git a/src/Interceptor/PharExtensionInterceptor.php b/src/Interceptor/PharExtensionInterceptor.php index df2c448..2fa9c45 100644 --- a/src/Interceptor/PharExtensionInterceptor.php +++ b/src/Interceptor/PharExtensionInterceptor.php @@ -21,9 +21,6 @@ class PharExtensionInterceptor implements Assertable /** * Determines whether the base file name has a ".phar" suffix. * - * @param string $path - * @param string $command - * @return bool * @throws Exception */ public function assert(string $path, string $command): bool @@ -40,10 +37,6 @@ public function assert(string $path, string $command): bool ); } - /** - * @param string $path - * @return bool - */ private function baseFileContainsPharExtension(string $path): bool { $invocation = Manager::instance()->resolve($path); diff --git a/src/Interceptor/PharMetaDataInterceptor.php b/src/Interceptor/PharMetaDataInterceptor.php index e818215..43b6173 100644 --- a/src/Interceptor/PharMetaDataInterceptor.php +++ b/src/Interceptor/PharMetaDataInterceptor.php @@ -28,9 +28,6 @@ class PharMetaDataInterceptor implements Assertable * Determines whether the according Phar archive contains * (potential insecure) serialized objects. * - * @param string $path - * @param string $command - * @return bool * @throws Exception */ public function assert(string $path, string $command): bool @@ -47,10 +44,6 @@ public function assert(string $path, string $command): bool ); } - /** - * @param string $path - * @return bool - */ private function baseFileDoesNotHaveMetaDataIssues(string $path): bool { $invocation = Manager::instance()->resolve($path); diff --git a/src/Manager.php b/src/Manager.php index aad63b5..6b62b99 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -38,12 +38,6 @@ class Manager */ private $collection; - /** - * @param Behavior $behaviour - * @param Resolvable $resolver - * @param Collectable $collection - * @return self - */ public static function initialize( Behavior $behaviour, Resolvable $resolver = null, @@ -59,9 +53,6 @@ public static function initialize( ); } - /** - * @return self - */ public static function instance(): self { if (self::$instance !== null) { @@ -73,9 +64,6 @@ public static function instance(): self ); } - /** - * @return bool - */ public static function destroy(): bool { if (self::$instance === null) { @@ -85,11 +73,6 @@ public static function destroy(): bool return true; } - /** - * @param Behavior $behaviour - * @param Resolvable $resolver - * @param Collectable $collection - */ private function __construct( Behavior $behaviour, Resolvable $resolver = null, @@ -100,19 +83,12 @@ private function __construct( $this->behavior = $behaviour; } - /** - * @param string $path - * @param string $command - * @return bool - */ public function assert(string $path, string $command): bool { return $this->behavior->assert($path, $command); } /** - * @param string $path - * @param null|int $flags * @return PharInvocation|null */ public function resolve(string $path, int $flags = null) @@ -120,9 +96,6 @@ public function resolve(string $path, int $flags = null) return $this->resolver->resolve($path, $flags); } - /** - * @return Collectable - */ public function getCollection(): Collectable { return $this->collection; diff --git a/src/Phar/Container.php b/src/Phar/Container.php index e1abf99..52dd2f1 100644 --- a/src/Phar/Container.php +++ b/src/Phar/Container.php @@ -24,35 +24,22 @@ class Container */ private $manifest; - /** - * @param Stub $stub - * @param Manifest $manifest - */ public function __construct(Stub $stub, Manifest $manifest) { $this->stub = $stub; $this->manifest = $manifest; } - /** - * @return Stub - */ public function getStub(): Stub { return $this->stub; } - /** - * @return Manifest - */ public function getManifest(): Manifest { return $this->manifest; } - /** - * @return string - */ public function getAlias(): string { return $this->manifest->getAlias() ?: $this->stub->getMappedAlias(); diff --git a/src/Phar/Manifest.php b/src/Phar/Manifest.php index 91968f9..8fa902a 100644 --- a/src/Phar/Manifest.php +++ b/src/Phar/Manifest.php @@ -15,8 +15,6 @@ class Manifest { /** - * @param string $content - * @return self * @see http://php.net/manual/en/phar.fileformat.phar.php */ public static function fromContent(string $content): self @@ -87,65 +85,41 @@ private function __construct() { } - /** - * @return int - */ public function getManifestLength(): int { return $this->manifestLength; } - /** - * @return int - */ public function getAmountOfFiles(): int { return $this->amountOfFiles; } - /** - * @return string - */ public function getApiVersion(): string { return $this->apiVersion; } - /** - * @return int - */ public function getFlags(): int { return $this->flags; } - /** - * @return int - */ public function getAliasLength(): int { return $this->aliasLength; } - /** - * @return string - */ public function getAlias(): string { return $this->alias; } - /** - * @return int - */ public function getMetaDataLength(): int { return $this->metaDataLength; } - /** - * @return string - */ public function getMetaData(): string { return $this->metaData; diff --git a/src/Phar/Reader.php b/src/Phar/Reader.php index 9e94c38..cdb491a 100644 --- a/src/Phar/Reader.php +++ b/src/Phar/Reader.php @@ -29,9 +29,6 @@ class Reader */ private $fileType; - /** - * @param string $fileName - */ public function __construct(string $fileName) { if (strpos($fileName, '://') !== false) { @@ -45,9 +42,6 @@ public function __construct(string $fileName) $this->fileType = $this->determineFileType(); } - /** - * @return Container - */ public function resolveContainer(): Container { $data = $this->extractData($this->resolveStream() . $this->fileName); @@ -83,7 +77,6 @@ public function resolveContainer(): Container /** * @param string $fileName e.g. '/path/file.phar' or 'compress.zlib:///path/file.phar' - * @return array */ private function extractData(string $fileName): array { @@ -143,28 +136,24 @@ private function extractData(string $fileName): array } /** - * Resolves stream in order to handle compressed Phar archives. - * - * @return string + * Resolves the stream to handle compressed Phar archives. */ private function resolveStream(): string { if ($this->fileType === 'application/x-gzip' || $this->fileType === 'application/gzip') { return 'compress.zlib://'; - } elseif ($this->fileType === 'application/x-bzip2') { + } + if ($this->fileType === 'application/x-bzip2') { return 'compress.bzip2://'; } return ''; } - /** - * @return string - */ - private function determineFileType() + private function determineFileType(): string { if (class_exists('\\finfo')) { $fileInfo = new \finfo(); - return $fileInfo->file($this->fileName, FILEINFO_MIME_TYPE); + return (string)$fileInfo->file($this->fileName, FILEINFO_MIME_TYPE); } return $this->determineFileTypeByHeader(); } @@ -172,8 +161,6 @@ private function determineFileType() /** * In case ext-fileinfo is not present only the relevant types * 'application/x-gzip' and 'application/x-bzip2' are resolved. - * - * @return string */ private function determineFileTypeByHeader(): string { @@ -186,17 +173,16 @@ private function determineFileTypeByHeader(): string } $header = fgets($resource, 4); fclose($resource); - $mimeType = ''; if (strpos($header, "\x42\x5a\x68") === 0) { - $mimeType = 'application/x-bzip2'; - } elseif (strpos($header, "\x1f\x8b") === 0) { - $mimeType = 'application/x-gzip'; + return 'application/x-bzip2'; + } + if (strpos($header, "\x1f\x8b") === 0) { + return 'application/x-gzip'; } - return $mimeType; + return ''; } /** - * @param string $content * @return int|null */ private function resolveManifestLength(string $content) @@ -207,11 +193,6 @@ private function resolveManifestLength(string $content) return static::resolveFourByteLittleEndian($content, 0); } - /** - * @param string $content - * @param int $start - * @return int - */ public static function resolveFourByteLittleEndian(string $content, int $start): int { $payload = substr($content, $start, 4); @@ -232,11 +213,6 @@ public static function resolveFourByteLittleEndian(string $content, int $start): return $value[1]; } - /** - * @param string $content - * @param int $start - * @return int - */ public static function resolveTwoByteBigEndian(string $content, int $start): int { $payload = substr($content, $start, 2); diff --git a/src/Phar/Stub.php b/src/Phar/Stub.php index 764d286..2c752a4 100644 --- a/src/Phar/Stub.php +++ b/src/Phar/Stub.php @@ -17,10 +17,6 @@ */ class Stub { - /** - * @param string $content - * @return self - */ public static function fromContent(string $content): self { $target = new static(); @@ -39,9 +35,9 @@ public static function fromContent(string $content): self } /** - * @var string + * @var null|string */ - private $content; + private $content = null; /** * @var string @@ -49,16 +45,13 @@ public static function fromContent(string $content): self private $mappedAlias = ''; /** - * @return string + * @return null|string */ public function getContent() { return $this->content; } - /** - * @return string - */ public function getMappedAlias(): string { return $this->mappedAlias; diff --git a/src/PharStreamWrapper.php b/src/PharStreamWrapper.php index 8455ce0..929e5d1 100644 --- a/src/PharStreamWrapper.php +++ b/src/PharStreamWrapper.php @@ -37,9 +37,6 @@ class PharStreamWrapper */ protected $invocation; - /** - * @return bool - */ public function dir_closedir(): bool { if (!is_resource($this->internalResource)) { @@ -53,11 +50,6 @@ public function dir_closedir(): bool return !is_resource($this->internalResource); } - /** - * @param string $path - * @param int $options - * @return bool - */ public function dir_opendir(string $path, int $options): bool { $this->assert($path, Behavior::COMMAND_DIR_OPENDIR); @@ -80,9 +72,6 @@ public function dir_readdir() ); } - /** - * @return bool - */ public function dir_rewinddir(): bool { if (!is_resource($this->internalResource)) { @@ -96,12 +85,6 @@ public function dir_rewinddir(): bool return is_resource($this->internalResource); } - /** - * @param string $path - * @param int $mode - * @param int $options - * @return bool - */ public function mkdir(string $path, int $mode, int $options): bool { $this->assert($path, Behavior::COMMAND_MKDIR); @@ -114,11 +97,6 @@ public function mkdir(string $path, int $mode, int $options): bool ); } - /** - * @param string $path_from - * @param string $path_to - * @return bool - */ public function rename(string $path_from, string $path_to): bool { $this->assert($path_from, Behavior::COMMAND_RENAME); @@ -131,11 +109,6 @@ public function rename(string $path_from, string $path_to): bool ); } - /** - * @param string $path - * @param int $options - * @return bool - */ public function rmdir(string $path, int $options): bool { $this->assert($path, Behavior::COMMAND_RMDIR); @@ -146,9 +119,6 @@ public function rmdir(string $path, int $options): bool ); } - /** - * @param int $cast_as - */ public function stream_cast(int $cast_as) { throw new Exception( @@ -165,9 +135,6 @@ public function stream_close() ); } - /** - * @return bool - */ public function stream_eof(): bool { return $this->invokeInternalStreamWrapper( @@ -176,9 +143,6 @@ public function stream_eof(): bool ); } - /** - * @return bool - */ public function stream_flush(): bool { return $this->invokeInternalStreamWrapper( @@ -187,10 +151,6 @@ public function stream_flush(): bool ); } - /** - * @param int $operation - * @return bool - */ public function stream_lock(int $operation): bool { return $this->invokeInternalStreamWrapper( @@ -201,10 +161,7 @@ public function stream_lock(int $operation): bool } /** - * @param string $path - * @param int $option * @param string|int $value - * @return bool */ public function stream_metadata(string $path, int $option, $value): bool { @@ -241,11 +198,7 @@ public function stream_metadata(string $path, int $option, $value): bool } /** - * @param string $path - * @param string $mode - * @param int $options * @param string|null $opened_path - * @return bool */ public function stream_open( string $path, @@ -277,10 +230,6 @@ public function stream_open( return true; } - /** - * @param int $count - * @return string - */ public function stream_read(int $count): string { return $this->invokeInternalStreamWrapper( @@ -290,11 +239,6 @@ public function stream_read(int $count): string ); } - /** - * @param int $offset - * @param int $whence - * @return bool - */ public function stream_seek(int $offset, int $whence = SEEK_SET): bool { return $this->invokeInternalStreamWrapper( @@ -305,12 +249,6 @@ public function stream_seek(int $offset, int $whence = SEEK_SET): bool ) !== -1; } - /** - * @param int $option - * @param int $arg1 - * @param int $arg2 - * @return bool - */ public function stream_set_option(int $option, int $arg1, int $arg2): bool { if ($option === STREAM_OPTION_BLOCKING) { @@ -338,9 +276,6 @@ public function stream_set_option(int $option, int $arg1, int $arg2): bool return false; } - /** - * @return array - */ public function stream_stat(): array { return $this->invokeInternalStreamWrapper( @@ -349,9 +284,6 @@ public function stream_stat(): array ); } - /** - * @return int - */ public function stream_tell(): int { return $this->invokeInternalStreamWrapper( @@ -360,10 +292,6 @@ public function stream_tell(): int ); } - /** - * @param int $new_size - * @return bool - */ public function stream_truncate(int $new_size): bool { return $this->invokeInternalStreamWrapper( @@ -373,10 +301,6 @@ public function stream_truncate(int $new_size): bool ); } - /** - * @param string $data - * @return int - */ public function stream_write(string $data): int { return $this->invokeInternalStreamWrapper( @@ -386,10 +310,6 @@ public function stream_write(string $data): int ); } - /** - * @param string $path - * @return bool - */ public function unlink(string $path): bool { $this->assert($path, Behavior::COMMAND_UNLINK); @@ -401,8 +321,6 @@ public function unlink(string $path): bool } /** - * @param string $path - * @param int $flags * @return array|false */ public function url_stat(string $path, int $flags) @@ -412,10 +330,6 @@ public function url_stat(string $path, int $flags) return $this->invokeInternalStreamWrapper($functionName, $path); } - /** - * @param string $path - * @param string $command - */ protected function assert(string $path, string $command) { if (Manager::instance()->assert($path, $command) === true) { @@ -433,9 +347,6 @@ protected function assert(string $path, string $command) ); } - /** - * @param string $path - */ protected function collectInvocation(string $path) { if (isset($this->invocation)) { @@ -470,7 +381,6 @@ protected function resolveAssertable(): Assertable /** * Invokes commands on the native PHP Phar stream wrapper. * - * @param string $functionName * @param mixed ...$arguments * @return mixed */ diff --git a/tests/Functional/Fixtures/Builder/Classes/Domain/Model/DemoModel.php b/tests/Functional/Fixtures/Builder/Classes/Domain/Model/DemoModel.php index 67d54fe..41d3915 100644 --- a/tests/Functional/Fixtures/Builder/Classes/Domain/Model/DemoModel.php +++ b/tests/Functional/Fixtures/Builder/Classes/Domain/Model/DemoModel.php @@ -3,8 +3,8 @@ class DemoModel { - public function getClassName() + public function getClassName(): string { return static::class; } -} \ No newline at end of file +} diff --git a/tests/Functional/Fixtures/Builder/build.php b/tests/Functional/Fixtures/Builder/build.php index e67d120..4c3896f 100755 --- a/tests/Functional/Fixtures/Builder/build.php +++ b/tests/Functional/Fixtures/Builder/build.php @@ -5,7 +5,7 @@ class TestModel {} } namespace { - include 'Classes/Domain/Model/DemoModel.php'; + include __DIR__ . '/Classes/Domain/Model/DemoModel.php'; $metaData = ['test' => new TYPO3\PharStreamWrapper\Tests\Functional\Fixtures\Source\TestModel()]; @unlink('../bundle.phar'); diff --git a/tests/Functional/Fixtures/Source/TestModel.php b/tests/Functional/Fixtures/Source/TestModel.php index 6f51694..7c6f89d 100644 --- a/tests/Functional/Fixtures/Source/TestModel.php +++ b/tests/Functional/Fixtures/Source/TestModel.php @@ -17,8 +17,8 @@ class TestModel public function __destruct() { throw new TestException( - sprintf('Destructed %s object', __CLASS__), + sprintf('Destructed %s object', self::class), 1553424350 ); } -} \ No newline at end of file +} diff --git a/tests/Functional/HelperTest.php b/tests/Functional/HelperTest.php index 2a54d5b..bcc4ea2 100644 --- a/tests/Functional/HelperTest.php +++ b/tests/Functional/HelperTest.php @@ -17,9 +17,6 @@ class HelperTest extends TestCase { - /** - * @return array - */ public function baseFileIsResolvedDataProvider(): array { $isWindows = DIRECTORY_SEPARATOR === '\\'; @@ -67,9 +64,6 @@ public function baseFileIsResolvedDataProvider(): array } /** - * @param string $path - * @param string $expectation - * * @test * @dataProvider baseFileIsResolvedDataProvider */ @@ -82,7 +76,6 @@ public function baseFileIsResolved(string $path, string $expectation = null) } /** - * @param string $directory * @param string[] $items * @return string[] */ @@ -90,17 +83,19 @@ private function substituteFileNames(string $directory, array $items): array { $directory = rtrim($directory); - return array_map( - function ($item) use ($directory) { - if (is_null($item)) { - return $item; - } - if (is_array($item)) { - return $this->substituteFileNames($directory, $item); - } - return str_replace('{DIR}', $directory, $item); - }, - $items + return array_filter( + array_map( + function ($item) use ($directory) { + if (is_null($item)) { + return null; + } + if (is_array($item)) { + return $this->substituteFileNames($directory, $item); + } + return str_replace('{DIR}', $directory, $item); + }, + $items + ) ); } } diff --git a/tests/Functional/Interceptor/AbstractTestCase.php b/tests/Functional/Interceptor/AbstractTestCase.php index 70e7900..421917b 100644 --- a/tests/Functional/Interceptor/AbstractTestCase.php +++ b/tests/Functional/Interceptor/AbstractTestCase.php @@ -39,9 +39,6 @@ abstract class AbstractTestCase extends TestCase */ const EXPECTED_EXCEPTION_CODE = 0; - /** - * @return array - */ public function allowedPathsDataProvider(): array { return array_combine( @@ -50,9 +47,6 @@ public function allowedPathsDataProvider(): array ); } - /** - * @return array - */ public function allowedAliasedPathsDataProvider(): array { return array_combine( @@ -61,9 +55,6 @@ public function allowedAliasedPathsDataProvider(): array ); } - /** - * @return array - */ public function deniedPathsDataProvider(): array { return array_combine( @@ -72,9 +63,6 @@ public function deniedPathsDataProvider(): array ); } - /** - * @return array - */ public function directoryActionAllowsInvocationDataProvider(): array { $dataSet = []; @@ -99,8 +87,6 @@ public function directoryActionAllowsInvocationDataProvider(): array } /** - * @param string $path - * * @test * @dataProvider directoryActionAllowsInvocationDataProvider */ @@ -115,7 +101,7 @@ public function directoryOpenAllowsInvocation(string $path) */ public function directoryOpenDeniesInvocationAfterCatchingError() { - if (empty($this->allowedPaths) || empty($this->deniedPaths)) { + if ($this->allowedPaths === [] || $this->deniedPaths === []) { $this->markTestSkipped('No ALLOWED_PATHS and DENIED_PATHS defined'); } try { @@ -126,8 +112,8 @@ public function directoryOpenDeniesInvocationAfterCatchingError() static::assertInstanceOf(Warning::class, $throwable); } - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); file_exists('phar://' . $this->deniedPaths[0]); } @@ -136,7 +122,7 @@ public function directoryOpenDeniesInvocationAfterCatchingError() */ public function directoryOpenDeniesInvocationAfterCatchingException() { - if (empty($this->allowedPaths) || empty($this->deniedPaths)) { + if ($this->allowedPaths === [] || $this->deniedPaths === []) { $this->markTestSkipped('No ALLOWED_PATHS and DENIED_PATHS defined'); } try { @@ -148,15 +134,12 @@ public function directoryOpenDeniesInvocationAfterCatchingException() static::assertSame(1539618987, $throwable->getCode()); } - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); file_exists('phar://' . $this->deniedPaths[0]); } /** - * @param string $path - * @param $expectation - * * @test * @dataProvider directoryActionAllowsInvocationDataProvider */ @@ -172,8 +155,6 @@ public function directoryReadAllowsInvocation(string $path, array $expectation) } /** - * @param string $path - * * @test * @dataProvider directoryActionAllowsInvocationDataProvider */ @@ -185,9 +166,6 @@ public function directoryCloseAllowsInvocation(string $path) self::assertFalse(is_resource($handle)); } - /** - * @return array - */ public function directoryActionDeniesInvocationDataProvider(): array { $dataSet = []; @@ -212,21 +190,16 @@ public function directoryActionDeniesInvocationDataProvider(): array } /** - * @param string $path - * * @test * @dataProvider directoryActionDeniesInvocationDataProvider */ public function directoryActionDeniesInvocation(string $path) { - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); opendir('phar://' . $path); } - /** - * @return array - */ public function urlStatAllowsInvocationDataProvider(): array { $dataSet = []; @@ -279,8 +252,6 @@ public function urlStatAllowsInvocationDataProvider(): array } /** - * @param string $functionName - * @param string $path * @param mixed $expectation * * @test @@ -294,9 +265,6 @@ public function urlStatAllowsInvocation(string $functionName, string $path, $exp ); } - /** - * @return array - */ public function urlStatDeniesInvocationDataProvider(): array { $dataSet = []; @@ -349,23 +317,17 @@ public function urlStatDeniesInvocationDataProvider(): array } /** - * @param string $functionName - * @param string $path - * @param mixed $expectation - * * @test * @dataProvider urlStatDeniesInvocationDataProvider */ public function urlStatDeniesInvocation(string $functionName, string $path) { - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); call_user_func($functionName, 'phar://' . $path); } /** - * @param string $allowedPath - * * @test * @dataProvider allowedPathsDataProvider */ @@ -376,8 +338,6 @@ public function streamOpenAllowsInvocationForFileOpen(string $allowedPath) } /** - * @param string $allowedPath - * * @test * @dataProvider allowedPathsDataProvider */ @@ -389,8 +349,6 @@ public function streamOpenAllowsInvocationForFileRead(string $allowedPath) } /** - * @param string $allowedPath - * * @test * @dataProvider allowedPathsDataProvider */ @@ -402,8 +360,6 @@ public function streamOpenAllowsInvocationForFileEnd(string $allowedPath) } /** - * @param string $allowedPath - * * @test * @dataProvider allowedPathsDataProvider */ @@ -415,8 +371,6 @@ public function streamOpenAllowsInvocationForFileClose(string $allowedPath) } /** - * @param string $allowedPath - * * @test * @dataProvider allowedPathsDataProvider */ @@ -427,8 +381,6 @@ public function streamOpenAllowsInvocationForFileGetContents(string $allowedPath } /** - * @param string $allowedPath - * * @test * @dataProvider allowedPathsDataProvider */ @@ -444,8 +396,6 @@ class_exists( } /** - * @param string $allowedPath - * * @test * @dataProvider allowedAliasedPathsDataProvider */ @@ -456,53 +406,41 @@ public function streamOpenAllowsInvocationForIncludeOnAliasedPhar(string $allowe } /** - * @param string $deniedPath - * * @test * @dataProvider deniedPathsDataProvider */ public function streamOpenDeniesInvocationForFileOpen(string $deniedPath) { - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); fopen('phar://' . $deniedPath . '/Resources/content.txt', 'r'); } /** - * @param string $deniedPath - * * @test * @dataProvider deniedPathsDataProvider */ public function streamOpenDeniesInvocationForFileGetContents(string $deniedPath) { - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); file_get_contents('phar://' . $deniedPath . '/Resources/content.txt'); } /** - * @param string $deniedPath - * * @test * @dataProvider deniedPathsDataProvider */ public function streamOpenDeniesInvocationForInclude(string $deniedPath) { - self::expectException(Exception::class); - self::expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); + $this->expectException(Exception::class); + $this->expectExceptionCode(static::EXPECTED_EXCEPTION_CODE); include('phar://' . $deniedPath . '/Classes/Domain/Model/DemoModel.php'); } - /** - * @return array - */ abstract public function isFileSystemInvocationAcceptableDataProvider(): array; /** - * @param string $path - * @param array $expectation - * * @test * @dataProvider isFileSystemInvocationAcceptableDataProvider * @throws \MaxMind\Db\Reader\InvalidDatabaseException @@ -527,11 +465,6 @@ public function isFileSystemInvocationAcceptable(string $path, array $expectatio self::assertSame($expectation, $invocations); } - /** - * @param array $monitoredInvocations - * @param string $path - * @return array - */ protected function groupInvocations(array $monitoredInvocations, string $path): array { $invocations = []; @@ -550,19 +483,11 @@ protected function groupInvocations(array $monitoredInvocations, string $path): return $invocations; } - /** - * @param string $value - * @return array - */ protected function wrapInArray(string $value): array { return [$value]; } - /** - * @param array $items - * @return array - */ protected function inflateDataSet(array $items): array { return array_combine( diff --git a/tests/Functional/Interceptor/ConjunctionInterceptorTest.php b/tests/Functional/Interceptor/ConjunctionInterceptorTest.php index be2ea70..a3f1174 100644 --- a/tests/Functional/Interceptor/ConjunctionInterceptorTest.php +++ b/tests/Functional/Interceptor/ConjunctionInterceptorTest.php @@ -12,6 +12,7 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3\PharStreamWrapper\Behavior; use TYPO3\PharStreamWrapper\Helper; use TYPO3\PharStreamWrapper\Interceptor\ConjunctionInterceptor; use TYPO3\PharStreamWrapper\Interceptor\PharExtensionInterceptor; @@ -62,8 +63,6 @@ class ConjunctionInterceptorTest extends AbstractTestCase protected function setUp() { - parent::setUp(); - if (!in_array('phar', stream_get_wrappers())) { $this->markTestSkipped('Phar stream wrapper is not registered'); } @@ -72,7 +71,7 @@ protected function setUp() stream_wrapper_register('phar', PharStreamWrapper::class); Manager::initialize( - (new \TYPO3\PharStreamWrapper\Behavior()) + (new Behavior()) ->withAssertion(new ConjunctionInterceptor([ new PharExtensionInterceptor(), new PharMetaDataInterceptor(), @@ -84,12 +83,8 @@ protected function tearDown() { stream_wrapper_restore('phar'); Manager::destroy(); - parent::tearDown(); } - /** - * @return array - */ public function isFileSystemInvocationAcceptableDataProvider(): array { $fixturePath = __DIR__ . '/../Fixtures'; diff --git a/tests/Functional/Interceptor/PharExtensionInterceptorTest.php b/tests/Functional/Interceptor/PharExtensionInterceptorTest.php index 35296d6..cfb93be 100644 --- a/tests/Functional/Interceptor/PharExtensionInterceptorTest.php +++ b/tests/Functional/Interceptor/PharExtensionInterceptorTest.php @@ -12,6 +12,7 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3\PharStreamWrapper\Behavior; use TYPO3\PharStreamWrapper\Helper; use TYPO3\PharStreamWrapper\Interceptor\PharExtensionInterceptor; use TYPO3\PharStreamWrapper\Manager; @@ -54,8 +55,6 @@ class PharExtensionInterceptorTest extends AbstractTestCase protected function setUp() { - parent::setUp(); - if (!in_array('phar', stream_get_wrappers())) { $this->markTestSkipped('Phar stream wrapper is not registered'); } @@ -64,7 +63,7 @@ protected function setUp() stream_wrapper_register('phar', PharStreamWrapper::class); Manager::initialize( - (new \TYPO3\PharStreamWrapper\Behavior()) + (new Behavior()) ->withAssertion(new PharExtensionInterceptor()) ); } @@ -73,12 +72,8 @@ protected function tearDown() { stream_wrapper_restore('phar'); Manager::destroy(); - parent::tearDown(); } - /** - * @return array - */ public function cliToolCommandDataProvider(): array { $fixtureDirectory = dirname(Helper::normalizeWindowsPath(__DIR__)) . '/Fixtures'; @@ -94,8 +89,6 @@ public function cliToolCommandDataProvider(): array } /** - * @param string $command - * * @test * @dataProvider cliToolCommandDataProvider */ @@ -132,9 +125,6 @@ public function cliToolIsExecuted(string $command) ], json_decode($response, true), 'The response is: ' . $response); } - /** - * @return array - */ public function isFileSystemInvocationAcceptableDataProvider(): array { $fixturePath = __DIR__ . '/../Fixtures'; diff --git a/tests/Functional/Interceptor/PharMetaDataInterceptorTest.php b/tests/Functional/Interceptor/PharMetaDataInterceptorTest.php index 56c8812..cfe791a 100644 --- a/tests/Functional/Interceptor/PharMetaDataInterceptorTest.php +++ b/tests/Functional/Interceptor/PharMetaDataInterceptorTest.php @@ -12,6 +12,7 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3\PharStreamWrapper\Behavior; use TYPO3\PharStreamWrapper\Helper; use TYPO3\PharStreamWrapper\Interceptor\PharMetaDataInterceptor; use TYPO3\PharStreamWrapper\Manager; @@ -60,8 +61,6 @@ class PharMetaDataInterceptorTest extends AbstractTestCase protected function setUp() { - parent::setUp(); - if (!in_array('phar', stream_get_wrappers())) { $this->markTestSkipped('Phar stream wrapper is not registered'); } @@ -70,7 +69,7 @@ protected function setUp() stream_wrapper_register('phar', PharStreamWrapper::class); Manager::initialize( - (new \TYPO3\PharStreamWrapper\Behavior()) + (new Behavior()) ->withAssertion(new PharMetaDataInterceptor()) ); } @@ -79,12 +78,8 @@ protected function tearDown() { stream_wrapper_restore('phar'); Manager::destroy(); - parent::tearDown(); } - /** - * @return array - */ public function isFileSystemInvocationAcceptableDataProvider(): array { $fixturePath = __DIR__ . '/../Fixtures'; diff --git a/tests/Functional/Phar/ReaderTest.php b/tests/Functional/Phar/ReaderTest.php index 8b4628a..587d6ef 100644 --- a/tests/Functional/Phar/ReaderTest.php +++ b/tests/Functional/Phar/ReaderTest.php @@ -40,7 +40,7 @@ public function pharAliasDataProvider(): array $fixturesPath . 'alias-special.phar', [ self::STUB_CONTENT_FLAG => '', - // actually PHP would throw an error when having different alias names + // actually, PHP would throw an error when having different alias names self::CONTAINER_ALIAS => 'spcl.phar', self::STUB_MAPPED_ALIAS => 'alias.special.phar', self::MANIFEST_ALIAS => 'spcl.phar', @@ -68,8 +68,6 @@ public function pharAliasDataProvider(): array } /** - * @param string $path - * @param array $expectations * @test * @dataProvider pharAliasDataProvider */ @@ -83,8 +81,6 @@ public function pharStubContentFlagCanBeResolved(string $path, array $expectatio } /** - * @param string $path - * @param array $expectations * @test * @dataProvider pharAliasDataProvider */ @@ -98,8 +94,6 @@ public function pharStubMappedAliasCanBeResolved(string $path, array $expectatio } /** - * @param string $path - * @param array $expectations * @test * @dataProvider pharAliasDataProvider */ @@ -113,8 +107,6 @@ public function pharManifestAliasCanBeResolved(string $path, array $expectations } /** - * @param string $path - * @param array $expectations * @test * @dataProvider pharAliasDataProvider */ @@ -127,9 +119,6 @@ public function pharContainerAliasCanBeResolved(string $path, array $expectation ); } - /** - * @return array - */ public function mimeTypeDataProvider(): array { $fixturesPath = dirname(__DIR__) . '/Fixtures/'; @@ -154,9 +143,6 @@ public function mimeTypeDataProvider(): array } /** - * @param string $path - * @param string $expectedMimeType - * * @test * @dataProvider mimeTypeDataProvider */ @@ -164,7 +150,7 @@ public function mimeTypeCanBeDetermined(string $path, string $expectedMimeType) { $reader = new Reader($path); $method = (new \ReflectionObject($reader))->getMethod('determineFileTypeByHeader'); - $method->setAccessible(TRUE); + $method->setAccessible(true); $this->assertSame($expectedMimeType, $method->invoke($reader)); } } diff --git a/tests/Functional/Resolver/PharInvocationResolverTest.php b/tests/Functional/Resolver/PharInvocationResolverTest.php index ec17e8d..f61d7c8 100644 --- a/tests/Functional/Resolver/PharInvocationResolverTest.php +++ b/tests/Functional/Resolver/PharInvocationResolverTest.php @@ -26,7 +26,6 @@ class PharInvocationResolverTest extends TestCase protected function setUp() { - parent::setUp(); Manager::initialize(new Behavior()); $this->subject = new PharInvocationResolver(); } @@ -35,12 +34,8 @@ protected function tearDown() { unset($this->subject); Manager::destroy(); - parent::tearDown(); } - /** - * @return array - */ public function invocationIsResolvedDataProvider(): array { $fixtureDirectory = dirname(__DIR__) . '/Fixtures'; @@ -81,9 +76,7 @@ public function invocationIsResolvedDataProvider(): array } /** - * @param string $path * @param int|null $flags - * @param array $expectations * * @test * @dataProvider invocationIsResolvedDataProvider @@ -95,9 +88,6 @@ public function invocationIsResolved(string $path, $flags, array $expectations) static::assertSame($invocation->getAlias(), $expectations['alias']); } - /** - * @return array - */ public function invocationIsNotResolvedDataProvider(): array { $fixtureDirectory = dirname(__DIR__) . '/Fixtures'; @@ -110,9 +100,7 @@ public function invocationIsNotResolvedDataProvider(): array } /** - * @param string $path * @param int|null $flags - * @param PharInvocation|null $expectation * * @test * @dataProvider invocationIsNotResolvedDataProvider @@ -126,13 +114,10 @@ public function invocationIsNotResolved(string $path, int $flags = null) /** * Duplicate of Helper::normalizeWindowsPath() for this test. * - * @param string $path File path to process - * @return string - * * @see Helper::normalizePath() */ private static function normalizeWindowsPath(string $path): string { return str_replace('\\', '/', $path); } -} \ No newline at end of file +} diff --git a/tests/Unit/BehaviourTest.php b/tests/Unit/BehaviourTest.php index 086a60c..9ac2353 100644 --- a/tests/Unit/BehaviourTest.php +++ b/tests/Unit/BehaviourTest.php @@ -37,7 +37,6 @@ class BehaviourTest extends TestCase protected function setUp() { - parent::setUp(); $this->path = uniqid('path'); $this->allAssertion = $this->prophesize(Assertable::class); $this->specificAssertion = $this->prophesize(Assertable::class); @@ -46,7 +45,6 @@ protected function setUp() protected function tearDown() { unset($this->path, $this->allAssertion, $this->specificAssertion); - parent::tearDown(); } /** diff --git a/tests/Unit/HelperTest.php b/tests/Unit/HelperTest.php index bc174cc..12f8ee1 100644 --- a/tests/Unit/HelperTest.php +++ b/tests/Unit/HelperTest.php @@ -17,9 +17,6 @@ class HelperTest extends TestCase { - /** - * @return array - */ public function pharPrefixIsRemovedDataProvider(): array { return [ @@ -37,9 +34,6 @@ public function pharPrefixIsRemovedDataProvider(): array } /** - * @param string $path - * @param string $expectation - * * @test * @dataProvider pharPrefixIsRemovedDataProvider */ @@ -51,9 +45,6 @@ public function pharPrefixIsRemoved(string $path, string $expectation) ); } - /** - * @return array - */ public function pathIsNormalizedDataProvider(): array { $dataSet = [ @@ -74,9 +65,6 @@ public function pathIsNormalizedDataProvider(): array } /** - * @param string $path - * @param string $expectation - * * @test * @dataProvider pathIsNormalizedDataProvider */ diff --git a/tests/Unit/ManagerTest.php b/tests/Unit/ManagerTest.php index ea2cf93..e4e69c3 100644 --- a/tests/Unit/ManagerTest.php +++ b/tests/Unit/ManagerTest.php @@ -26,14 +26,12 @@ class ManagerTest extends TestCase protected function setUp() { - parent::setUp(); $this->behaviorProphecy = $this->prophesize(Behavior::class); } protected function tearDown() { unset($this->behaviorProphecy); - parent::tearDown(); } /**