Skip to content

Commit ca6f1ab

Browse files
committed
wip
1 parent 59fe2f1 commit ca6f1ab

File tree

7 files changed

+69
-65
lines changed

7 files changed

+69
-65
lines changed

.github/workflows/formats.yml

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
name: Formats
22

3-
on: ["push", "pull_request"]
3+
on: [ "push", "pull_request" ]
44

55
jobs:
66
formats:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
fail-fast: true
1010
matrix:
11-
os: [ubuntu-latest]
12-
php: [8.2]
13-
stability: [prefer-stable]
11+
os: [ ubuntu-latest ]
12+
php: [ 8.4 ]
13+
stability: [ prefer-stable ]
1414

1515
name: Formats php@${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.stability }}
1616

1717
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
18+
- name: Checkout
19+
uses: actions/checkout@v4
2020

21-
- name: Setup PHP
22-
uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: ${{ matrix.php }}
25-
coverage: none
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: none
2626

27-
- name: Install Composer dependencies
28-
run: composer update --${{ matrix.stability }} --no-interaction
27+
- name: Install Composer dependencies
28+
run: composer update --${{ matrix.stability }} --no-interaction
2929

30-
- name: Coding Style Checks
31-
run: composer test:lint
30+
- name: Coding Style Checks
31+
run: composer test:lint
3232

33-
- name: Type Checks
34-
run: composer test:types
33+
- name: Type Checks
34+
run: composer test:types

.github/workflows/tests.yml

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
name: Tests
22

3-
on: ["push", "pull_request"]
3+
on: [ "push", "pull_request" ]
44

55
jobs:
66
tests:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
fail-fast: true
1010
matrix:
11-
os: [ubuntu-latest]
12-
php: ["8.0", 8.1, 8.2]
13-
stability: [prefer-lowest, prefer-stable]
11+
os: [ ubuntu-latest ]
12+
php: [ "8.0", 8.1, 8.2, 8.3, 8.4 ]
13+
laravel: [ 11.*, 10.*, 9.*, 8.*, 7.* ]
14+
stability: [ prefer-lowest, prefer-stable ]
15+
exclude:
16+
- php: 8.1
17+
laravel: 11.*
1418

1519
name: Tests php@${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.stability }}
1620

1721
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
22+
- name: Checkout
23+
uses: actions/checkout@v4
2024

21-
- name: Setup PHP
22-
uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: ${{ matrix.php }}
25-
coverage: pcov
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: pcov
2630

27-
- name: Install Composer dependencies
28-
run: composer update --${{ matrix.stability }} --no-interaction
31+
- name: Install Composer dependencies
32+
run: composer update --${{ matrix.stability }} --no-interaction
2933

