@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $normalized = \array_values(\array_unique(\array_merge( |
| 227 | 227 | $normalized, |
| 228 | 228 | \array_map( |
| 229 | - static function ($shortcode) { |
|
| 229 | + static function($shortcode) { |
|
| 230 | 230 | return \preg_replace('/[^a-z0-9-]/', '-', \strtolower(\trim($shortcode, ':(){}[]'))); |
| 231 | 231 | }, |
| 232 | 232 | (array) $shortcodes |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | { |
| 312 | 312 | return \current( |
| 313 | 313 | $this->getSkins()->filter( |
| 314 | - static function (Emoji $emoji) use ($tone) { |
|
| 314 | + static function(Emoji $emoji) use ($tone) { |
|
| 315 | 315 | return \in_array($tone, (array) $emoji->getTone(), true); |
| 316 | 316 | } |
| 317 | 317 | )->getArrayCopy() |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | public function offsetExists($key): bool // phpcs:ignore |
| 375 | 375 | { |
| 376 | - $method = \current(\array_filter(['get' . \ucfirst($key), $key], function ($method) { |
|
| 376 | + $method = \current(\array_filter(['get' . \ucfirst($key), $key], function($method) { |
|
| 377 | 377 | return \method_exists($this, $method); |
| 378 | 378 | })); |
| 379 | 379 | |
@@ -392,12 +392,12 @@ discard block |
||
| 392 | 392 | public function offsetGet($key) // phpcs:ignore |
| 393 | 393 | { |
| 394 | 394 | // Use the dedicated "get" method for the property instead. |
| 395 | - $method = \current(\array_filter(['get' . \ucfirst($key), $key], function ($method) { |
|
| 395 | + $method = \current(\array_filter(['get' . \ucfirst($key), $key], function($method) { |
|
| 396 | 396 | return \method_exists($this, $method); |
| 397 | 397 | })); |
| 398 | 398 | |
| 399 | 399 | // Otherwise, ensure the property actually exists. |
| 400 | - if (! $method && ! \property_exists($this, $key)) { |
|
| 400 | + if (!$method && !\property_exists($this, $key)) { |
|
| 401 | 401 | throw new \RuntimeException(\sprintf('Unknown property: %s', $key)); |
| 402 | 402 | } |
| 403 | 403 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | public function offsetSet($key, $value): void // phpcs:ignore |
| 414 | 414 | { |
| 415 | 415 | // Immediately return if key or value isn't valid. |
| 416 | - if (! \property_exists($this, $key) || ! isset($value) || $value === '') { |
|
| 416 | + if (!\property_exists($this, $key) || !isset($value) || $value === '') { |
|
| 417 | 417 | return; |
| 418 | 418 | } |
| 419 | 419 | |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | { |
| 442 | 442 | $array = []; |
| 443 | 443 | foreach (\get_object_vars($this) as $key => $value) { |
| 444 | - if (! isset($value)) { |
|
| 444 | + if (!isset($value)) { |
|
| 445 | 445 | continue; |
| 446 | 446 | } |
| 447 | 447 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | const BUILD_DIRECTORY = BASE_DIRECTORY . '/build'; |
| 15 | 15 | const EMOJIBASE_DATA_DIRECTORY = BASE_DIRECTORY . '/node_modules/emojibase-data'; |
| 16 | 16 | |
| 17 | -if (! is_dir(EMOJIBASE_DATA_DIRECTORY) || ! interface_exists(EmojibaseInterface::class)) { |
|
| 17 | +if (!is_dir(EMOJIBASE_DATA_DIRECTORY) || !interface_exists(EmojibaseInterface::class)) { |
|
| 18 | 18 | throw new \RuntimeException('You must first run `npm install && npm run build` to build the datasets.'); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | $data = array_column($json, null, 'hexcode'); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if (! isset($data)) { |
|
| 34 | + if (!isset($data)) { |
|
| 35 | 35 | throw new \RuntimeException(sprintf('Unable to load JSON: %s', $file)); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Merge any skin variations into the main list (faster performance). |
| 39 | 39 | foreach ($data as $hexcode => &$item) { |
| 40 | - if (! isset($item['shortcodes'])) { |
|
| 40 | + if (!isset($item['shortcodes'])) { |
|
| 41 | 41 | $item['shortcodes'] = []; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $item['shortcodes'] = Emoji::normalizeShortcodes($item['shortcodes'], $shortcodes[$hexcode]); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (! isset($item['skins']) || ! count($item['skins'])) { |
|
| 50 | + if (!isset($item['skins']) || !count($item['skins'])) { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | foreach (EmojibaseShortcodeInterface::PRESETS as $preset) { |
| 93 | 93 | // Skip presets that don't exist. |
| 94 | 94 | $file = sprintf('%s/%s/shortcodes/%s.json', EMOJIBASE_DATA_DIRECTORY, $locale, $preset); |
| 95 | - if (! file_exists($file) || ! ($c = file_get_contents($file)) || ! ($shortcodes = json_decode($c, true))) { |
|
| 95 | + if (!file_exists($file) || !($c = file_get_contents($file)) || !($shortcodes = json_decode($c, true))) { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -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) { |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $emoji = Emoji::create($emoji); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if (! $emoji instanceof Emoji) { |
|
| 36 | + if (!$emoji instanceof Emoji) { |
|
| 37 | 37 | throw new \RuntimeException(\sprintf('Passed array item must be an instance of %s.', Emoji::class)); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | foreach ($emoji->getSkins() as $skin) { |
| 48 | 48 | $skinKeys = \array_filter((array) $skin[$index]); |
| 49 | 49 | foreach ($skinKeys as $sk) { |
| 50 | - if (! isset($dataset[$sk])) { |
|
| 50 | + if (!isset($dataset[$sk])) { |
|
| 51 | 51 | $dataset[$sk] = $skin; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public static function unarchive(string $filename): self |
| 62 | 62 | { |
| 63 | - if (! \file_exists($filename)) { |
|
| 63 | + if (!\file_exists($filename)) { |
|
| 64 | 64 | throw new FileNotFoundException($filename); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ( |
| 68 | - ! ($contents = \file_get_contents($filename)) || |
|
| 69 | - ! ($decoded = \gzdecode($contents)) || |
|
| 70 | - ! ($dataset = \unserialize($decoded)) |
|
| 68 | + !($contents = \file_get_contents($filename)) || |
|
| 69 | + !($decoded = \gzdecode($contents)) || |
|
| 70 | + !($dataset = \unserialize($decoded)) |
|
| 71 | 71 | ) { |
| 72 | 72 | throw new UnarchiveException($filename); |
| 73 | 73 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function indexBy(string $index = 'hexcode'): Dataset |
| 98 | 98 | { |
| 99 | - if (! isset($this->indices[$index])) { |
|
| 99 | + if (!isset($this->indices[$index])) { |
|
| 100 | 100 | $this->indices[$index] = new self($this, $index); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -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 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | public function __get(string $key) |
| 13 | 13 | { |
| 14 | 14 | $method = 'get' . \ucfirst(\substr($key, 0, 3) === 'get' ? \substr($key, 3) : $key); |
| 15 | - if (! \method_exists($this, $method)) { |
|
| 15 | + if (!\method_exists($this, $method)) { |
|
| 16 | 16 | $method = null; |
| 17 | 17 | } |
| 18 | 18 | |