@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | array $arguments, |
| 70 | 70 | string $source, |
| 71 | 71 | int $level |
| 72 | - ) { |
|
| 72 | + ){ |
|
| 73 | 73 | $this->filename = $filename; |
| 74 | 74 | $this->line = $line; |
| 75 | 75 | $this->class = $class; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function getArgument(int $index): ReflectionArgument |
| 181 | 181 | { |
| 182 | - if (!isset($this->arguments[$index])) { |
|
| 182 | + if (!isset($this->arguments[$index])){ |
|
| 183 | 183 | throw new ReflectionException("No such argument with index '{$index}'"); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -179,7 +179,8 @@ |
||
| 179 | 179 | */ |
| 180 | 180 | public function getArgument(int $index): ReflectionArgument |
| 181 | 181 | { |
| 182 | - if (!isset($this->arguments[$index])) { |
|
| 182 | + if (!isset($this->arguments[$index])) |
|
| 183 | + { |
|
| 183 | 184 | throw new ReflectionException("No such argument with index '{$index}'"); |
| 184 | 185 | } |
| 185 | 186 | |
@@ -69,7 +69,8 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function stringValue(): string |
| 71 | 71 | { |
| 72 | - if ($this->type != self::STRING) { |
|
| 72 | + if ($this->type != self::STRING) |
|
| 73 | + { |
|
| 73 | 74 | throw new ReflectionException( |
| 74 | 75 | "Unable to represent value as string, value type is '{$this->type}'" |
| 75 | 76 | ); |
@@ -91,12 +92,15 @@ discard block |
||
| 91 | 92 | $level = 0; |
| 92 | 93 | |
| 93 | 94 | $result = []; |
| 94 | - foreach ($tokens as $token) { |
|
| 95 | - if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) { |
|
| 95 | + foreach ($tokens as $token) |
|
| 96 | + { |
|
| 97 | + if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) |
|
| 98 | + { |
|
| 96 | 99 | continue; |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | - if (empty($definition)) { |
|
| 102 | + if (empty($definition)) |
|
| 103 | + { |
|
| 100 | 104 | $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []]; |
| 101 | 105 | } |
| 102 | 106 | |
@@ -118,12 +122,14 @@ discard block |
||
| 118 | 122 | continue; |
| 119 | 123 | } |
| 120 | 124 | |
| 121 | - if ($level) { |
|
| 125 | + if ($level) |
|
| 126 | + { |
|
| 122 | 127 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 123 | 128 | continue; |
| 124 | 129 | } |
| 125 | 130 | |
| 126 | - if ($token[ReflectionFile::TOKEN_TYPE] == ',') { |
|
| 131 | + if ($token[ReflectionFile::TOKEN_TYPE] == ',') |
|
| 132 | + { |
|
| 127 | 133 | $result[] = self::createArgument($definition); |
| 128 | 134 | $definition = null; |
| 129 | 135 | continue; |
@@ -134,9 +140,11 @@ discard block |
||
| 134 | 140 | } |
| 135 | 141 | |
| 136 | 142 | //Last argument |
| 137 | - if (is_array($definition)) { |
|
| 143 | + if (is_array($definition)) |
|
| 144 | + { |
|
| 138 | 145 | $definition = self::createArgument($definition); |
| 139 | - if (!empty($definition->getType())) { |
|
| 146 | + if (!empty($definition->getType())) |
|
| 147 | + { |
|
| 140 | 148 | $result[] = $definition; |
| 141 | 149 | } |
| 142 | 150 | } |
@@ -155,9 +163,11 @@ discard block |
||
| 155 | 163 | { |
| 156 | 164 | $result = new static(self::EXPRESSION, $definition['value']); |
| 157 | 165 | |
| 158 | - if (count($definition['tokens']) == 1) { |
|
| 166 | + if (count($definition['tokens']) == 1) |
|
| 167 | + { |
|
| 159 | 168 | //If argument represent by one token we can try to resolve it's type more precisely |
| 160 | - switch ($definition['tokens'][0][0]) { |
|
| 169 | + switch ($definition['tokens'][0][0]) |
|
| 170 | + { |
|
| 161 | 171 | case T_VARIABLE: |
| 162 | 172 | $result->type = self::VARIABLE; |
| 163 | 173 | break; |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Argument types. |
| 23 | 23 | */ |
| 24 | - public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
| 25 | - public const VARIABLE = 'variable'; //PHP variable |
|
| 24 | + public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
| 25 | + public const VARIABLE = 'variable'; //PHP variable |
|
| 26 | 26 | public const EXPRESSION = 'expression'; //PHP code (expression). |
| 27 | 27 | public const STRING = 'string'; |
| 28 | 28 | private string $type; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function stringValue(): string |
| 61 | 61 | { |
| 62 | - if ($this->type != self::STRING) { |
|
| 62 | + if ($this->type != self::STRING){ |
|
| 63 | 63 | throw new ReflectionException( |
| 64 | 64 | "Unable to represent value as string, value type is '{$this->type}'" |
| 65 | 65 | ); |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | $level = 0; |
| 81 | 81 | |
| 82 | 82 | $result = []; |
| 83 | - foreach ($tokens as $token) { |
|
| 84 | - if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) { |
|
| 83 | + foreach ($tokens as $token){ |
|
| 84 | + if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE){ |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if (empty($definition)) { |
|
| 88 | + if (empty($definition)){ |
|
| 89 | 89 | $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []]; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if ( |
| 93 | 93 | $token[ReflectionFile::TOKEN_TYPE] == '(' |
| 94 | 94 | || $token[ReflectionFile::TOKEN_TYPE] == '[' |
| 95 | - ) { |
|
| 95 | + ){ |
|
| 96 | 96 | ++$level; |
| 97 | 97 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 98 | 98 | continue; |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | if ( |
| 102 | 102 | $token[ReflectionFile::TOKEN_TYPE] == ')' |
| 103 | 103 | || $token[ReflectionFile::TOKEN_TYPE] == ']' |
| 104 | - ) { |
|
| 104 | + ){ |
|
| 105 | 105 | --$level; |
| 106 | 106 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 107 | 107 | continue; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ($level) { |
|
| 110 | + if ($level){ |
|
| 111 | 111 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 112 | 112 | continue; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ($token[ReflectionFile::TOKEN_TYPE] == ',') { |
|
| 115 | + if ($token[ReflectionFile::TOKEN_TYPE] == ','){ |
|
| 116 | 116 | $result[] = self::createArgument($definition); |
| 117 | 117 | $definition = null; |
| 118 | 118 | continue; |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | //Last argument |
| 126 | - if (is_array($definition)) { |
|
| 126 | + if (is_array($definition)){ |
|
| 127 | 127 | $definition = self::createArgument($definition); |
| 128 | - if (!empty($definition->getType())) { |
|
| 128 | + if (!empty($definition->getType())){ |
|
| 129 | 129 | $result[] = $definition; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $result = new static(self::EXPRESSION, $definition['value']); |
| 144 | 144 | |
| 145 | - if (count($definition['tokens']) == 1) { |
|
| 145 | + if (count($definition['tokens']) == 1){ |
|
| 146 | 146 | //If argument represent by one token we can try to resolve it's type more precisely |
| 147 | - switch ($definition['tokens'][0][0]) { |
|
| 147 | + switch ($definition['tokens'][0][0]){ |
|
| 148 | 148 | case T_VARIABLE: |
| 149 | 149 | $result->type = self::VARIABLE; |
| 150 | 150 | break; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | protected function someFunction() |
| 20 | 20 | { |
| 21 | 21 | $result = $this->sampleMethod('hello world'); |
| 22 | - print_r(self::sampleMethod($result . 'plus')); |
|
| 22 | + print_r(self::sampleMethod($result.'plus')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function testInstance() |
@@ -22,17 +22,17 @@ |
||
| 22 | 22 | $this->assertContains(TestTrait::class, $reflection->getTraits()); |
| 23 | 23 | $this->assertContains(TestInterface::class, $reflection->getInterfaces()); |
| 24 | 24 | |
| 25 | - $this->assertSame([__NAMESPACE__ . '\hello'], $reflection->getFunctions()); |
|
| 25 | + $this->assertSame([__NAMESPACE__.'\hello'], $reflection->getFunctions()); |
|
| 26 | 26 | |
| 27 | 27 | $functionA = null; |
| 28 | 28 | $functionB = null; |
| 29 | 29 | |
| 30 | - foreach ($reflection->getInvocations() as $invocation) { |
|
| 31 | - if ($invocation->getName() == 'test_function_a') { |
|
| 30 | + foreach ($reflection->getInvocations() as $invocation){ |
|
| 31 | + if ($invocation->getName() == 'test_function_a'){ |
|
| 32 | 32 | $functionA = $invocation; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($invocation->getName() == 'test_function_b') { |
|
| 35 | + if ($invocation->getName() == 'test_function_b'){ |
|
| 36 | 36 | $functionB = $invocation; |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -27,12 +27,15 @@ |
||
| 27 | 27 | $functionA = null; |
| 28 | 28 | $functionB = null; |
| 29 | 29 | |
| 30 | - foreach ($reflection->getInvocations() as $invocation) { |
|
| 31 | - if ($invocation->getName() == 'test_function_a') { |
|
| 30 | + foreach ($reflection->getInvocations() as $invocation) |
|
| 31 | + { |
|
| 32 | + if ($invocation->getName() == 'test_function_a') |
|
| 33 | + { |
|
| 32 | 34 | $functionA = $invocation; |
| 33 | 35 | } |
| 34 | 36 | |
| 35 | - if ($invocation->getName() == 'test_function_b') { |
|
| 37 | + if ($invocation->getName() == 'test_function_b') |
|
| 38 | + { |
|
| 36 | 39 | $functionB = $invocation; |
| 37 | 40 | } |
| 38 | 41 | } |
@@ -37,10 +37,10 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function matches(string $string, string $pattern): bool |
| 39 | 39 | { |
| 40 | - if ($string === $pattern) { |
|
| 40 | + if ($string === $pattern){ |
|
| 41 | 41 | return true; |
| 42 | 42 | } |
| 43 | - if (!$this->isPattern($pattern)) { |
|
| 43 | + if (!$this->isPattern($pattern)){ |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -37,10 +37,12 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function matches(string $string, string $pattern): bool |
| 39 | 39 | { |
| 40 | - if ($string === $pattern) { |
|
| 40 | + if ($string === $pattern) |
|
| 41 | + { |
|
| 41 | 42 | return true; |
| 42 | 43 | } |
| 43 | - if (!$this->isPattern($pattern)) { |
|
| 44 | + if (!$this->isPattern($pattern)) |
|
| 45 | + { |
|
| 44 | 46 | return false; |
| 45 | 47 | } |
| 46 | 48 | |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | protected function say(string $string, array $options = [], $bundle = null): string |
| 43 | 43 | { |
| 44 | - if (Translator::isMessage($string)) { |
|
| 44 | + if (Translator::isMessage($string)){ |
|
| 45 | 45 | //Cut [[ and ]] |
| 46 | 46 | $string = substr($string, 2, -2); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $container = ContainerScope::getContainer(); |
| 50 | - if (empty($container) || !$container->has(TranslatorInterface::class)) { |
|
| 50 | + if (empty($container) || !$container->has(TranslatorInterface::class)){ |
|
| 51 | 51 | return Translator::interpolate($string, $options); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | $translator = $container->get(TranslatorInterface::class); |
| 58 | 58 | |
| 59 | - if (is_null($bundle)) { |
|
| 59 | + if (is_null($bundle)){ |
|
| 60 | 60 | $bundle = $translator->getDomain(static::class); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -41,13 +41,15 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | protected function say(string $string, array $options = [], $bundle = null): string |
| 43 | 43 | { |
| 44 | - if (Translator::isMessage($string)) { |
|
| 44 | + if (Translator::isMessage($string)) |
|
| 45 | + { |
|
| 45 | 46 | //Cut [[ and ]] |
| 46 | 47 | $string = substr($string, 2, -2); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | $container = ContainerScope::getContainer(); |
| 50 | - if (empty($container) || !$container->has(TranslatorInterface::class)) { |
|
| 51 | + if (empty($container) || !$container->has(TranslatorInterface::class)) |
|
| 52 | + { |
|
| 51 | 53 | return Translator::interpolate($string, $options); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -56,7 +58,8 @@ discard block |
||
| 56 | 58 | */ |
| 57 | 59 | $translator = $container->get(TranslatorInterface::class); |
| 58 | 60 | |
| 59 | - if (is_null($bundle)) { |
|
| 61 | + if (is_null($bundle)) |
|
| 62 | + { |
|
| 60 | 63 | $bundle = $translator->getDomain(static::class); |
| 61 | 64 | } |
| 62 | 65 | |
@@ -107,9 +107,12 @@ |
||
| 107 | 107 | { |
| 108 | 108 | $bundle = strtolower(str_replace(['/', '\\'], '-', $bundle)); |
| 109 | 109 | |
| 110 | - foreach ($this->config['domains'] as $domain => $patterns) { |
|
| 111 | - foreach ($patterns as $pattern) { |
|
| 112 | - if ($this->matcher->matches($bundle, $pattern)) { |
|
| 110 | + foreach ($this->config['domains'] as $domain => $patterns) |
|
| 111 | + { |
|
| 112 | + foreach ($patterns as $pattern) |
|
| 113 | + { |
|
| 114 | + if ($this->matcher->matches($bundle, $pattern)) |
|
| 115 | + { |
|
| 113 | 116 | return $domain; |
| 114 | 117 | } |
| 115 | 118 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | public function getLocaleDirectory(string $locale): string |
| 78 | 78 | { |
| 79 | - return $this->getLocalesDirectory() . $locale . '/'; |
|
| 79 | + return $this->getLocalesDirectory().$locale.'/'; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $bundle = strtolower(str_replace(['/', '\\'], '-', $bundle)); |
| 88 | 88 | |
| 89 | - foreach ($this->config['domains'] as $domain => $patterns) { |
|
| 90 | - foreach ($patterns as $pattern) { |
|
| 91 | - if ($this->matcher->matches($bundle, $pattern)) { |
|
| 89 | + foreach ($this->config['domains'] as $domain => $patterns){ |
|
| 90 | + foreach ($patterns as $pattern){ |
|
| 91 | + if ($this->matcher->matches($bundle, $pattern)){ |
|
| 92 | 92 | return $domain; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function loadCatalogue(string $locale): CatalogueInterface |
| 52 | 52 | { |
| 53 | - if (!$this->hasLocale($locale)) { |
|
| 53 | + if (!$this->hasLocale($locale)){ |
|
| 54 | 54 | throw new LocaleException($locale); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -50,7 +50,8 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function loadCatalogue(string $locale): CatalogueInterface |
| 52 | 52 | { |
| 53 | - if (!$this->hasLocale($locale)) { |
|
| 53 | + if (!$this->hasLocale($locale)) |
|
| 54 | + { |
|
| 54 | 55 | throw new LocaleException($locale); |
| 55 | 56 | } |
| 56 | 57 | |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function getLocales(): array |
| 52 | 52 | { |
| 53 | - if ($this->locales !== []) { |
|
| 53 | + if ($this->locales !== []){ |
|
| 54 | 54 | return $this->locales; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $this->locales = (array)$this->cache->getLocales(); |
| 58 | - if ($this->locales === []) { |
|
| 58 | + if ($this->locales === []){ |
|
| 59 | 59 | $this->locales = $this->loader->getLocales(); |
| 60 | 60 | $this->cache->setLocales($this->locales); |
| 61 | 61 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function load(string $locale): CatalogueInterface |
| 70 | 70 | { |
| 71 | - if (isset($this->catalogues[$locale])) { |
|
| 71 | + if (isset($this->catalogues[$locale])){ |
|
| 72 | 72 | return $this->catalogues[$locale]; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $data = (array)$this->cache->loadLocale($locale); |
| 76 | - if (!empty($data)) { |
|
| 76 | + if (!empty($data)){ |
|
| 77 | 77 | $this->catalogues[$locale] = new Catalogue($locale, $data); |
| 78 | - } else { |
|
| 78 | + }else{ |
|
| 79 | 79 | $this->catalogues[$locale] = $this->loader->loadCatalogue($locale); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | public function reset(): void |
| 113 | 113 | { |
| 114 | 114 | $this->cache->setLocales(null); |
| 115 | - foreach ($this->getLocales() as $locale) { |
|
| 115 | + foreach ($this->getLocales() as $locale){ |
|
| 116 | 116 | $this->cache->saveLocale($locale, null); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -50,12 +50,14 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function getLocales(): array |
| 52 | 52 | { |
| 53 | - if ($this->locales !== []) { |
|
| 53 | + if ($this->locales !== []) |
|
| 54 | + { |
|
| 54 | 55 | return $this->locales; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | $this->locales = (array)$this->cache->getLocales(); |
| 58 | - if ($this->locales === []) { |
|
| 59 | + if ($this->locales === []) |
|
| 60 | + { |
|
| 59 | 61 | $this->locales = $this->loader->getLocales(); |
| 60 | 62 | $this->cache->setLocales($this->locales); |
| 61 | 63 | } |
@@ -68,14 +70,18 @@ discard block |
||
| 68 | 70 | */ |
| 69 | 71 | public function load(string $locale): CatalogueInterface |
| 70 | 72 | { |
| 71 | - if (isset($this->catalogues[$locale])) { |
|
| 73 | + if (isset($this->catalogues[$locale])) |
|
| 74 | + { |
|
| 72 | 75 | return $this->catalogues[$locale]; |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | $data = (array)$this->cache->loadLocale($locale); |
| 76 | - if (!empty($data)) { |
|
| 79 | + if (!empty($data)) |
|
| 80 | + { |
|
| 77 | 81 | $this->catalogues[$locale] = new Catalogue($locale, $data); |
| 78 | - } else { |
|
| 82 | + } |
|
| 83 | + else |
|
| 84 | + { |
|
| 79 | 85 | $this->catalogues[$locale] = $this->loader->loadCatalogue($locale); |
| 80 | 86 | } |
| 81 | 87 | |
@@ -112,7 +118,8 @@ discard block |
||
| 112 | 118 | public function reset(): void |
| 113 | 119 | { |
| 114 | 120 | $this->cache->setLocales(null); |
| 115 | - foreach ($this->getLocales() as $locale) { |
|
| 121 | + foreach ($this->getLocales() as $locale) |
|
| 122 | + { |
|
| 116 | 123 | $this->cache->saveLocale($locale, null); |
| 117 | 124 | } |
| 118 | 125 | |