Skip to content

Commit d6280f1

Browse files
committed
chore: 🤖 Bump version
1 parent ecfdca4 commit d6280f1

File tree

8 files changed

+104
-64
lines changed

8 files changed

+104
-64
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ jobs:
2424
2525
strategy:
2626
matrix:
27-
php: ['8.0', 8.1, 8.2]
28-
lib:
29-
- { laravel: ^11.0 }
30-
- { laravel: ^10.0 }
31-
- { laravel: ^9.0 }
27+
php: [8.2, 8.3, 8.4]
28+
laravel:
29+
- ^13.0.x-dev
30+
- ^12.0
31+
- ^11.0
3232
exclude:
33-
- { php: 8.0, lib: { laravel: ^10.0 } }
34-
- { php: 8.0, lib: { laravel: ^11.0 } }
35-
- { php: 8.1, lib: { laravel: ^11.0 } }
33+
- php: 8.2
34+
laravel: ^13.0.x-dev
3635
include:
37-
- { lib: { laravel: ^9.0 }, phpstan: 1 }
38-
- { lib: { laravel: ^10.0 }, phpstan: 1 }
36+
- laravel: ^11.0
37+
larastan: 1
38+
- laravel: ^12.0
39+
larastan: 1
3940

4041
steps:
4142
- uses: actions/checkout@v3
@@ -47,20 +48,17 @@ jobs:
4748
coverage: xdebug
4849

4950
- name: Remove impossible dependencies
50-
if: ${{ matrix.phpstan != 1 }}
51+
if: ${{ matrix.larastan != 1 }}
5152
run: composer remove nunomaduro/larastan --dev --no-update
5253

5354
- name: Adjust Package Versions
5455
run: |
55-
composer require "laravel/framework:${{ matrix.lib.laravel }}" --dev
56+
composer require "laravel/framework:${{ matrix.laravel }}" --dev
5657
5758
- name: PHPStan
58-
if: ${{ matrix.phpstan == 1 }}
59+
if: ${{ matrix.larastan == 1 }}
5960
run: composer phpstan
6061

61-
- name: Clean up Larastan broken cache (Dirty hack for bugs)
62-
run: rm -f vendor/orchestra/testbench-core/laravel/vendor vendor/orchestra/testbench-core/laravel/bootstrap/cache/*.php
63-
6462
- run: mkdir -p build/logs
6563
- run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml
6664

@@ -69,7 +67,7 @@ jobs:
6967
env:
7068
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7169
COVERALLS_PARALLEL: 'true'
72-
COVERALLS_FLAG_NAME: 'laravel:${{ matrix.lib.laravel }}'
70+
COVERALLS_FLAG_NAME: 'laravel:${{ matrix.laravel }}'
7371
with:
7472
timeout_minutes: 1
7573
max_attempts: 3

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ Temporarily enable/disable PDO prepared statement emulation.
44

55
## Requirements
66

7-
| Package | Version | Mandatory |
8-
|:--------|:-----------------------------------------------------------------------------------------|:---------:|
9-
| PHP | <code>^8.0</code> ||
10-
| Laravel | <code>^9.0 &#124;&#124; ^10.0</code> ||
11-
| PHPStan | <code>&gt;=1.1</code> | |
7+
| Package | Version | Mandatory |
8+
|:--------|:--------------------------------------|:---------:|
9+
| PHP | <code>^8.2</code> ||
10+
| Laravel | <code>^11.0 &#124;&#124; ^12.0</code> ||
11+
| PHPStan | <code>&gt;=2.0</code> | |
12+
13+
> [!NOTE]
14+
> Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.
1215
1316
## Installing
1417

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
}
2323
},
2424
"require": {
25-
"php": "^8.0",
25+
"php": "^8.2",
2626
"ext-pdo": "*",
27-
"illuminate/database": "^9.0 || ^10.0 || ^11.0",
28-
"illuminate/support": "^9.0 || ^10.0 || ^11.0",
29-
"mpyw/unclosure": "^3.0"
27+
"illuminate/database": "^11.0 || ^12.0 || ^13.0",
28+
"illuminate/support": "^11.0 || ^12.0 || ^13.0",
29+
"mpyw/unclosure": "^3.1"
3030
},
3131
"require-dev": {
3232
"orchestra/testbench": "*",
33-
"orchestra/testbench-core": ">=7.0",
34-
"mockery/mockery": "^1.3.3 || ^1.4.2",
35-
"phpunit/phpunit": ">=9.5",
36-
"phpstan/phpstan": ">=1.1",
37-
"phpstan/extension-installer": ">=1.1",
38-
"nunomaduro/larastan": ">=1.0"
33+
"orchestra/testbench-core": ">=9.0",
34+
"mockery/mockery": "^1.6.12",
35+
"phpunit/phpunit": ">=11.0",
36+
"phpstan/phpstan": ">=2.0",
37+
"phpstan/extension-installer": ">=1.4",
38+
"nunomaduro/larastan": ">=3.1"
3939
},
4040
"scripts": {
4141
"test": "vendor/bin/phpunit",

phpstan/CallableParameter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
final class CallableParameter implements ParameterReflection
1111
{
1212
/**
13-
* @var CallableArgumentParameter[]
13+
* @var list<CallableArgumentParameter>
1414
*/
1515
private array $argumentParameters;
1616

