Completed
Push — master ( a6cc58...1b8eb5 )
by Martijn
26s
created
SwaggerGen/Swagger/Type/Custom/Ipv6Type.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
17 17
 class Ipv6Type extends StringType implements ICustomType
18 18
 {
19 19
 
20
-    const PATTERN = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))';
21
-
22
-    /**
23
-     * List of formats recognized by this class
24
-     * @var string[]
25
-     */
26
-    private static $formats = array('ipv6');
27
-
28
-    /**
29
-     * Construct and set up the regular expression for this type
30
-     *
31
-     * @param AbstractObject $parent
32
-     * @param string $definition
33
-     */
34
-    public function __construct(AbstractObject $parent, $definition)
35
-    {
36
-        $this->pattern = self::PATTERN;
37
-
38
-        parent::__construct($parent, $definition);
39
-    }
40
-
41
-    /**
42
-     * Parse a type definition string, assuming it belongs to this type
43
-     *
44
-     * @param string $definition
45
-     * @throws Exception
46
-     */
47
-    protected function parseDefinition($definition)
48
-    {
49
-        $definition = self::trim($definition);
50
-
51
-        $match = array();
52
-        if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
-            throw new Exception("Unparseable IPv6 definition: '{$definition}'");
54
-        }
55
-
56
-        if (!in_array(strtolower($match[1]), self::$formats)) {
57
-            throw new Exception("Not an IPv6: '{$definition}'");
58
-        }
59
-
60
-        $this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
-    }
62
-
63
-    /**
64
-     * Check (and optionally reformat) a default value
65
-     *
66
-     * @param string $value
67
-     * @return string
68
-     * @throws Exception
69
-     */
70
-    protected function validateDefault($value)
71
-    {
72
-        if (empty($value)) {
73
-            throw new Exception("Empty IPv6 default");
74
-        }
75
-
76
-        if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
77
-            throw new Exception("Invalid IPv6 default value: '{$value}'");
78
-        }
79
-
80
-        return $value;
81
-    }
82
-
83
-    public static function getFormats()
84
-    {
85
-        return self::$formats;
86
-    }
87
-
88
-    public static function setFormats(array $formats)
89
-    {
90
-        self::$formats = $formats;
91
-    }
20
+	const PATTERN = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))';
21
+
22
+	/**
23
+	 * List of formats recognized by this class
24
+	 * @var string[]
25
+	 */
26
+	private static $formats = array('ipv6');
27
+
28
+	/**
29
+	 * Construct and set up the regular expression for this type
30
+	 *
31
+	 * @param AbstractObject $parent
32
+	 * @param string $definition
33
+	 */
34
+	public function __construct(AbstractObject $parent, $definition)
35
+	{
36
+		$this->pattern = self::PATTERN;
37
+
38
+		parent::__construct($parent, $definition);
39
+	}
40
+
41
+	/**
42
+	 * Parse a type definition string, assuming it belongs to this type
43
+	 *
44
+	 * @param string $definition
45
+	 * @throws Exception
46
+	 */
47
+	protected function parseDefinition($definition)
48
+	{
49
+		$definition = self::trim($definition);
50
+
51
+		$match = array();
52
+		if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
+			throw new Exception("Unparseable IPv6 definition: '{$definition}'");
54
+		}
55
+
56
+		if (!in_array(strtolower($match[1]), self::$formats)) {
57
+			throw new Exception("Not an IPv6: '{$definition}'");
58
+		}
59
+
60
+		$this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
+	}
62
+
63
+	/**
64
+	 * Check (and optionally reformat) a default value
65
+	 *
66
+	 * @param string $value
67
+	 * @return string
68
+	 * @throws Exception
69
+	 */
70
+	protected function validateDefault($value)
71
+	{
72
+		if (empty($value)) {
73
+			throw new Exception("Empty IPv6 default");
74
+		}
75
+
76
+		if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
77
+			throw new Exception("Invalid IPv6 default value: '{$value}'");
78
+		}
79
+
80
+		return $value;
81
+	}
82
+
83
+	public static function getFormats()
84
+	{
85
+		return self::$formats;
86
+	}
87
+
88
+	public static function setFormats(array $formats)
89
+	{
90
+		self::$formats = $formats;
91
+	}
92 92
 
93 93
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/AbstractPreprocessor.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -13,123 +13,123 @@
 block discarded – undo
