Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sor3nt@gmail.com committed Dec 30, 2018
1 parent d6ac6af commit a29de05
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/Service/Compiler/Parser/T_IF.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ static public function map( $tokens, $current, \Closure $parseToken ){
}
}


if (count($case['condition'])){
$firstNode = $case['condition'][0];
$lastNode = end($case['condition']);


$doWrap = false;
if (
!(
Expand Down Expand Up @@ -95,8 +93,6 @@ static public function map( $tokens, $current, \Closure $parseToken ){
$tree = [$tree];

self::remapCondition( $tree, $isNot );


self::extendConditionInformation( $tree );

$parsedConditions[] = current($tree);
Expand All @@ -123,8 +119,6 @@ static public function map( $tokens, $current, \Closure $parseToken ){

static public function fixDoubleBracketOpen( $tokens ){

// var_dump($tokens);
// exit;
if (
count($tokens['params']) == 3 &&
$tokens['params'][0]['type'] == Token::T_BRACKET_OPEN &&
Expand All @@ -141,7 +135,6 @@ static public function parseIfStatement( $tokens, $current, \Closure $parseToken

$token = $tokens[$current];


$node = [
'type' => $token['type'],
'value' => $token['value'],
Expand Down Expand Up @@ -225,7 +218,7 @@ static public function parseIfStatement( $tokens, $current, \Closure $parseToken
* bad hack, i parse here the tokens to get the needed length....
*/
$beforeCurrent = $current + 2;
list($current,) = $parseToken(
list($current, ) = $parseToken(
$tokens, $current + 2
);

Expand Down Expand Up @@ -291,7 +284,7 @@ static public function parseIfStatement( $tokens, $current, \Closure $parseToken
* bad hack, i parse here the tokens to get the needed length....
*/
$beforeCurrent = $current + 2;
list($current,) = $parseToken(
list($current, ) = $parseToken(
$tokens, $current + 2
);

Expand Down Expand Up @@ -332,7 +325,7 @@ static public function parseIfStatement( $tokens, $current, \Closure $parseToken
}


static function parseIfLastElse( $tokens, $current, $shortStatement = false ){
static function parseIfLastElse( $tokens, $current ){

$case = [
'condition' => [],
Expand Down Expand Up @@ -360,7 +353,6 @@ static function parseIfLastElse( $tokens, $current, $shortStatement = false ){
$deep--;
}


$case[ 'isTrue' ][] = $token;

$current++;
Expand All @@ -369,15 +361,14 @@ static function parseIfLastElse( $tokens, $current, $shortStatement = false ){
throw new \Exception('Parser: parseIfLastElse not handeld correct');
}



/**
* remap / regroup statements
*
* input : T_VARIABLE T_IS_EQUAL T_INT
* output : T_IS_EQUAL[T_VARIABLE] = T_INT
*
* @param $tokens
* @param bool $isOuterNot
* @throws \Exception
*/
static function remapCondition( &$tokens, $isOuterNot = false ){
Expand Down Expand Up @@ -465,7 +456,6 @@ static function remapCondition( &$tokens, $isOuterNot = false ){
}

if ($opertation == false){

throw new \Exception('operator not found');
}
$innerTokens = array_values($innerTokens);
Expand Down Expand Up @@ -495,7 +485,6 @@ static function remapCondition( &$tokens, $isOuterNot = false ){
}

$innerCurrent++;

}
}

Expand Down Expand Up @@ -529,6 +518,4 @@ static function extendConditionInformation( &$tokens ){
}
}
}


}

0 comments on commit a29de05

Please sign in to comment.