30-
- name: Unit Tests
31-
run: composer test:unit
34+
- name: Unit Tests
35+
run: composer test:unit

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
},
2222
"require-dev": {
2323
"laravel/pint": "^1.2.0",
24-
"nunomaduro/collision": "^6.0",
25-
"orchestra/testbench": "^7.0",
26-
"pestphp/pest": "^1.0",
27-
"pestphp/pest-plugin-laravel": "^1.3",
24+
"nunomaduro/collision": "^8.0",
25+
"orchestra/testbench": "^9.0",
26+
"pestphp/pest": "^3.0",
27+
"pestphp/pest-plugin-laravel": "^3.0",
2828
"phpstan/extension-installer": "^1.2",
29-
"phpstan/phpstan": "^1.8.6",
30-
"phpstan/phpstan-strict-rules": "^1.4",
31-
"rector/rector": "^0.15.0",
32-
"symfony/var-dumper": "^6.0.0"
29+
"phpstan/phpstan": "^2.0",
30+
"phpstan/phpstan-strict-rules": "^2.0",
31+
"rector/rector": "^2.0",
32+
"symfony/var-dumper": "^7.0.0"
3333
},
3434
"autoload": {
3535
"psr-4": {

phpunit.xml.dist

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
colors="true"
55
>
6-
<coverage>
7-
<include>
8-
<directory suffix=".php">./src</directory>
9-
</include>
10-
</coverage>
116
<testsuites>
127
<testsuite name="default">
138
<directory suffix=".php">./tests</directory>
149
</testsuite>
1510
</testsuites>
11+
<source>
12+
<include>
13+
<directory>./src</directory>
14+
</include>
15+
</source>
1616
</phpunit>

rector.php

-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
declare(strict_types=1);
44

5-
use Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector;
6-
use Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector;
7-
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
85
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
96
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
107
use Rector\Config\RectorConfig;
11-
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
128
use Rector\Set\ValueObject\LevelSetList;
139
use Rector\Set\ValueObject\SetList;
1410

@@ -31,9 +27,5 @@
3127
$rectorConfig->skip([
3228
EncapsedStringsToSprintfRector::class,
3329
WrapEncapsedVariableInCurlyBracesRector::class,
34-
VarConstantCommentRector::class,
35-
ChangeAndIfToEarlyReturnRector::class,
36-
SplitListAssignToSeparateLineRector::class,
37-
StaticClosureRector::class,
3830
]);
3931
};

src/Jql.php

+8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function orWhere(string|Closure $column, mixed $operator = Operator::EQUA
5959
return $this;
6060
}
6161

62+
/**
63+
* @param callable(self, mixed): ?self $callback
64+
*/
6265
public function when(mixed $value, callable $callback): self
6366
{
6467
$value = $value instanceof Closure ? $value($this) : $value;
@@ -70,6 +73,9 @@ public function when(mixed $value, callable $callback): self
7073
return $this;
7174
}
7275

76+
/**
77+
* @param callable(self, mixed): ?self $callback
78+
*/
7379
public function whenNot(mixed $value, callable $callback): self
7480
{
7581
$value = $value instanceof Closure ? $value($this) : $value;
@@ -128,9 +134,11 @@ private function quote(string $operator, mixed $value): string
128134
is_array($value) ? $value : [$value],
129135
function ($prev, $current): string {
130136
if ($prev === null) {
137+
// @phpstan-ignore argument.type
131138
return '"'.str_replace('"', '\\"', $current).'"';
132139
}
133140

141+
// @phpstan-ignore argument.type
134142
return $prev.', "'.str_replace('"', '\\"', $current).'"';
135143
}
136144
);

tests/Jql.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use JqlBuilder\Jql;
44

55
it('can generate query', function () {
6-
$builder = new Jql();
6+
$builder = new Jql;
77

88
$query = $builder->where('project', '=', 'MY PROJECT')->getQuery();
99

1010
$expected = 'project = "MY PROJECT"';
1111

1212
expect($query)->toBe($expected);
1313

14-
$builder = new Jql();
14+
$builder = new Jql;
1515

1616
$query = $builder
1717
->where('project', '=', 'MY PROJECT')
@@ -28,7 +28,7 @@
2828

2929
expect($query)->toBe($expected);
3030

31-
$builder = new Jql();
31+
$builder = new Jql;
3232

3333
$query = (string) $builder
3434
->where('project', 'MY PROJECT')
@@ -48,7 +48,7 @@
4848
});
4949

5050
it('can generate raw query', function () {
51-
$query = (string) (new Jql())->rawQuery('project = "MY PROJECT"');
51+
$query = (string) (new Jql)->rawQuery('project = "MY PROJECT"');
5252

5353
$expected = 'project = "MY PROJECT"';
5454

@@ -57,7 +57,7 @@
5757

5858
it('can generate query with grouped conditions', function () {
5959
$actualQueries = [
60-
(new Jql())->where('creator', '=', '1646667083862@mailinator.com')
60+
(new Jql)->where('creator', '=', '1646667083862@mailinator.com')
6161
->where(function (Jql $builder) {
6262
$builder->where('project', '=', 'A')
6363
->where('status', '=', '"Closed"');
@@ -66,7 +66,7 @@
6666
$builder->where('project', '=', '"B"')
6767
->where('status', '!=', 'Closed');
6868
})->getQuery(),
69-
(new Jql())->where(function (Jql $builder) {
69+
(new Jql)->where(function (Jql $builder) {
7070
$builder->where('project', '=', 'A')
7171
->where('status', '=', 'Closed');
7272
})->orWhere(function (Jql $builder) {
@@ -84,15 +84,15 @@
8484
});
8585

8686
it('will quote custom field that contains spaces', function () {
87-
$query = (new Jql())->where('project name', '=', 'MY PROJECT')->getQuery();
87+
$query = (new Jql)->where('project name', '=', 'MY PROJECT')->getQuery();
8888

8989
$expected = '"project name" = "MY PROJECT"';
9090

9191
expect($query)->toBe($expected);
9292
});
9393

9494
it('can add macro', function () {
95-
$builder = new Jql();
95+
$builder = new Jql;
9696

9797
$builder::macro('whereCustom', function (mixed $value) {
9898
/** @var Jql $this */
@@ -108,15 +108,15 @@
108108
});
109109

110110
it('will throw exception when invalid boolean passed', function () {
111-
(new Jql())->where('project', '=', 'MY PROJECT', '=');
111+
(new Jql)->where('project', '=', 'MY PROJECT', '=');
112112
})->throws(InvalidArgumentException::class, 'Illegal boolean [=] value. only [and, or] is acceptable');
113113

114114
it('will throw exception when invalid operator passed', function () {
115-
(new Jql())->where('project', '=', ['MY PROJECT']);
115+
(new Jql)->where('project', '=', ['MY PROJECT']);
116116
})->throws(InvalidArgumentException::class, 'Illegal operator [=] value. only [in, not in, was in, was not in] is acceptable when $value type is array');
117117

118118
it('can reset the current query', function () {
119-
$query = new Jql();
119+
$query = new Jql;
120120

121121
$query->where('project', 'name');
122122

0 commit comments

Comments
 (0)