Skip to content

Commit 41beb2c

Browse files
committed
Removed deprecated methods from query object
1 parent fa2487d commit 41beb2c

File tree

8 files changed

+61
-32
lines changed

8 files changed

+61
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
### Added
9-
- Added `QueryInterface::isDefinite()` method that returns true if given query can address
10-
only one value.
9+
- Query object now provides properties interface with `isPath` and `isDefinite` flags.
1110
- `QueryCallbackBuilderInterface` implemented.
1211
### Deprecated
1312
- `SelectResultInterface::encode()` method deprecates `::toJson()`.

src/Query/Exception/PropertiesNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ final class PropertiesNotFoundException extends LogicException implements Except
1111

1212
public function __construct(Throwable $previous = null)
1313
{
14-
parent::__construct("IsDefinite flag is accessed before being set", 0, $previous);
14+
parent::__construct("Properties are accessed before being set", 0, $previous);
1515
}
1616
}

src/Query/LazyQuery.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode
3131
return $this->getLoadedQuery()($runtime, $rootNode);
3232
}
3333

34-
/**
35-
* @return bool
36-
* @deprecated
37-
*/
38-
public function isDefinite(): bool
39-
{
40-
return $this
41-
->getProperties()
42-
->isDefinite();
43-
}
44-
4534
public function getProperties(): QueryPropertiesInterface
4635
{
4736
return $this

src/Query/Query.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode
2626
return call_user_func($this->callback, $runtime, $rootNode);
2727
}
2828

29-
/**
30-
* @return bool
31-
* @deprecated
32-
*/
33-
public function isDefinite(): bool
34-
{
35-
return $this->properties->isDefinite();
36-
}
37-
3829
public function getProperties(): QueryPropertiesInterface
3930
{
4031
return $this->properties;

src/Query/QueryInterface.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,5 @@ interface QueryInterface
1212

1313
public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode): ValueListInterface;
1414

15-
/**
16-
* @return bool
17-
* @deprecated
18-
*/
19-
public function isDefinite(): bool;
20-
2115
public function getProperties(): QueryPropertiesInterface;
2216
}

tests/Parser/TranslationSchemeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testAllMethods_AssembledWithParser_QueryWorksAsExpected(
2929
): void {
3030
$query = QueryFactory::create()->createQuery($path);
3131
// TODO: extract isDefinite test
32-
self::assertSame($isDefinite, $query->isDefinite());
32+
self::assertSame($isDefinite, $query->getProperties()->isDefinite());
3333

3434
$result = Processor::create()->select(
3535
$query,

tests/Query/Exception/IsDefiniteFlagNotFoundExceptionTest.php renamed to tests/Query/Exception/PropertiesNotFoundExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
/**
1111
* @covers \Remorhaz\JSON\Path\Query\Exception\PropertiesNotFoundException
1212
*/
13-
class IsDefiniteFlagNotFoundExceptionTest extends TestCase
13+
class PropertiesNotFoundExceptionTest extends TestCase
1414
{
1515

1616
public function testGetMessage_Constructed_ReturnsMatchingValue(): void
1717
{
1818
$exception = new PropertiesNotFoundException;
19-
self::assertSame('IsDefinite flag is accessed before being set', $exception->getMessage());
19+
self::assertSame('Properties are accessed before being set', $exception->getMessage());
2020
}
2121

2222
public function testGetCode_Always_ReturnsZero(): void
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Remorhaz\JSON\Path\Test\Query;
5+
6+
use PHPUnit\Framework\TestCase;
7+
use Remorhaz\JSON\Path\Query\QueryProperties;
8+
9+
/**
10+
* @covers \Remorhaz\JSON\Path\Query\QueryProperties
11+
*/
12+
class QueryPropertiesTest extends TestCase
13+
{
14+
15+
/**
16+
* @param bool $isDefinite
17+
* @param bool $expectedValue
18+
* @dataProvider providerIsDefinite
19+
*/
20+
public function testIsDefinite_ConstructedWithIsDefiniteFlag_ReturnsSameValue(
21+
bool $isDefinite,
22+
bool $expectedValue
23+
): void {
24+
$properties = new QueryProperties($isDefinite, false);
25+
self::assertSame($expectedValue, $properties->isDefinite());
26+
}
27+
28+
public function providerIsDefinite(): array
29+
{
30+
return [
31+
'TRUE' => [true, true],
32+
'FALSE' => [false, false],
33+
];
34+
}
35+
36+
/**
37+
* @param bool $isPath
38+
* @param bool $expectedValue
39+
* @dataProvider providerIsPath
40+
*/
41+
public function testIsPath_ConstructedWithIsPathFlag_ReturnsSameValue(
42+
bool $isPath,
43+
bool $expectedValue
44+
): void {
45+
$properties = new QueryProperties(false, $isPath);
46+
self::assertSame($expectedValue, $properties->isPath());
47+
}
48+
49+
public function providerIsPath(): array
50+
{
51+
return [
52+
'TRUE' => [true, true],
53+
'FALSE' => [false, false],
54+
];
55+
}
56+
}

0 commit comments

Comments
 (0)