Skip to content

Commit

Permalink
Wrap all functionality in the JsonPath namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
crocodele committed Jul 9, 2021
1 parent 9a77de3 commit fd1b1e5
Show file tree
Hide file tree
Showing 285 changed files with 323 additions and 323 deletions.
2 changes: 1 addition & 1 deletion jsonpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void print_lex_tokens(struct jpath_token lex_tok[], int lex_tok_count, const cha
*/
PHP_MINIT_FUNCTION(jsonpath) {
zend_class_entry jsonpath_class_entry;
INIT_CLASS_ENTRY(jsonpath_class_entry, "JsonPath", class_JsonPath_methods);
INIT_NS_CLASS_ENTRY(jsonpath_class_entry, "JsonPath", "JsonPath", class_JsonPath_methods);

jsonpath_ce = zend_register_internal_class(&jsonpath_class_entry);

Expand Down
2 changes: 1 addition & 1 deletion tests/001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $obj = array (
),
);

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

echo "Assertion 1\n";
print_r($jsonPath->find($obj, '$.store.book'));
Expand Down
2 changes: 1 addition & 1 deletion tests/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test typical use cases
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'level1' =>
Expand Down
2 changes: 1 addition & 1 deletion tests/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test typical use cases
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array(
'id' => 1234,
Expand Down
2 changes: 1 addition & 1 deletion tests/004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing >, <, >= <= operators
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Ensure no segfault if filtering on object instead of array
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array(
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Ensure no "Array to string conversion" notice when selecting non-scalar
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array(
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing <= operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing <= operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/009.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing <= operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing >= operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/011.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing >= operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/012.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing >= operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/013.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing != operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
2 changes: 1 addition & 1 deletion tests/014.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Testing != operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$obj = array (
'test' => array(
Expand Down
4 changes: 2 additions & 2 deletions tests/015.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test array slice with strings as start, end, and step
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -22,7 +22,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words['first':'last':'two']");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/016.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test array slice with unquoted strings as start, end, and step
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -22,7 +22,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[first:last:two]");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/017.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test array slice with mix of unquoted string and numbers as start, end, and step
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -22,7 +22,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[first:-1:2]");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/018.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test array slice with wildcard as end
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -22,7 +22,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[0:*:2]");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/019.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test broken boolean as right-hand operand
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -32,7 +32,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[?(@.isAdjective == truse)]");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/020.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test broken boolean as left-hand operand
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -32,7 +32,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[?(falsue == @.isAdjective)]");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/021.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test dot selector with misplaced current node operator
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -32,7 +32,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words.@");

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/022.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[?(@.d==[100,200])]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/023.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$[?(@.name=~/hello\/.*/)]");

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/bounds_checks/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Ensure queries that contain more than LEX_TOK_ARR_LEN tokens safely fail
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

try {
// This query contains 51 tokens (root selector $ plus 50 dot selectors), which exceeds LEX_TOK_ARR_LEN
Expand Down
4 changes: 2 additions & 2 deletions tests/bounds_checks/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test array slice with overflowing values for start, end, and stop
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -22,7 +22,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[9223372036854775808:9223372036854775809:9223372036854775810]");

var_dump($result);
Expand Down
4 changes: 2 additions & 2 deletions tests/bounds_checks/004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test filter with overflowing operand
--FILE--
<?php

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();

$data = [
'words' => [
Expand All @@ -32,7 +32,7 @@ $data = [
],
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$.words[?($.occurrences > 9223372036854775808)]");

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $data = [
"fifth",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[1:3]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $data = [
"fifth",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[0:5]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $data = [
"third",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[7:10]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $data = [
"1:3" => "nice",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[1:3]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $data = [
"third",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[1:10]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $data = [
"fifth",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[2:113667776004]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $data = [
"fifth",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[2:-113667776004:-1]');

var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/comparison_array_slice/008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $data = [
"fifth",
];

$jsonPath = new JsonPath();
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, '$[-113667776004:2]');

var_dump($result);
Expand Down
Loading

0 comments on commit fd1b1e5

Please sign in to comment.