@@ -21,8 +21,8 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public static function filter(array $tokens, ?callable $callback = null): array |
| 23 | 23 | { |
| 24 | - if (! $callback) { |
|
| 25 | - $callback = static function (AbstractToken $token): bool { |
|
| 24 | + if (!$callback) { |
|
| 25 | + $callback = static function(AbstractToken $token): bool { |
|
| 26 | 26 | return $token instanceof static; |
| 27 | 27 | }; |
| 28 | 28 | } |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | { |
| 94 | 94 | return \current( |
| 95 | 95 | $this->skins->filter( |
| 96 | - static function (Emoji $emoji) use ($tone) { |
|
| 96 | + static function(Emoji $emoji) use ($tone) { |
|
| 97 | 97 | return \in_array($tone, (array) $emoji->tone, true); |
| 98 | 98 | } |
| 99 | 99 | )->getArrayCopy() |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct(string $filename, ?string $message = null, ?Throwable $previous = null) |
| 12 | 12 | { |
| 13 | - if (! isset($message)) { |
|
| 13 | + if (!isset($message)) { |
|
| 14 | 14 | $message = \sprintf('Empty or corrupted archive: %s.', $filename); |
| 15 | 15 | } |
| 16 | 16 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function offsetExists($index) // phpcs:ignore |
| 49 | 49 | { |
| 50 | - if (! \array_key_exists($index, $this->getArrayCopy())) { |
|
| 50 | + if (!\array_key_exists($index, $this->getArrayCopy())) { |
|
| 51 | 51 | throw new \OutOfRangeException(\sprintf('Unknown property: %s', $index)); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $method = 'get' . \ucfirst(\substr($key, 0, 3) === 'get' ? \substr($key, 3) : $key); |
| 69 | - if (! \method_exists($this, $method)) { |
|
| 69 | + if (!\method_exists($this, $method)) { |
|
| 70 | 70 | throw new \OutOfRangeException(\sprintf('Unknown property: %s', $key)); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | { |
| 57 | 57 | $tokens = []; |
| 58 | 58 | while (true) { |
| 59 | - if (! $this->lexer->lookahead) { |
|
| 59 | + if (!$this->lexer->lookahead) { |
|
| 60 | 60 | break; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return string[] |
| 77 | 77 | */ |
| 78 | - static function (Options $options, $value): array { |
|
| 79 | - if (! $value) { |
|
| 78 | + static function(Options $options, $value): array { |
|
| 79 | + if (!$value) { |
|
| 80 | 80 | return $value; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $resolver->define('locale') |
| 91 | 91 | ->allowedTypes('string') |
| 92 | - ->allowedValues(static function (string $value): bool { |
|
| 93 | - return ! ! Normalize::locale($value); |
|
| 92 | + ->allowedValues(static function(string $value): bool { |
|
| 93 | + return !!Normalize::locale($value); |
|
| 94 | 94 | }) |
| 95 | 95 | ->default('en') |
| 96 | - ->normalize(static function (Options $options, string $value): string { |
|
| 96 | + ->normalize(static function(Options $options, string $value): string { |
|
| 97 | 97 | return Normalize::locale($value); |
| 98 | 98 | }); |
| 99 | 99 | } |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $resolver->define('native') |
| 104 | 104 | ->allowedTypes('bool') |
| 105 | - ->default(static function (Options $options): bool { |
|
| 105 | + ->default(static function(Options $options): bool { |
|
| 106 | 106 | return \in_array($options['locale'], DatasetInterface::NON_LATIN_LOCALES, true); |
| 107 | 107 | }) |
| 108 | - ->normalize(static function (Options $options, bool $value) { |
|
| 108 | + ->normalize(static function(Options $options, bool $value) { |
|
| 109 | 109 | return $value && \in_array($options['locale'], DatasetInterface::NON_LATIN_LOCALES, true); |
| 110 | 110 | }); |
| 111 | 111 | } |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * @param mixed $value |
| 128 | 128 | */ |
| 129 | - static function ($value): bool { |
|
| 129 | + static function($value): bool { |
|
| 130 | 130 | foreach ((array) $value as $v) { |
| 131 | - if (! \in_array($v, ShortcodeInterface::SUPPORTED_PRESETS, true)) { |
|
| 131 | + if (!\in_array($v, ShortcodeInterface::SUPPORTED_PRESETS, true)) { |
|
| 132 | 132 | throw new InvalidOptionsException(\sprintf( |
| 133 | 133 | 'The option "preset" with value "%s" is invalid. Accepted values are: %s.', |
| 134 | 134 | $v, |
| 135 | - \implode(', ', \array_map(static function ($s) { |
|
| 135 | + \implode(', ', \array_map(static function($s) { |
|
| 136 | 136 | return \sprintf('"%s"', $s); |
| 137 | 137 | }, ShortcodeInterface::SUPPORTED_PRESETS)) |
| 138 | 138 | )); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return string[] |
| 151 | 151 | */ |
| 152 | - static function (Options $options, $value): array { |
|
| 152 | + static function(Options $options, $value): array { |
|
| 153 | 153 | // Presets. |
| 154 | 154 | $presets = []; |
| 155 | 155 | foreach ((array) $value as $preset) { |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public static function unarchive(string $filename): self |
| 29 | 29 | { |
| 30 | - if (! \file_exists($filename)) { |
|
| 30 | + if (!\file_exists($filename)) { |
|
| 31 | 31 | throw new FileNotFoundException($filename); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if ( |
| 35 | - ! ($contents = \file_get_contents($filename)) || |
|
| 36 | - ! ($decoded = \gzdecode($contents)) |
|
| 35 | + !($contents = \file_get_contents($filename)) || |
|
| 36 | + !($decoded = \gzdecode($contents)) |
|
| 37 | 37 | ) { |
| 38 | 38 | throw new UnarchiveException($filename); |
| 39 | 39 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | throw new MalformedArchiveException($filename, $throwable); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (! $dataset instanceof Dataset) { |
|
| 47 | + if (!$dataset instanceof Dataset) { |
|
| 48 | 48 | throw new MalformedArchiveException($filename); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function indexBy(string $index = 'hexcode'): Dataset |
| 76 | 76 | { |
| 77 | - if (! isset($this->indices[$index])) { |
|
| 77 | + if (!isset($this->indices[$index])) { |
|
| 78 | 78 | $this->indices[$index] = new self($this, $index); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $emoji = new Emoji($emoji); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (! $emoji instanceof Emoji) { |
|
| 61 | + if (!$emoji instanceof Emoji) { |
|
| 62 | 62 | throw new \RuntimeException(\sprintf('Passed array item must be an instance of %s.', Emoji::class)); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | ]; |
| 131 | 131 | |
| 132 | 132 | // Immediately return if not a valid type. |
| 133 | - if (! isset($methods[$type])) { |
|
| 133 | + if (!isset($methods[$type])) { |
|
| 134 | 134 | $value = null; |
| 135 | 135 | |
| 136 | 136 | return false; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $normalized = \array_values(\array_unique(\array_merge( |
| 155 | 155 | $normalized, |
| 156 | 156 | \array_map( |
| 157 | - static function ($shortcode) { |
|
| 157 | + static function($shortcode) { |
|
| 158 | 158 | return \preg_replace('/[^a-z0-9-]/', '-', \strtolower(\trim($shortcode, ':(){}[]'))); |
| 159 | 159 | }, |
| 160 | 160 | (array) $shortcodes |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | \preg_match(self::REGEX, $type, $matches, PREG_UNMATCHED_AS_NULL); |
| 37 | 37 | $this->callback = $matches['callback'] ?? null; |
| 38 | 38 | $this->customType = $matches['customType'] ?? null; |
| 39 | - $this->emptyNullable = ! ! ($matches['emptyNullable'] ?? false); |
|
| 40 | - $this->iterable = ! ! ($matches['iterable'] ?? false); |
|
| 41 | - $this->nullable = ! ! ($this->emptyNullable || ($matches['nullable'] ?? false)); |
|
| 39 | + $this->emptyNullable = !!($matches['emptyNullable'] ?? false); |
|
| 40 | + $this->iterable = !!($matches['iterable'] ?? false); |
|
| 41 | + $this->nullable = !!($this->emptyNullable || ($matches['nullable'] ?? false)); |
|
| 42 | 42 | $this->type = $matches['type'] ?? 'mixed'; |
| 43 | 43 | $this->isPhpType = \in_array($this->type, self::TYPES, true); |
| 44 | 44 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function castValue($value) |
| 78 | 78 | { |
| 79 | 79 | // Immediately return if nullable or empty. |
| 80 | - if (($this->nullable && $value === null) || ($this->emptyNullable && ! $value)) { |
|
| 80 | + if (($this->nullable && $value === null) || ($this->emptyNullable && !$value)) { |
|
| 81 | 81 | return null; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -117,6 +117,6 @@ discard block |
||
| 117 | 117 | Normalize::setType($value, $this->type); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - return $this->emptyNullable && ! $value ? null : $value; |
|
| 120 | + return $this->emptyNullable && !$value ? null : $value; |
|
| 121 | 121 | } |
| 122 | 122 | } |