Skip to content

Commit d5e9f27

Browse files
committed
Self-correct
1 parent a9b5af7 commit d5e9f27

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

src/PHPCheckstyle/PHPCheckstyle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ private function _processParenthesisClose($token) {
13781378
if ($this->statementStack->getCurrentStackItem()->openParentheses === 0) {
13791379

13801380
// We are in a array declaration, we unstack
1381-
if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_ARRAY and $this->statementStack->getCurrentStackItem()->name !== 'square_bracket_open') {
1381+
if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_ARRAY && $this->statementStack->getCurrentStackItem()->name !== 'square_bracket_open') {
13821382
$this->statementStack->pop();
13831383
}
13841384
}
@@ -2613,7 +2613,7 @@ private function _checkEmptyBlock() {
26132613
* This function is launched when the current token is T_ENCAPSED_AND_WHITESPACE.
26142614
*/
26152615
private function _checkEncapsedVariablesInsideString() {
2616-
if ($this->_isActive('encapsedVariablesInsideString') and (!$this->statementStack->getCurrentStackItem()->inHeredoc or ($this->_inFuncCall and !$this->_config->isException('encapsedVariablesInsideString', end($this->_currentFuncCall))))) {
2616+
if ($this->_isActive('encapsedVariablesInsideString') && (!$this->statementStack->getCurrentStackItem()->inHeredoc || ($this->_inFuncCall && !$this->_config->isException('encapsedVariablesInsideString', end($this->_currentFuncCall))))) {
26172617
$this->_writeError('encapsedVariablesInsideString', $this->_getMessage('VARIABLE_INSIDE_STRING'));
26182618
}
26192619
}

src/PHPCheckstyle/Reporter/ConsoleReporter.php

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111
*/
1212
class ConsoleReporter extends Reporter {
1313

14-
/**
15-
* @var String
16-
*/
17-
private $reportingLevel;
14+
/**
15+
*
16+
* @var String
17+
*/
18+
private $reportingLevel;
1819

19-
public function __construct($level = INFO) {
20-
$this->reportingLevel = $this->calculateLevel($level);
21-
parent::__construct();
22-
}
20+
public function __construct($level = INFO) {
21+
$this->reportingLevel = $this->_calculateLevel($level);
22+
parent::__construct();
23+
}
2324

24-
/**
25+
/**
26+
*
2527
* {@inheritdoc}
2628
*
2729
* @param Integer $line
@@ -32,40 +34,39 @@ public function __construct($level = INFO) {
3234
* the text to log
3335
* @param String $level
3436
* the severity level
35-
* @SuppressWarnings
37+
* @SuppressWarnings
3638
*/
3739
public function writeError($line, $check, $message, $level = WARNING) {
38-
$messageLevel = $this->calculateLevel($level);
39-
if ($messageLevel >= $this->reportingLevel) {
40-
echo "File \"" . $this->currentPhpFile . "\"" . " " . $level . ", line " . $line . " - " . $message . "\n";
41-
}
40+
$messageLevel = $this->_calculateLevel($level);
41+
if ($messageLevel >= $this->reportingLevel) {
42+
echo "File \"" . $this->currentPhpFile . "\"" . " " . $level . ", line " . $line . " - " . $message . "\n";
43+
}
4244
}
4345

44-
/**
45-
* Transforms a specified level from a String to an Integer
46-
* so one can check if the level is above or below a
47-
* certain threshold.
48-
*
49-
* Unknown level will return 1 which is equal to INFO
50-
*
51-
* @param String $level
52-
*
53-
* @return int
54-
* INFO = 1
55-
* WARNING = 2
56-
* ERROR = 3
57-
* unknown = 1
58-
*/
59-
private function calculateLevel($level) {
60-
switch ($level) {
61-
case INFO:
62-
return 1;
63-
case WARNING:
64-
return 2;
65-
case ERROR:
66-
return 3;
67-
default:
68-
return 1;
69-
}
70-
}
46+
/**
47+
* Transforms a specified level from a String to an Integer
48+
* so one can check if the level is above or below a
49+
* certain threshold.
50+
*
51+
* Unknown level will return 1 which is equal to INFO
52+
*
53+
* @param String $level
54+
*
55+
* @return int INFO = 1
56+
* WARNING = 2
57+
* ERROR = 3
58+
* unknown = 1
59+
*/
60+
private function _calculateLevel($level) {
61+
switch ($level) {
62+
case INFO:
63+
return 1;
64+
case WARNING:
65+
return 2;
66+
case ERROR:
67+
return 3;
68+
default:
69+
return 1;
70+
}
71+
}
7172
}

0 commit comments

Comments
 (0)