@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return string[] |
| 89 | 89 | */ |
| 90 | - static function (Options $options, $value): array { |
|
| 91 | - if (! $value) { |
|
| 90 | + static function(Options $options, $value): array { |
|
| 91 | + if (!$value) { |
|
| 92 | 92 | return $value; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -98,20 +98,20 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $resolver->define('locale') |
| 100 | 100 | ->allowedTypes('string') |
| 101 | - ->allowedValues(static function (string $value): bool { |
|
| 102 | - return ! ! static::normalizeLocale($value); |
|
| 101 | + ->allowedValues(static function(string $value): bool { |
|
| 102 | + return !!static::normalizeLocale($value); |
|
| 103 | 103 | }) |
| 104 | 104 | ->default('en') |
| 105 | - ->normalize(static function (Options $options, string $value): string { |
|
| 105 | + ->normalize(static function(Options $options, string $value): string { |
|
| 106 | 106 | return static::normalizeLocale($value); |
| 107 | 107 | }); |
| 108 | 108 | |
| 109 | 109 | $resolver->define('native') |
| 110 | 110 | ->allowedTypes('bool') |
| 111 | - ->default(static function (Options $options): bool { |
|
| 111 | + ->default(static function(Options $options): bool { |
|
| 112 | 112 | return \in_array($options['locale'], EmojibaseInterface::NON_LATIN_LOCALES, true); |
| 113 | 113 | }) |
| 114 | - ->normalize(static function (Options $options, bool $value) { |
|
| 114 | + ->normalize(static function(Options $options, bool $value) { |
|
| 115 | 115 | return $value && \in_array($options['locale'], EmojibaseInterface::NON_LATIN_LOCALES, true); |
| 116 | 116 | }); |
| 117 | 117 | |
@@ -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, EmojibaseShortcodeInterface::SUPPORTED_PRESETS, true)) { |
|
| 131 | + if (!\in_array($v, EmojibaseShortcodeInterface::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 | }, EmojibaseShortcodeInterface::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) { |
@@ -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 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $texts = $this->dataset->indexBy('text'); |
| 49 | 49 | |
| 50 | 50 | while (true) { |
| 51 | - if (! $this->lookahead) { |
|
| 51 | + if (!$this->lookahead) { |
|
| 52 | 52 | break; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -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() |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $emoji = new Emoji($emoji); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if (! $emoji instanceof Emoji) { |
|
| 37 | + if (!$emoji instanceof Emoji) { |
|
| 38 | 38 | throw new \RuntimeException(\sprintf('Passed array item must be an instance of %s.', Emoji::class)); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | foreach ($emoji->skins as &$skin) { |
| 49 | 49 | $skinKeys = \array_filter((array) $skin->$index); |
| 50 | 50 | foreach ($skinKeys as $sk) { |
| 51 | - if (! isset($dataset[$sk])) { |
|
| 51 | + if (!isset($dataset[$sk])) { |
|
| 52 | 52 | $dataset[$sk] = &$skin; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public static function unarchive(string $filename): self |
| 63 | 63 | { |
| 64 | - if (! \file_exists($filename)) { |
|
| 64 | + if (!\file_exists($filename)) { |
|
| 65 | 65 | throw new FileNotFoundException($filename); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if ( |
| 69 | - ! ($contents = \file_get_contents($filename)) || |
|
| 70 | - ! ($decoded = \gzdecode($contents)) |
|
| 69 | + !($contents = \file_get_contents($filename)) || |
|
| 70 | + !($decoded = \gzdecode($contents)) |
|
| 71 | 71 | ) { |
| 72 | 72 | throw new UnarchiveException($filename); |
| 73 | 73 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | throw new MalformedArchiveException($filename, $throwable); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (! $dataset instanceof Dataset) { |
|
| 81 | + if (!$dataset instanceof Dataset) { |
|
| 82 | 82 | throw new MalformedArchiveException($filename); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public function indexBy(string $index = 'hexcode'): Dataset |
| 110 | 110 | { |
| 111 | - if (! isset($this->indices[$index])) { |
|
| 111 | + if (!isset($this->indices[$index])) { |
|
| 112 | 112 | $this->indices[$index] = new self($this, $index); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -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 | |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | $normalized = \array_values(\array_unique(\array_merge( |
| 41 | 41 | $normalized, |
| 42 | 42 | \array_map( |
| 43 | - static function ($shortcode) { |
|
| 43 | + static function($shortcode) { |
|
| 44 | 44 | return \preg_replace('/[^a-z0-9-]/', '-', \strtolower(\trim($shortcode, ':(){}[]'))); |
| 45 | 45 | }, |
| 46 | 46 | (array) $shortcodes |
@@ -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 | |
@@ -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 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - return $this->emptyNullable && ! $value ? null : $value; |
|
| 126 | + return $this->emptyNullable && !$value ? null : $value; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function castValue($value) |
| 135 | 135 | { |
| 136 | 136 | // Immediately return if nullable or empty. |
| 137 | - if (($this->nullable && $value === null) || ($this->emptyNullable && ! $value)) { |
|
| 137 | + if (($this->nullable && $value === null) || ($this->emptyNullable && !$value)) { |
|
| 138 | 138 | return null; |
| 139 | 139 | } |
| 140 | 140 | |