1717
/**
18-
* @param CallableArgumentParameter[] $argumentParameters
18+
* @param list<CallableArgumentParameter> $argumentParameters
1919
*/
2020
public function __construct(array $argumentParameters)
2121
{

phpstan/ConnectionClassExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class ConnectionClassExtension implements MethodsClassReflectionExtension
1212
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
1313
{
1414
return \in_array($methodName, ['emulated', 'native'], true)
15-
&& \is_a($classReflection->getName(), ConnectionInterface::class, true);
15+
&& $classReflection->is(ConnectionInterface::class);
1616
}
1717

1818
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection

phpunit.xml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3-
<coverage>
2+
<phpunit backupGlobals="false"
3+
bootstrap="vendor/autoload.php"
4+
colors="true"
5+
processIsolation="false"
6+
stopOnFailure="false"
7+
cacheDirectory=".phpunit.cache"
8+
backupStaticProperties="false">
9+
10+
<source>
411
<include>
5-
<directory suffix=".php">src</directory>
12+
<directory>./src</directory>
613
</include>
7-
</coverage>
14+
</source>
15+
16+
<coverage/>
17+
818
<testsuites>
919
<testsuite name="Package Test Suite">
10-
<directory suffix="Test.php">./tests/</directory>
20+
<directory suffix="Test.php">./tests</directory>
1121
</testsuite>
1222
</testsuites>
1323
</phpunit>

src/EmulationController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class EmulationController
1515
/**
1616
* EmulationController constructor.
1717
*
18-
* @param null|\Closure|\PDO &...$pdos
18+
* @param \Closure|\PDO &...$pdos
1919
*/
20+
// @phpstan-ignore-next-line parameterByRef.unusedType
2021
public function __construct(&...$pdos)
2122
{
23+
// @phpstan-ignore arrayFilter.same
2224
$this->pdos = array_filter($pdos);
2325
}
2426

@@ -50,6 +52,7 @@ public function native(callable $callback, ...$args)
5052
*/
5153
public function switchingTo(bool $bool, callable $callback, ...$args)
5254
{
55+
// @phpstan-ignore assign.propertyType
5356
return Value::withEffectForEach($this->pdos, function (PDO $pdo) use ($bool) {
5457
$original = $pdo->getAttribute(PDO::ATTR_EMULATE_PREPARES);
5558
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $bool);

tests/IntegrationTest.php

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Mpyw\LaravelPdoEmulationControl\ConnectionServiceProvider;
88
use Orchestra\Testbench\TestCase;
99
use PDO;
10+
use PHPUnit\Framework\ExpectationFailedException;
1011

1112
class IntegrationTest extends TestCase
1213
{
@@ -36,13 +37,12 @@ protected function getEnvironmentSetUp($app): void
3637
/**
3738
* @param string $property
3839
* @return \Closure|\PDO
40+
* @noinspection PhpDocMissingThrowsInspection
3941
*/
40-
protected function getConnectionPropertyValue(string $property)
42+
protected function getConnectionPropertyValue(string $property): \Closure|\PDO
4143
{
42-
$db = DB::connection();
43-
$rp = new \ReflectionProperty($db, $property);
44-
$rp->setAccessible(true);
45-
$value = $rp->getValue($db);
44+
/** @noinspection PhpUnhandledExceptionInspection */
45+
$value = (new \ReflectionProperty($db = DB::connection(), $property))->getValue($db);
4646

4747
assert($value instanceof Closure || $value instanceof PDO);
4848

@@ -80,13 +80,39 @@ protected function getPackageProviders($app): array
8080
];
8181
}
8282

83+
/**
84+
* @throws ExpectationFailedException
85+
*
86+
* @phpstan-assert false $condition
87+
*/
88+
protected function assertPdoAttrTruthy(mixed $condition, string $message = ''): void {
89+
if (version_compare(PHP_VERSION, '8.4', '>=')) {
90+
$this->assertTrue($condition, $message);
91+
} else {
92+
$this->assertSame(1, $condition, $message);
93+
}
94+
}
95+
96+
/**
97+
* @throws ExpectationFailedException
98+
*
99+
* @phpstan-assert false $condition
100+
*/
101+
protected function assertPdoAttrFalsy(mixed $condition, string $message = ''): void {
102+
if (version_compare(PHP_VERSION, '8.4', '>=')) {
103+
$this->assertFalse($condition, $message);
104+
} else {
105+
$this->assertSame(0, $condition, $message);
106+
}
107+
}
108+
83109
public function testEagerEmulated(): void
84110
{
85111
$this->assertPdoNotResolved();
86112
$this->assertReadPdoNotResolved();
87113

88-
$this->assertSame(0, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
89-
$this->assertSame(0, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
114+
$this->assertPdoAttrFalsy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
115+
$this->assertPdoAttrFalsy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
90116

91117
$this->assertPdoResolved();
92118
$this->assertReadPdoResolved();
@@ -95,8 +121,8 @@ public function testEagerEmulated(): void
95121
$this->assertPdoResolved();
96122
$this->assertReadPdoResolved();
97123

98-
$this->assertSame(1, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
99-
$this->assertSame(1, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
124+
$this->assertPdoAttrTruthy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
125+
$this->assertPdoAttrTruthy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
100126

101127
$this->assertPdoResolved();
102128
$this->assertReadPdoResolved();
@@ -107,8 +133,8 @@ public function testEagerEmulated(): void
107133
$this->assertPdoResolved();
108134
$this->assertReadPdoResolved();
109135

110-
$this->assertSame(0, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
111-
$this->assertSame(0, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
136+
$this->assertPdoAttrFalsy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
137+
$this->assertPdoAttrFalsy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
112138

113139
$this->assertPdoResolved();
114140
$this->assertReadPdoResolved();
@@ -125,8 +151,8 @@ public function testLazyEmulated(): void
125151
$this->assertPdoNotResolved();
126152
$this->assertReadPdoNotResolved();
127153

128-
$this->assertSame(1, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
129-
$this->assertSame(1, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
154+
$this->assertPdoAttrTruthy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
155+
$this->assertPdoAttrTruthy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
130156

131157
$this->assertPdoResolved();
132158
$this->assertReadPdoResolved();
@@ -136,8 +162,8 @@ public function testLazyEmulated(): void
136162
$this->assertPdoResolved();
137163
$this->assertReadPdoResolved();
138164

139-
$this->assertSame(0, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
140-
$this->assertSame(0, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
165+
$this->assertPdoAttrFalsy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
166+
$this->assertPdoAttrFalsy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
141167

142168
$this->assertPdoResolved();
143169
$this->assertReadPdoResolved();
@@ -160,8 +186,8 @@ public function testCancelEmulated(): void
160186
$this->assertPdoNotResolved();
161187
$this->assertReadPdoNotResolved();
162188

163-
$this->assertSame(0, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
164-
$this->assertSame(0, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
189+
$this->assertPdoAttrFalsy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
190+
$this->assertPdoAttrFalsy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
165191

166192
$this->assertPdoResolved();
167193
$this->assertReadPdoResolved();
@@ -176,8 +202,8 @@ public function testEagerNative(): void
176202
$this->assertPdoNotResolved();
177203
$this->assertReadPdoNotResolved();
178204

179-
$this->assertSame(1, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
180-
$this->assertSame(1, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
205+
$this->assertPdoAttrTruthy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
206+
$this->assertPdoAttrTruthy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
181207

182208
$this->assertPdoResolved();
183209
$this->assertReadPdoResolved();
@@ -186,8 +212,8 @@ public function testEagerNative(): void
186212
$this->assertPdoResolved();
187213
$this->assertReadPdoResolved();
188214

189-
$this->assertSame(0, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
190-
$this->assertSame(0, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
215+
$this->assertPdoAttrFalsy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
216+
$this->assertPdoAttrFalsy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
191217

192218
$this->assertPdoResolved();
193219
$this->assertReadPdoResolved();
@@ -198,8 +224,8 @@ public function testEagerNative(): void
198224
$this->assertPdoResolved();
199225
$this->assertReadPdoResolved();
200226

201-
$this->assertSame(1, DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
202-
$this->assertSame(1, DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
227+
$this->assertPdoAttrTruthy(DB::getReadPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
228+
$this->assertPdoAttrTruthy(DB::getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES));
203229

204230
$this->assertPdoResolved();
205231
$this->assertReadPdoResolved();

0 commit comments

Comments
 (0)