@@ -9,7 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace Serafim\Stream\Filter; |
| 11 | 11 | |
| 12 | -use Composer\Autoload\ClassLoader; |
|
| 13 | 12 | use Psr\SimpleCache\CacheInterface; |
| 14 | 13 | use Serafim\Stream\Exception\StreamCreatingException; |
| 15 | 14 | use Serafim\Stream\Stream; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $this->stream = Stream::new(32); |
| 46 | 46 | |
| 47 | - $this->stream->onRead(function (string $sources) { |
|
| 47 | + $this->stream->onRead(function(string $sources) { |
|
| 48 | 48 | foreach ($this->then as $handler) { |
| 49 | 49 | $sources = $handler($sources); |
| 50 | 50 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return $sources; |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | - $this->where(function (string $class, string $pathname) use ($vendorDirectory): bool { |
|
| 55 | + $this->where(function(string $class, string $pathname) use ($vendorDirectory): bool { |
|
| 56 | 56 | if ($this->vendor) { |
| 57 | 57 | return true; |
| 58 | 58 | } |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function through(CacheInterface $cache, callable $then): self |
| 111 | 111 | { |
| 112 | - return $this->then(function (string $sources) use ($cache, $then) { |
|
| 112 | + return $this->then(function(string $sources) use ($cache, $then) { |
|
| 113 | 113 | $key = \md5($sources); |
| 114 | 114 | |
| 115 | - if (! $cache->has($key)) { |
|
| 115 | + if (!$cache->has($key)) { |
|
| 116 | 116 | $cache->set($key, $then($sources)); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function not(callable $filter): self |
| 37 | 37 | { |
| 38 | - return $this->where(function (string $class, string $file) use ($filter): bool { |
|
| 39 | - return ! $filter($class, $file); |
|
| 38 | + return $this->where(function(string $class, string $file) use ($filter): bool { |
|
| 39 | + return !$filter($class, $file); |
|
| 40 | 40 | }); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function every(\Closure $then): self |
| 59 | 59 | { |
| 60 | - return $this->where(function (string $class, string $file) use ($then): bool { |
|
| 60 | + return $this->where(function(string $class, string $file) use ($then): bool { |
|
| 61 | 61 | $then($conjunction = new Conjunction()); |
| 62 | 62 | |
| 63 | 63 | return $conjunction->match($class, $file); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function any(\Closure $then): self |
| 72 | 72 | { |
| 73 | - return $this->where(function (string $class, string $file) use ($then): bool { |
|
| 73 | + return $this->where(function(string $class, string $file) use ($then): bool { |
|
| 74 | 74 | $then($disjunction = new Disjunction()); |
| 75 | 75 | |
| 76 | 76 | return $disjunction->match($class, $file); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function fqn(string $fqn): self |
| 85 | 85 | { |
| 86 | - return $this->where(function (string $class) use ($fqn): bool { |
|
| 86 | + return $this->where(function(string $class) use ($fqn): bool { |
|
| 87 | 87 | return \trim($class, '\\') === \trim($fqn, '\\'); |
| 88 | 88 | }); |
| 89 | 89 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $name = \trim($name, '\\'); |
| 98 | 98 | |
| 99 | - return $this->where(function (string $fqn) use ($name): bool { |
|
| 99 | + return $this->where(function(string $fqn) use ($name): bool { |
|
| 100 | 100 | return \substr($fqn, -\strlen($name)) === $name; |
| 101 | 101 | }); |
| 102 | 102 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $prefix = \trim($prefix, '\\'); |
| 111 | 111 | |
| 112 | - return $this->where(function (string $class) use ($prefix): bool { |
|
| 112 | + return $this->where(function(string $class) use ($prefix): bool { |
|
| 113 | 113 | return \strpos(\trim($class, '\\'), $prefix) === 0; |
| 114 | 114 | }); |
| 115 | 115 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function fileName(string $name): self |
| 122 | 122 | { |
| 123 | - return $this->where(function (string $_, string $file) use ($name): bool { |
|
| 123 | + return $this->where(function(string $_, string $file) use ($name): bool { |
|
| 124 | 124 | return \pathinfo($file, \PATHINFO_FILENAME) === $name; |
| 125 | 125 | }); |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $regex = $this->regex($regex, false); |
| 135 | 135 | |
| 136 | - return $this->where(function (string $_, string $file) use ($regex): bool { |
|
| 136 | + return $this->where(function(string $_, string $file) use ($regex): bool { |
|
| 137 | 137 | return \preg_match($regex, $file) !== 0; |
| 138 | 138 | }); |
| 139 | 139 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $regex = $this->regex($regex); |
| 148 | 148 | |
| 149 | - return $this->where(function (string $_, string $file) use ($regex): bool { |
|
| 149 | + return $this->where(function(string $_, string $file) use ($regex): bool { |
|
| 150 | 150 | return \preg_match($regex, \pathinfo($file, \PATHINFO_FILENAME)) !== 0; |
| 151 | 151 | }); |
| 152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $regex = $this->regex($regex, true); |
| 161 | 161 | |
| 162 | - return $this->where(function (string $fqn) use ($regex): bool { |
|
| 162 | + return $this->where(function(string $fqn) use ($regex): bool { |
|
| 163 | 163 | $class = \basename(\str_replace('\\', '/', $fqn)); |
| 164 | 164 | |
| 165 | 165 | return \preg_match($regex, $class) !== 0; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | $regex = $this->regex($regex); |
| 176 | 176 | |
| 177 | - return $this->where(function (string $fqn) use ($regex): bool { |
|
| 177 | + return $this->where(function(string $fqn) use ($regex): bool { |
|
| 178 | 178 | return \preg_match($regex, $fqn) !== 0; |
| 179 | 179 | }); |
| 180 | 180 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | private function regex(string $regex, bool $strict = false): string |
| 188 | 188 | { |
| 189 | - $regex = $strict ? '^' . $regex . '$' : $regex; |
|
| 189 | + $regex = $strict ? '^'.$regex.'$' : $regex; |
|
| 190 | 190 | |
| 191 | 191 | return \sprintf('#%s#isuS', \str_replace('#', '\\#', $regex)); |
| 192 | 192 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | public function match(string $class, string $path): bool |
| 23 | 23 | { |
| 24 | 24 | foreach ($this->filters as $filter) { |
| 25 | - if (! $filter($class, $path)) { |
|
| 25 | + if (!$filter($class, $path)) { |
|
| 26 | 26 | return false; |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @var string |
| 29 | 29 | */ |
| 30 | 30 | private const STREAM_DUPLICATION_EXCEPTION = |
| 31 | - 'Could not create stream "%s", because stream ' . |
|
| 31 | + 'Could not create stream "%s", because stream '. |
|
| 32 | 32 | 'with same name already has been registered.'; |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | \assert($complexity > 0, 'Name complexity should be greater than 0'); |
| 81 | 81 | |
| 82 | - $name = 'stream' . \bin2hex(\random_bytes(\random_int(1, $complexity))); |
|
| 82 | + $name = 'stream'.\bin2hex(\random_bytes(\random_int(1, $complexity))); |
|
| 83 | 83 | |
| 84 | 84 | return static::create($name, $wrapper); |
| 85 | 85 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public static function get(string $protocol): StreamInterface |
| 149 | 149 | { |
| 150 | - if (! isset(static::$streams[$protocol])) { |
|
| 150 | + if (!isset(static::$streams[$protocol])) { |
|
| 151 | 151 | $error = \sprintf('Protocol "%s://" should be registered', $protocol); |
| 152 | 152 | throw new StreamCreatingException($error); |
| 153 | 153 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | private function assertIsFile(string $pathname): void |
| 249 | 249 | { |
| 250 | - if (! \is_file($pathname)) { |
|
| 250 | + if (!\is_file($pathname)) { |
|
| 251 | 251 | $error = \sprintf('File %s not found', $pathname); |
| 252 | 252 | throw new NotFoundException($error); |
| 253 | 253 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | private function assertIsReadable(string $pathname): void |
| 262 | 262 | { |
| 263 | - if (! \is_readable($pathname)) { |
|
| 263 | + if (!\is_readable($pathname)) { |
|
| 264 | 264 | $error = \sprintf('File %s not readable', $pathname); |
| 265 | 265 | throw new NotReadableException($error); |
| 266 | 266 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | use Serafim\Stream\Stream; |
| 11 | 11 | use Serafim\Stream\StreamInterface; |
| 12 | 12 | |
| 13 | -if (! \function_exists('\\restream')) { |
|
| 13 | +if (!\function_exists('\\restream')) { |
|
| 14 | 14 | /** |
| 15 | 15 | * @param string $protocol |
| 16 | 16 | * @param Closure $then |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $this->stream = Stream::get($this->protocol); |
| 54 | 54 | |
| 55 | - if (\STREAM_USE_PATH & $options && ! \is_file($this->pathname)) { |
|
| 55 | + if (\STREAM_USE_PATH & $options && !\is_file($this->pathname)) { |
|
| 56 | 56 | $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS); |
| 57 | 57 | |
| 58 | - $this->pathname = \dirname($trace[1]['file']) . '/' . $this->pathname; |
|
| 58 | + $this->pathname = \dirname($trace[1]['file']).'/'.$this->pathname; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $this->resource = \fopen('php://memory', 'rb+'); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function stream_read(int $length): string |
| 90 | 90 | { |
| 91 | - return ! \feof($this->resource) ? \fread($this->resource, $length) : ''; |
|
| 91 | + return !\feof($this->resource) ? \fread($this->resource, $length) : ''; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function stream_tell(): int |
| 129 | 129 | { |
| 130 | - return (int)\ftell($this->resource); |
|
| 130 | + return (int) \ftell($this->resource); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if (! \is_string($file = $this->composer->findFile($class))) { |
|
| 104 | + if (!\is_string($file = $this->composer->findFile($class))) { |
|
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |