@@ -36,6 +36,9 @@ discard block |
||
| 36 | 36 | $this->config = $processor->processConfiguration($definition, $profiles); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $profileDir |
|
| 41 | + */ |
|
| 39 | 42 | private function readProfiles(YamlLoader $loader, $profileDir) { |
| 40 | 43 | $profiles = []; |
| 41 | 44 | foreach (new \DirectoryIterator($profileDir) as $file) { |
@@ -51,18 +54,27 @@ discard block |
||
| 51 | 54 | return $this->config; |
| 52 | 55 | } |
| 53 | 56 | |
| 57 | + /** |
|
| 58 | + * @param string $key |
|
| 59 | + */ |
|
| 54 | 60 | public function getIndentation($key) { |
| 55 | 61 | if (isset($this->config['indentation'][$key])) { |
| 56 | 62 | return $this->config['indentation'][$key]; |
| 57 | 63 | } |
| 58 | 64 | } |
| 59 | 65 | |
| 66 | + /** |
|
| 67 | + * @param string $key |
|
| 68 | + */ |
|
| 60 | 69 | public function getBraces($key) { |
| 61 | 70 | if (isset($this->config['braces'][$key])) { |
| 62 | 71 | return $this->config['braces'][$key]; |
| 63 | 72 | } |
| 64 | 73 | } |
| 65 | 74 | |
| 75 | + /** |
|
| 76 | + * @param string $key |
|
| 77 | + */ |
|
| 66 | 78 | public function getWhitespace($key, $context = 'default') { |
| 67 | 79 | if (isset($this->config['whitespace'][$context][$key])) { |
| 68 | 80 | $val = $this->config['whitespace'][$context][$key]; |
@@ -77,6 +89,9 @@ discard block |
||
| 77 | 89 | return false; |
| 78 | 90 | } |
| 79 | 91 | |
| 92 | + /** |
|
| 93 | + * @param string $key |
|
| 94 | + */ |
|
| 80 | 95 | public function getBlanks($key) { |
| 81 | 96 | if (isset($this->config['blanks'][$key])) { |
| 82 | 97 | return $this->config['blanks'][$key]; |
@@ -84,6 +99,9 @@ discard block |
||
| 84 | 99 | return 0; |
| 85 | 100 | } |
| 86 | 101 | |
| 102 | + /** |
|
| 103 | + * @param string $key |
|
| 104 | + */ |
|
| 87 | 105 | public function getNewline($key) { |
| 88 | 106 | if (isset($this->config['newlines'][$key])) { |
| 89 | 107 | return $this->config['newlines'][$key]; |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | namespace gossi\formatter\config; |
| 4 | 4 | |
| 5 | 5 | use Symfony\Component\Config\FileLocator; |
| 6 | -use Symfony\Component\Config\Loader\LoaderResolver; |
|
| 7 | -use Symfony\Component\Config\Loader\DelegatingLoader; |
|
| 8 | 6 | use Symfony\Component\Config\Definition\Processor; |
| 9 | 7 | |
| 10 | 8 | class Config { |
@@ -71,7 +71,8 @@ |
||
| 71 | 71 | return $this->getWhitespace($key); |
| 72 | 72 | } |
| 73 | 73 | return $val; |
| 74 | - } else if ($context !== 'default') { // workaround? |
|
| 74 | + } else if ($context !== 'default') { |
|
| 75 | +// workaround? |
|
| 75 | 76 | return $this->getWhitespace($key); |
| 76 | 77 | } |
| 77 | 78 | return false; |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace gossi\formatter\formatters; |
| 3 | 3 | |
| 4 | 4 | use gossi\formatter\token\Token; |
| 5 | -use gossi\formatter\token\Tokenizer; |
|
| 6 | 5 | use gossi\formatter\entities\Group; |
| 7 | 6 | |
| 8 | 7 | class WhitespaceFormatter extends SpecializedFormatter { |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace gossi\formatter\token; |
| 4 | 4 | |
| 5 | -use gossi\formatter\visitor\Visitor; |
|
| 6 | - |
|
| 7 | 5 | class Token { |
| 8 | 6 | |
| 9 | 7 | public $type; |
@@ -2,5 +2,9 @@ |
||
| 2 | 2 | namespace gossi\formatter\token; |
| 3 | 3 | |
| 4 | 4 | interface TokenVisitorInterface { |
| 5 | + |
|
| 6 | + /** |
|
| 7 | + * @return void |
|
| 8 | + */ |
|
| 5 | 9 | public function visitToken(Token $token); |
| 6 | 10 | } |
| 7 | 11 | \ No newline at end of file |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function write($content) { |
| 59 | 59 | $lines = explode("\n", $content); |
| 60 | - for ($i = 0, $c = count($lines); $i < $c; $i ++) { |
|
| 60 | + for ($i = 0, $c = count($lines); $i < $c; $i++) { |
|
| 61 | 61 | if ($this->indentationLevel > 0 |
| 62 | 62 | && !empty($lines[$i]) |
| 63 | 63 | && (empty($this->content) || "\n" === substr($this->content, -1))) { |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Keyswords that are followed by a single space |
| 19 | - */ |
|
| 19 | + */ |
|
| 20 | 20 | public static $KEYWORDS = [T_ABSTRACT, T_CASE, T_CLASS, T_FUNCTION, T_CLONE, T_CONST, T_EXTENDS, T_FINAL, T_GLOBAL, T_IMPLEMENTS, T_INTERFACE, T_NAMESPACE, T_NEW, T_PRIVATE, T_PUBLIC, T_PROTECTED, T_THROW, T_TRAIT, T_USE]; |
| 21 | 21 | public static $BLOCKS = [T_IF, T_ELSEIF, T_ELSE, T_FOR, T_FOREACH, T_WHILE, T_DO, T_SWITCH, T_TRY, T_CATCH]; |
| 22 | 22 | public static $CASTS = [T_ARRAY_CAST, T_BOOL_CAST, T_DOUBLE_CAST, T_INT_CAST, T_OBJECT_CAST, T_STRING_CAST, T_UNSET_CAST]; |