13 13
 abstract class AbstractPreprocessor
14 14
 {
15 15
 
16
-    private $defines = array();
17
-    private $stack = array();
18
-
19
-    public function __construct()
20
-    {
21
-        $this->resetDefines();
22
-    }
23
-
24
-    public function resetDefines()
25
-    {
26
-        $this->defines = array();
27
-    }
28
-
29
-    public function addDefines(array $defines)
30
-    {
31
-        $this->defines = array_merge($this->defines, $defines);
32
-    }
33
-
34
-    public function define($name, $value = 1)
35
-    {
36
-        $this->defines[$name] = $value;
37
-    }
38
-
39
-    public function undefine($name)
40
-    {
41
-        unset($this->defines[$name]);
42
-    }
43
-
44
-    protected function getState()
45
-    {
46
-        return empty($this->stack) || end($this->stack);
47
-    }
48
-
49
-    /**
50
-     * Get the first word from a string and remove it from the string.
51
-     *
52
-     * @param string $data
53
-     * @return boolean|string
54
-     */
55
-    private static function wordShift(&$data)
56
-    {
57
-        if (preg_match('~^(\S+)\s*(.*)$~', $data, $matches) === 1) {
58
-            $data = $matches[2];
59
-            return $matches[1];
60
-        }
61
-        return false;
62
-    }
63
-
64
-    protected function handle($command, $expression)
65
-    {
66
-        switch (strtolower($command)) {
67
-            case 'if':
68
-                $name = self::wordShift($expression);
69
-                $state = $this->getState();
70
-                if (empty($expression)) {
71
-                    $this->stack[] = $state && !empty($this->defines[$name]);
72
-                } else {
73
-                    $this->stack[] = $state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
74
-                }
75
-                break;
76
-
77
-            case 'ifdef':
78
-                $this->stack[] = $this->getState() && isset($this->defines[$expression]);
79
-                break;
80
-
81
-            case 'ifndef':
82
-                $this->stack[] = $this->getState() && !isset($this->defines[$expression]);
83
-                break;
84
-
85
-            case 'else':
86
-                $state = $this->getState();
87
-                array_pop($this->stack);
88
-                $this->stack[] = !$state;
89
-                break;
90
-
91
-            case 'elif':
92
-                $name = self::wordShift($expression);
93
-                $state = $this->getState();
94
-                array_pop($this->stack);
95
-                if (empty($expression)) {
96
-                    $this->stack[] = !$state && !empty($this->defines[$name]);
97
-                } else {
98
-                    $this->stack[] = !$state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
99
-                }
100
-                break;
101
-
102
-            case 'define':
103
-                $name = self::wordShift($expression);
104
-                $this->defines[$name] = $expression;
105
-                break;
106
-
107
-            case 'undef':
108
-                unset($this->defines[$expression]);
109
-                break;
110
-
111
-            case 'endif':
112
-                array_pop($this->stack);
113
-                break;
114
-
115
-            default:
116
-                return false;
117
-        }
118
-
119
-        return true;
120
-    }
121
-
122
-    public function preprocess($content)
123
-    {
124
-        $this->stack = array();
125
-
126
-        return $this->parseContent($content);
127
-    }
128
-
129
-    public function preprocessFile($filename)
130
-    {
131
-        return $this->preprocess(file_get_contents($filename));
132
-    }
133
-
134
-    abstract protected function parseContent($content);
16
+	private $defines = array();
17
+	private $stack = array();
18
+
19
+	public function __construct()
20
+	{
21
+		$this->resetDefines();
22
+	}
23
+
24
+	public function resetDefines()
25
+	{
26
+		$this->defines = array();
27
+	}
28
+
29
+	public function addDefines(array $defines)
30
+	{
31
+		$this->defines = array_merge($this->defines, $defines);
32
+	}
33
+
34
+	public function define($name, $value = 1)
35
+	{
36
+		$this->defines[$name] = $value;
37
+	}
38
+
39
+	public function undefine($name)
40
+	{
41
+		unset($this->defines[$name]);
42
+	}
43
+
44
+	protected function getState()
45
+	{
46
+		return empty($this->stack) || end($this->stack);
47
+	}
48
+
49
+	/**
50
+	 * Get the first word from a string and remove it from the string.
51
+	 *
52
+	 * @param string $data
53
+	 * @return boolean|string
54
+	 */
55
+	private static function wordShift(&$data)
56
+	{
57
+		if (preg_match('~^(\S+)\s*(.*)$~', $data, $matches) === 1) {
58
+			$data = $matches[2];
59
+			return $matches[1];
60
+		}
61
+		return false;
62
+	}
63
+
64
+	protected function handle($command, $expression)
65
+	{
66
+		switch (strtolower($command)) {
67
+			case 'if':
68
+				$name = self::wordShift($expression);
69
+				$state = $this->getState();
70
+				if (empty($expression)) {
71
+					$this->stack[] = $state && !empty($this->defines[$name]);
72
+				} else {
73
+					$this->stack[] = $state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
74
+				}
75
+				break;
76
+
77
+			case 'ifdef':
78
+				$this->stack[] = $this->getState() && isset($this->defines[$expression]);
79
+				break;
80
+
81
+			case 'ifndef':
82
+				$this->stack[] = $this->getState() && !isset($this->defines[$expression]);
83
+				break;
84
+
85
+			case 'else':
86
+				$state = $this->getState();
87
+				array_pop($this->stack);
88
+				$this->stack[] = !$state;
89
+				break;
90
+
91
+			case 'elif':
92
+				$name = self::wordShift($expression);
93
+				$state = $this->getState();
94
+				array_pop($this->stack);
95
+				if (empty($expression)) {
96
+					$this->stack[] = !$state && !empty($this->defines[$name]);
97
+				} else {
98
+					$this->stack[] = !$state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
99
+				}
100
+				break;
101
+
102
+			case 'define':
103
+				$name = self::wordShift($expression);
104
+				$this->defines[$name] = $expression;
105
+				break;
106
+
107
+			case 'undef':
108
+				unset($this->defines[$expression]);
109
+				break;
110
+
111
+			case 'endif':
112
+				array_pop($this->stack);
113
+				break;
114
+
115
+			default:
116
+				return false;
117
+		}
118
+
119
+		return true;
120
+	}
121
+
122
+	public function preprocess($content)
123
+	{
124
+		$this->stack = array();
125
+
126
+		return $this->parseContent($content);
127
+	}
128
+
129
+	public function preprocessFile($filename)
130
+	{
131
+		return $this->preprocess(file_get_contents($filename));
132
+	}
133
+
134
+	abstract protected function parseContent($content);
135 135
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/Php/Entity/ParserClass.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -15,120 +15,120 @@
 block discarded – undo
15 15
 class ParserClass extends AbstractEntity
16 16
 {
17 17
 
18
-    /**
19
-     * @var string
20
-     */
21
-    public $name = null;
22
-
23
-    /**
24
-     * @var ParserFunction[]
25
-     */
26
-    public $Methods = array();
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    public $extends = null;
32
-
33
-    /**
34
-     * @var string[]
35
-     */
36
-    public $implements = array();
37
-    private $lastStatements = null;
38
-
39
-    public function __construct(Parser $Parser, &$tokens, $Statements)
40
-    {
41
-        if ($Statements) {
42
-            $this->Statements = array_merge($this->Statements, $Statements);
43
-        }
44
-
45
-        $depth = 0;
46
-
47
-        $mode = T_CLASS;
48
-
49
-        $token = current($tokens);
50
-        while ($token) {
51
-            switch ($token[0]) {
52
-                case T_STRING:
53
-                    switch ($mode) {
54
-                        case T_CLASS:
55
-                            $this->name = $token[1];
56
-                            $mode = null;
57
-                            break;
58
-
59
-                        case T_EXTENDS:
60
-                            $Parser->queueClass($token[1]);
61
-                            $this->extends = $token[1];
62
-                            $mode = null;
63
-                            break;
64
-
65
-                        case T_IMPLEMENTS:
66
-                            $Parser->queueClass($token[1]);
67
-                            $this->implements[] = $token[1];
68
-                            break;
69
-                    }
70
-                    break;
71
-
72
-                case '{':
73
-                case T_CURLY_OPEN:
74
-                case T_DOLLAR_OPEN_CURLY_BRACES:
75
-                case T_STRING_VARNAME:
76
-                    $mode = null;
77
-                    ++$depth;
78
-                    break;
79
-
80
-                case '}':
81
-                    --$depth;
82
-                    if ($depth == 0) {
83
-                        if ($this->lastStatements) {
84
-                            $this->Statements = array_merge($this->Statements, $this->lastStatements);
85
-                            $this->lastStatements = null;
86
-                        }
87
-                        return;
88
-                    }
89
-                    break;
90
-
91
-                case T_FUNCTION:
92
-                    $Method = new ParserFunction($Parser, $tokens, $this->lastStatements);
93
-                    $this->Methods[strtolower($Method->name)] = $Method;
94
-                    $this->lastStatements = null;
95
-                    break;
96
-
97
-                case T_EXTENDS:
98
-                    $mode = T_EXTENDS;
99
-                    break;
100
-
101
-                case T_IMPLEMENTS:
102
-                    $mode = T_IMPLEMENTS;
103
-                    break;
104
-
105
-                case T_COMMENT:
106
-                    if ($this->lastStatements) {
107
-                        $this->Statements = array_merge($this->Statements, $this->lastStatements);
108
-                        $this->lastStatements = null;
109
-                    }
110
-                    $Statements = $Parser->tokenToStatements($token);
111
-                    $Parser->queueClassesFromComments($Statements);
112
-                    $this->Statements = array_merge($this->Statements, $Statements);
113
-                    break;
114
-
115
-                case T_DOC_COMMENT:
116
-                    if ($this->lastStatements) {
117
-                        $this->Statements = array_merge($this->Statements, $this->lastStatements);
118
-                    }
119
-                    $Statements = $Parser->tokenToStatements($token);
120
-                    $Parser->queueClassesFromComments($Statements);
121
-                    $this->lastStatements = $Statements;
122
-                    break;
123
-            }
124
-
125
-            $token = next($tokens);
126
-        }
127
-
128
-        if ($this->lastStatements) {
129
-            $this->Statements = array_merge($this->Statements, $this->lastStatements);
130
-            $this->lastStatements = null;
131
-        }
132
-    }
18
+	/**
19
+	 * @var string
20
+	 */
21
+	public $name = null;
22
+
23
+	/**
24
+	 * @var ParserFunction[]
25
+	 */
26
+	public $Methods = array();
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	public $extends = null;
32
+
33
+	/**
34
+	 * @var string[]
35
+	 */
36
+	public $implements = array();
37
+	private $lastStatements = null;
38
+
39
+	public function __construct(Parser $Parser, &$tokens, $Statements)
40
+	{
41
+		if ($Statements) {
42
+			$this->Statements = array_merge($this->Statements, $Statements);
43
+		}
44
+
45
+		$depth = 0;
46
+
47
+		$mode = T_CLASS;
48
+
49
+		$token = current($tokens);
50
+		while ($token) {
51
+			switch ($token[0]) {
52
+				case T_STRING:
53
+					switch ($mode) {
54
+						case T_CLASS:
55
+							$this->name = $token[1];
56
+							$mode = null;
57
+							break;
58
+
59
+						case T_EXTENDS:
60
+							$Parser->queueClass($token[1]);
61
+							$this->extends = $token[1];
62
+							$mode = null;
63
+							break;
64
+
65
+						case T_IMPLEMENTS:
66
+							$Parser->queueClass($token[1]);
67
+							$this->implements[] = $token[1];
68
+							break;
69
+					}
70
+					break;
71
+
72
+				case '{':
73
+				case T_CURLY_OPEN:
74
+				case T_DOLLAR_OPEN_CURLY_BRACES:
75
+				case T_STRING_VARNAME:
76
+					$mode = null;
77
+					++$depth;
78
+					break;
79
+
80
+				case '}':
81
+					--$depth;
82
+					if ($depth == 0) {
83
+						if ($this->lastStatements) {
84
+							$this->Statements = array_merge($this->Statements, $this->lastStatements);
85
+							$this->lastStatements = null;
86
+						}
87
+						return;
88
+					}
89
+					break;
90
+
91
+				case T_FUNCTION:
92
+					$Method = new ParserFunction($Parser, $tokens, $this->lastStatements);
93
+					$this->Methods[strtolower($Method->name)] = $Method;
94
+					$this->lastStatements = null;
95
+					break;
96
+
97
+				case T_EXTENDS:
98
+					$mode = T_EXTENDS;
99
+					break;
100
+
101
+				case T_IMPLEMENTS:
102
+					$mode = T_IMPLEMENTS;
103
+					break;
104
+
105
+				case T_COMMENT:
106
+					if ($this->lastStatements) {
107
+						$this->Statements = array_merge($this->Statements, $this->lastStatements);
108
+						$this->lastStatements = null;
109
+					}
110
+					$Statements = $Parser->tokenToStatements($token);
111
+					$Parser->queueClassesFromComments($Statements);
112
+					$this->Statements = array_merge($this->Statements, $Statements);
113
+					break;
114
+
115
+				case T_DOC_COMMENT:
116
+					if ($this->lastStatements) {
117
+						$this->Statements = array_merge($this->Statements, $this->lastStatements);
118
+					}
119
+					$Statements = $Parser->tokenToStatements($token);
120
+					$Parser->queueClassesFromComments($Statements);
121
+					$this->lastStatements = $Statements;
122
+					break;
123
+			}
124
+
125
+			$token = next($tokens);
126
+		}
127
+
128
+		if ($this->lastStatements) {
129
+			$this->Statements = array_merge($this->Statements, $this->lastStatements);
130
+			$this->lastStatements = null;
131
+		}
132
+	}
133 133
 
134 134
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/IParser.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,5 +13,5 @@
 block discarded – undo
13 13
 interface IParser
14 14
 {
15 15
 
16
-    public function parse($file, array $dirs = array());
16
+	public function parse($file, array $dirs = array());
17 17
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/Text/Preprocessor.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@
 block discarded – undo
18 18
 class Preprocessor extends AbstractPreprocessor
19 19
 {
20 20
 
21
-    protected function parseContent($content)
22
-    {
23
-        $pattern = '/\\s*([a-z]+)\\s*(.*)\\s*/';
24
-
25
-        $output = '';
26
-
27
-        foreach (preg_split('/(\\R)/m', $content, null, PREG_SPLIT_DELIM_CAPTURE) as $index => $line) {
28
-            if ($index % 2) {
29
-                $output .= $line;
30
-            } else {
31
-                $match = array();
32
-                if (preg_match($pattern, $line, $match) === 1) {
33
-                    if (!$this->handle($match[1], $match[2]) && $this->getState()) {
34
-                        $output .= $line;
35
-                    } else {
36
-                        $output .= '';
37
-                    }
38
-                } else {
39
-                    $output .= $line;
40
-                }
41
-            }
42
-        }
43
-
44
-        return $output;
45
-    }
21
+	protected function parseContent($content)
22
+	{
23
+		$pattern = '/\\s*([a-z]+)\\s*(.*)\\s*/';
24
+
25
+		$output = '';
26
+
27
+		foreach (preg_split('/(\\R)/m', $content, null, PREG_SPLIT_DELIM_CAPTURE) as $index => $line) {
28
+			if ($index % 2) {
29
+				$output .= $line;
30
+			} else {
31
+				$match = array();
32
+				if (preg_match($pattern, $line, $match) === 1) {
33
+					if (!$this->handle($match[1], $match[2]) && $this->getState()) {
34
+						$output .= $line;
35
+					} else {
36
+						$output .= '';
37
+					}
38
+				} else {
39
+					$output .= $line;
40
+				}
41
+			}
42
+		}
43
+
44
+		return $output;
45
+	}
46 46
 
47 47
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/Text/Parser.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -17,99 +17,99 @@
 block discarded – undo
17 17
 class Parser implements IParser
18 18
 {
19 19
 
20
-    /**
21
-     * List of directories to scan for class files referenced in the parsed
22
-     * command statements.
23
-     *
24
-     * @var string[]
25
-     */
26
-    protected $common_dirs = [];
20
+	/**
21
+	 * List of directories to scan for class files referenced in the parsed
22
+	 * command statements.
23
+	 *
24
+	 * @var string[]
25
+	 */
26
+	protected $common_dirs = [];
27 27
 
28
-    /**
29
-     * @var AbstractPreprocessor
30
-     */
31
-    private $Preprocessor;
28
+	/**
29
+	 * @var AbstractPreprocessor
30
+	 */
31
+	private $Preprocessor;
32 32
 
33
-    /**
34
-     * Create a new text parser and set directories to scan for referenced
35
-     * class files.
36
-     *
37
-     * @param string[] $dirs
38
-     */
39
-    public function __construct(array $dirs = [])
40
-    {
41
-        foreach ($dirs as $dir) {
42
-            $this->common_dirs[] = realpath($dir);
43
-        }
33
+	/**
34
+	 * Create a new text parser and set directories to scan for referenced
35
+	 * class files.
36
+	 *
37
+	 * @param string[] $dirs
38
+	 */
39
+	public function __construct(array $dirs = [])
40
+	{
41
+		foreach ($dirs as $dir) {
42
+			$this->common_dirs[] = realpath($dir);
43
+		}
44 44
 
45
-        $this->Preprocessor = new Preprocessor();
46
-    }
45
+		$this->Preprocessor = new Preprocessor();
46
+	}
47 47
 
48
-    /**
49
-     * Add additional directories to scan for referenced class files.
50
-     *
51
-     * @param string[] $dirs
52
-     */
53
-    public function addDirs(array $dirs)
54
-    {
55
-        foreach ($dirs as $dir) {
56
-            $this->common_dirs[] = realpath($dir);
57
-        }
58
-    }
48
+	/**
49
+	 * Add additional directories to scan for referenced class files.
50
+	 *
51
+	 * @param string[] $dirs
52
+	 */
53
+	public function addDirs(array $dirs)
54
+	{
55
+		foreach ($dirs as $dir) {
56
+			$this->common_dirs[] = realpath($dir);
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * Parse a text file
62
-     *
63
-     * @param string $file
64
-     * @param string[] $dirs
65
-     * @param string[] $defines
66
-     * @return Statement[]
67
-     */
68
-    public function parse($file, array $dirs = [], array $defines = [])
69
-    {
70
-        return $this->parseText(file_get_contents(realpath($file)), $dirs);
71
-    }
60
+	/**
61
+	 * Parse a text file
62
+	 *
63
+	 * @param string $file
64
+	 * @param string[] $dirs
65
+	 * @param string[] $defines
66
+	 * @return Statement[]
67
+	 */
68
+	public function parse($file, array $dirs = [], array $defines = [])
69
+	{
70
+		return $this->parseText(file_get_contents(realpath($file)), $dirs);
71
+	}
72 72
 
73
-    /**
74
-     * Parse plain text
75
-     *
76
-     * @param string $text
77
-     * @param string[] $dirs
78
-     * @param string[] $defines
79
-     * @return Statement[]
80
-     */
81
-    public function parseText($text, array $dirs = [], array $defines = []): array
82
-    {
83
-        $this->Preprocessor->resetDefines();
84
-        $this->Preprocessor->addDefines($defines);
85
-        $text = $this->Preprocessor->preprocess($text);
73
+	/**
74
+	 * Parse plain text
75
+	 *
76
+	 * @param string $text
77
+	 * @param string[] $dirs
78
+	 * @param string[] $defines
79
+	 * @return Statement[]
80
+	 */
81
+	public function parseText($text, array $dirs = [], array $defines = []): array
82
+	{
83
+		$this->Preprocessor->resetDefines();
84
+		$this->Preprocessor->addDefines($defines);
85
+		$text = $this->Preprocessor->preprocess($text);
86 86
 
87
-        $Statements = [];
87
+		$Statements = [];
88 88
 
89
-        foreach (preg_split('/\\R/m', $text) as $line => $data) {
90
-            $data = trim($data);
91
-            $command = self::wordShift($data);
92
-            if (!empty($command)) {
93
-                $Statements[] = new Statement($command, $data, null, $line);
94
-            }
95
-        }
89
+		foreach (preg_split('/\\R/m', $text) as $line => $data) {
90
+			$data = trim($data);
91
+			$command = self::wordShift($data);
92
+			if (!empty($command)) {
93
+				$Statements[] = new Statement($command, $data, null, $line);
94
+			}
95
+		}
96 96
 
97
-        return $Statements;
98
-    }
97
+		return $Statements;
98
+	}
99 99
 
100
-    /**
101
-     * Get the first word from a string and remove it from the string.
102
-     *
103
-     * @param string $data
104
-     * @return boolean|string
105
-     */
106
-    private static function wordShift(&$data)
107
-    {
108
-        if (preg_match('~^(\S+)\s*(.*)$~', $data, $matches) === 1) {
109
-            $data = $matches[2];
110
-            return $matches[1];
111
-        }
112
-        return false;
113
-    }
100
+	/**
101
+	 * Get the first word from a string and remove it from the string.
102
+	 *
103
+	 * @param string $data
104
+	 * @return boolean|string
105
+	 */
106
+	private static function wordShift(&$data)
107
+	{
108
+		if (preg_match('~^(\S+)\s*(.*)$~', $data, $matches) === 1) {
109
+			$data = $matches[2];
110
+			return $matches[1];
111
+		}
112
+		return false;
113
+	}
114 114
 
115 115
 }
Please login to merge, or discard this patch.
SwaggerGen/TypeRegistry.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -15,55 +15,55 @@
 block discarded – undo
15 15
 class TypeRegistry
16 16
 {
17 17
 
18
-    /**
19
-     * Map of format-name => class-name
20
-     *
21
-     * @var array
22
-     */
23
-    private $formats = array();
18
+	/**
19
+	 * Map of format-name => class-name
20
+	 *
21
+	 * @var array
22
+	 */
23
+	private $formats = array();
24 24
 
25
-    /**
26
-     * Add a type name from classname
27
-     *
28
-     * @param string $classname
29
-     */
30
-    public function add(string $classname): void
31
-    {
32
-        if (is_subclass_of($classname, ICustomType::class)) {
33
-            foreach ($classname::getFormats() as $format) {
34
-                $this->formats[$format] = $classname;
35
-            }
36
-        }
37
-    }
25
+	/**
26
+	 * Add a type name from classname
27
+	 *
28
+	 * @param string $classname
29
+	 */
30
+	public function add(string $classname): void
31
+	{
32
+		if (is_subclass_of($classname, ICustomType::class)) {
33
+			foreach ($classname::getFormats() as $format) {
34
+				$this->formats[$format] = $classname;
35
+			}
36
+		}
37
+	}
38 38
 
39
-    /**
40
-     * Remove type format by explicitly nulling it (disables it)
41
-     *
42
-     * @param string $name
43
-     */
44
-    public function remove($name)
45
-    {
46
-        $this->formats[$name] = null;
47
-    }
39
+	/**
40
+	 * Remove type format by explicitly nulling it (disables it)
41
+	 *
42
+	 * @param string $name
43
+	 */
44
+	public function remove($name)
45
+	{
46
+		$this->formats[$name] = null;
47
+	}
48 48
 
49
-    /**
50
-     * Is a type format known?
51
-     *
52
-     * @return bool
53
-     */
54
-    public function has($name)
55
-    {
56
-        return !empty($this->formats[$name]);
57
-    }
49
+	/**
50
+	 * Is a type format known?
51
+	 *
52
+	 * @return bool
53
+	 */
54
+	public function has($name)
55
+	{
56
+		return !empty($this->formats[$name]);
57
+	}
58 58
 
59
-    /**
60
-     * Get the format class name
61
-     *
62
-     * @return null|string
63
-     */
64
-    public function get($name)
65
-    {
66
-        return !empty($this->formats[$name]) ? $this->formats[$name] : null;
67
-    }
59
+	/**
60
+	 * Get the format class name
61
+	 *
62
+	 * @return null|string
63
+	 */
64
+	public function get($name)
65
+	{
66
+		return !empty($this->formats[$name]) ? $this->formats[$name] : null;
67
+	}
68 68
 
69 69
 }
Please login to merge, or discard this patch.
tests/Base/PHPUnit7.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 
3 3
 class Base_PHPUnit7 extends PHPUnit\Framework\TestCase
4 4
 {
5
-    public function expectException(string $exception, string $message = ''): void
6
-    {
7
-        parent::expectException($exception);
8
-        if ($message !== '') {
9
-            parent::expectExceptionMessage($message);
10
-        }
11
-    }
5
+	public function expectException(string $exception, string $message = ''): void
6
+	{
7
+		parent::expectException($exception);
8
+		if ($message !== '') {
9
+			parent::expectExceptionMessage($message);
10
+		}
11
+	}
12 12
 }
Please login to merge, or discard this patch.
tests/Base/PHPUnit5.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@
 block discarded – undo
2 2
 
3 3
 class Base_PHPUnit5 extends PHPUnit_Framework_TestCase
4 4
 {
5
-    /**
6
-     * @param string $exception
7
-     * @param string $message
8
-     * @return void
9
-     */
10
-    public function expectException($exception, $message = '')
11
-    {
12
-        parent::setExpectedException($exception, $message);
13
-    }
5
+	/**
6
+	 * @param string $exception
7
+	 * @param string $message
8
+	 * @return void
9
+	 */
10
+	public function expectException($exception, $message = '')
11
+	{
12
+		parent::setExpectedException($exception, $message);
13
+	}
14 14
 }
Please login to merge, or discard this patch.