Skip to content

Commit c0ceea4

Browse files
authored
Merge pull request #72 from TheDigitalOrchard/syntax-cleanup
syntax cleanup, set minimum PHP version to 5.6
2 parents 35510e3 + 47dd00d commit c0ceea4

File tree

10 files changed

+29
-29
lines changed

10 files changed

+29
-29
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup PHP with specific version
2121
uses: shivammathur/setup-php@v2
2222
with:
23-
php-version: '5.4'
23+
php-version: '5.6'
2424

2525
- name: Validate composer.json and composer.lock
2626
run: composer validate --strict

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.4"
14+
"php": ">=5.6"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": "~4.0",

src/Galbar/JsonPath/Expression/Comparison.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public static function evaluate(&$root, &$partial, $leftExpr, $comparator, $righ
3030
}
3131
if ($comparator === Language\Token::COMP_EQ) {
3232
return $left === $right;
33-
} else if ($comparator === Language\Token::COMP_NEQ) {
33+
} elseif ($comparator === Language\Token::COMP_NEQ) {
3434
return $left !== $right;
35-
} else if ($comparator === Language\Token::COMP_LT) {
35+
} elseif ($comparator === Language\Token::COMP_LT) {
3636
return $left < $right;
37-
} else if ($comparator === Language\Token::COMP_GT) {
37+
} elseif ($comparator === Language\Token::COMP_GT) {
3838
return $left > $right;
39-
} else if ($comparator === Language\Token::COMP_LTE) {
39+
} elseif ($comparator === Language\Token::COMP_LTE) {
4040
return $left <= $right;
41-
} else if ($comparator === Language\Token::COMP_GTE) {
41+
} elseif ($comparator === Language\Token::COMP_GTE) {
4242
return $left >= $right;
4343
} else { // $comparator === Language\Token::COMP_RE_MATCH
4444
if (is_string($right) && is_string($left)) {

src/Galbar/JsonPath/Expression/Value.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public static function evaluate(&$root, &$partial, $expression)
2626
{
2727
if ($expression === Language\Token::VAL_NULL) {
2828
return null;
29-
} else if ($expression === Language\Token::VAL_TRUE) {
29+
} elseif ($expression === Language\Token::VAL_TRUE) {
3030
return true;
31-
} else if ($expression === Language\Token::VAL_FALSE) {
31+
} elseif ($expression === Language\Token::VAL_FALSE) {
3232
return false;
33-
} else if (is_numeric($expression)) {
33+
} elseif (is_numeric($expression)) {
3434
return floatval($expression);
35-
} else if (preg_match(Language\Regex::EXPR_STRING, $expression)) {
35+
} elseif (preg_match(Language\Regex::EXPR_STRING, $expression)) {
3636
return substr($expression, 1, strlen($expression) - 2);
37-
} else if (preg_match(Language\Regex::EXPR_REGEX, $expression)) {
37+
} elseif (preg_match(Language\Regex::EXPR_REGEX, $expression)) {
3838
return $expression;
3939
} else {
4040
$match = array();
@@ -54,8 +54,7 @@ public static function evaluate(&$root, &$partial, $expression)
5454
if ($length) {
5555
if (is_array($result[0])) {
5656
return (float) count($result[0]);
57-
}
58-
if (is_string($result[0])) {
57+
} elseif (is_string($result[0])) {
5958
return (float) strlen($result[0]);
6059
}
6160
return false;

src/Galbar/JsonPath/InvalidJsonPathException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ class InvalidJsonPathException extends \Exception
3535
*/
3636
public function __construct($token)
3737
{
38-
parent::__construct("Error in JSONPath near '" . $token . "'", 0, null);
38+
parent::__construct("Error in JSONPath near '{$token}'", 0, null);
3939
}
4040
}

src/Galbar/JsonPath/JsonObject.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ function __construct($json = null, $smartGet = false)
121121
{
122122
if ($json === null) {
123123
$this->jsonObject = array();
124-
} else if (is_string($json)) {
124+
} elseif (is_string($json)) {
125125
$this->jsonObject = json_decode($json, true);
126126
if ($this->jsonObject === null) {
127-
throw new InvalidJsonException("string does not contain a valid JSON object.");
127+
throw new InvalidJsonException('String does not contain a valid JSON object.');
128128
}
129-
} else if (is_array($json)) {
129+
} elseif (is_array($json)) {
130130
$this->jsonObject = $json;
131-
} else if (is_object($json)){
131+
} elseif (is_object($json)){
132132
$this->jsonObject = json_decode(json_encode($json), true);
133133
} else {
134-
throw new InvalidJsonException("value does not encode a JSON object.");
134+
throw new InvalidJsonException('Value does not encode a JSON object.');
135135
}
136136
$this->smartGet = $smartGet;
137137
}
@@ -198,7 +198,7 @@ public function &getValue()
198198
*
199199
* @return string
200200
*/
201-
public function getJson($options=0)
201+
public function getJson($options = 0)
202202
{
203203
return json_encode($this->jsonObject, $options);
204204
}

src/Galbar/JsonPath/JsonPath.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function subtreeGet(&$root, &$partial, $jsonPath, $createInexisten
5858
} else {
5959
$jsonPath = $match[2];
6060
}
61-
} else if (Language\ChildSelector::match($jsonPath, $match)) {
61+
} elseif (Language\ChildSelector::match($jsonPath, $match)) {
6262
$contents = $match[0];
6363
foreach ($selection as &$partial) {
6464
list($result, $newHasDiverged) = Operation\SelectChildren::apply($root, $partial, $contents, $createInexistent);
@@ -71,12 +71,12 @@ public static function subtreeGet(&$root, &$partial, $jsonPath, $createInexisten
7171
} else {
7272
$jsonPath = $match[1];
7373
}
74-
} else if (preg_match(Language\Regex::RECURSIVE_SELECTOR, $jsonPath, $match)) {
74+
} elseif (preg_match(Language\Regex::RECURSIVE_SELECTOR, $jsonPath, $match)) {
7575
$recursivePath = $match[1];
7676
if ($recursivePath[0] === '[') {
77-
$recursivePath = "$$recursivePath";
77+
$recursivePath = "${$recursivePath}";
7878
} else {
79-
$recursivePath = "$.$recursivePath";
79+
$recursivePath = "$.{$recursivePath}";
8080
}
8181
foreach ($selection as &$partial) {
8282
list($result, $newHasDiverged) = Operation\GetRecursive::apply($root, $partial, $recursivePath);
@@ -87,7 +87,7 @@ public static function subtreeGet(&$root, &$partial, $jsonPath, $createInexisten
8787
$hasDiverged = $hasDiverged || $newHasDiverged;
8888
break;
8989
} else {
90-
$jsonPath = "";
90+
$jsonPath = '';
9191
}
9292
} else {
9393
throw new \JsonPath\InvalidJsonPathException($jsonPath);

src/Galbar/JsonPath/Language/Token.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Token
2828
const EXPRESSION_END = ')';
2929
const ALL = '*';
3030
const COMA = ',';
31+
const COMMA = ',';
3132
const COLON = ':';
3233
const COMP_EQ = '==';
3334
const COMP_NEQ = '!=';

src/Galbar/JsonPath/Operation/SelectChildren.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function($x) { return intval(trim($x)); },
4949
} else if (preg_match(Language\Regex::CHILD_NAME_LIST, $contents, $match)) {
5050
$names = array_map(
5151
function($x) { return trim($x, " \t\n\r\0\x0B'\""); },
52-
explode(Language\Token::COMA, $contents)
52+
explode(Language\Token::COMMA, $contents)
5353
);
5454
if (count($names) > 1) {
5555
$hasDiverged = true;

src/Galbar/Utilities/ArraySlice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static function adjustEndpoint($length, $endpoint, $step)
6161
if ($endpoint < 0) {
6262
$endpoint = ($step < 0 ? -1 : 0);
6363
}
64-
} else if ($endpoint >= $length) {
64+
} elseif ($endpoint >= $length) {
6565
$endpoint = ($step < 0 ? $length - 1 : $length);
6666
}
6767
return $endpoint;
@@ -71,7 +71,7 @@ private static function adjustSlice($length, &$start, &$stop, &$step)
7171
{
7272
if ($step === null) {
7373
$step = 1;
74-
} else if ($step === 0) {
74+
} elseif ($step === 0) {
7575
throw new \Exception("Step cannot be 0");
7676
}
7777

0 commit comments

Comments
 (0)