Skip to content

Commit 8a9168d

Browse files
Merge pull request #7556 from getkirby/v6/refact/php-cleanup
Remove unnecessary PHP code
2 parents e96566c + d638802 commit 8a9168d

File tree

20 files changed

+12
-91
lines changed

20 files changed

+12
-91
lines changed

src/Filesystem/Mime.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ function_exists('finfo_file') === true &&
188188
) {
189189
$finfo = finfo_open(FILEINFO_MIME_TYPE);
190190
$mime = finfo_file($finfo, $file);
191-
finfo_close($finfo);
192191
return $mime;
193192
}
194193

src/Http/Remote.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ public function fetch(): static
255255
throw new Exception($this->errorMessage, $this->errorCode);
256256
}
257257

258-
curl_close($this->curl);
259-
260258
return $this;
261259
}
262260

src/Image/QrCode.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public function toDataUri(
7272

7373
ob_start();
7474
imagepng($image);
75-
imagedestroy($image);
7675
$data = ob_get_contents();
7776
ob_end_clean();
7877

tests/Cache/CacheTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public function testConstruct(): void
1818
public function testKey(): void
1919
{
2020
$method = new ReflectionMethod(Cache::class, 'key');
21-
$method->setAccessible(true);
2221

2322
$cache = new TestCache();
2423
$this->assertSame('foo', $method->invoke($cache, 'foo'));
@@ -83,7 +82,6 @@ public function testEnabled(): void
8382
public function testExpiration(): void
8483
{
8584
$method = new ReflectionMethod(Cache::class, 'expiration');
86-
$method->setAccessible(true);
8785

8886
$cache = new TestCache();
8987
$this->assertSame(0, $method->invoke($cache));

tests/Cache/FileCacheTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function testEnabledNotWritable(): void
6161
public function testFile(): void
6262
{
6363
$method = new ReflectionMethod(FileCache::class, 'file');
64-
$method->setAccessible(true);
6564

6665
$cache = new FileCache([
6766
'root' => $root = static::TMP

tests/Cms/App/AppErrorsTest.php

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function setUp(): void
3333
public function tearDown(): void
3434
{
3535
$unsetMethod = new ReflectionMethod(App::class, 'unsetWhoopsHandler');
36-
$unsetMethod->setAccessible(true);
3736

3837
$app = App::instance();
3938
$unsetMethod->invoke($app);
@@ -60,7 +59,6 @@ public function testExceptionHook(): void
6059
]);
6160

6261
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
63-
$whoopsMethod->setAccessible(true);
6462

6563
$whoops = $whoopsMethod->invoke($app);
6664
$handler = $whoops->getHandlers()[1];
@@ -90,7 +88,6 @@ public function testExceptionHookDisableLogging(): void
9088
]);
9189

9290
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
93-
$whoopsMethod->setAccessible(true);
9491

9592
$whoops = $whoopsMethod->invoke($app);
9693
$handler = $whoops->getHandlers()[1];
@@ -109,10 +106,7 @@ public function testExceptionHookDisableLogging(): void
109106
public function testHandleCliErrors(): void
110107
{
111108
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
112-
$whoopsMethod->setAccessible(true);
113-
114-
$testMethod = new ReflectionMethod(App::class, 'handleCliErrors');
115-
$testMethod->setAccessible(true);
109+
$testMethod = new ReflectionMethod(App::class, 'handleCliErrors');
116110

117111
$app = App::instance();
118112
$whoops = $whoopsMethod->invoke($app);
@@ -127,10 +121,7 @@ public function testHandleCliErrors(): void
127121
public function testHandleErrors1(): void
128122
{
129123
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
130-
$whoopsMethod->setAccessible(true);
131-
132-
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
133-
$testMethod->setAccessible(true);
124+
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
134125

135126
$app = $this->app->clone([
136127
'cli' => true
@@ -148,10 +139,7 @@ public function testHandleErrors1(): void
148139
public function testHandleErrors2(): void
149140
{
150141
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
151-
$whoopsMethod->setAccessible(true);
152-
153-
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
154-
$testMethod->setAccessible(true);
142+
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
155143

156144
$app = $this->app->clone([
157145
'cli' => false,
@@ -172,10 +160,7 @@ public function testHandleErrors2(): void
172160
public function testHandleErrors3(): void
173161
{
174162
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
175-
$whoopsMethod->setAccessible(true);
176-
177-
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
178-
$testMethod->setAccessible(true);
163+
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
179164

180165
$app = $this->app->clone([
181166
'cli' => false,
@@ -201,10 +186,7 @@ public function testHandleErrors3(): void
201186
public function testHandleErrorsGlobalSetting(): void
202187
{
203188
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
204-
$whoopsMethod->setAccessible(true);
205-
206-
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
207-
$testMethod->setAccessible(true);
189+
$testMethod = new ReflectionMethod(App::class, 'handleErrors');
208190

209191
$whoopsEnabled = $whoopsMethod->invoke($this->app);
210192
$whoopsDisabled = $whoopsMethod->invoke($this->originalApp);
@@ -230,14 +212,9 @@ public function testHandleErrorsGlobalSetting(): void
230212

231213
public function testHandleHtmlErrors(): void
232214
{
233-
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
234-
$whoopsMethod->setAccessible(true);
235-
215+
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
236216
$optionsMethod = new ReflectionMethod(App::class, 'optionsFromProps');
237-
$optionsMethod->setAccessible(true);
238-
239-
$testMethod = new ReflectionMethod(App::class, 'handleHtmlErrors');
240-
$testMethod->setAccessible(true);
217+
$testMethod = new ReflectionMethod(App::class, 'handleHtmlErrors');
241218

242219
$app = App::instance();
243220
$whoops = $whoopsMethod->invoke($app);
@@ -304,14 +281,9 @@ public function testHandleHtmlErrors(): void
304281

305282
public function testHandleJsonErrors(): void
306283
{
307-
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
308-
$whoopsMethod->setAccessible(true);
309-
284+
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
310285
$optionsMethod = new ReflectionMethod(App::class, 'optionsFromProps');
311-
$optionsMethod->setAccessible(true);
312-
313-
$testMethod = new ReflectionMethod(App::class, 'handleJsonErrors');
314-
$testMethod->setAccessible(true);
286+
$testMethod = new ReflectionMethod(App::class, 'handleJsonErrors');
315287

316288
$app = App::instance();
317289
$whoops = $whoopsMethod->invoke($app);
@@ -381,13 +353,8 @@ public function testHandleJsonErrors(): void
381353
public function testSetUnsetWhoopsHandler(): void
382354
{
383355
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
384-
$whoopsMethod->setAccessible(true);
385-
386-
$setMethod = new ReflectionMethod(App::class, 'setWhoopsHandler');
387-
$setMethod->setAccessible(true);
388-
389-
$unsetMethod = new ReflectionMethod(App::class, 'unsetWhoopsHandler');
390-
$unsetMethod->setAccessible(true);
356+
$setMethod = new ReflectionMethod(App::class, 'setWhoopsHandler');
357+
$unsetMethod = new ReflectionMethod(App::class, 'unsetWhoopsHandler');
391358

392359
$app = App::instance();
393360
$whoops = $whoopsMethod->invoke($app);
@@ -414,7 +381,6 @@ public function testSetUnsetWhoopsHandler(): void
414381
public function testWhoops(): void
415382
{
416383
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
417-
$whoopsMethod->setAccessible(true);
418384

419385
$app = App::instance();
420386

tests/Cms/App/AppTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,7 @@ public function testOptionsOnReady(): void
597597
'slugs' => 'de'
598598
], $app->options());
599599

600-
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
601-
$whoopsMethod->setAccessible(true);
600+
$whoopsMethod = new ReflectionMethod(App::class, 'whoops');
602601
$whoopsHandler = $whoopsMethod->invoke($app)->getHandlers()[0];
603602
$this->assertInstanceOf(PrettyPageHandler::class, $whoopsHandler);
604603

tests/Cms/System/LicenseTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ public function testNormalizeDomain(string $domain, string $expected): void
260260
{
261261
$reflector = new ReflectionClass(License::class);
262262
$normalize = $reflector->getMethod('normalizeDomain');
263-
$normalize->setAccessible(true);
264263

265264
$license = new License();
266265

tests/Database/DbTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public function testConnection(): void
9292
public function testTable(): void
9393
{
9494
$tableProp = new ReflectionProperty(Query::class, 'table');
95-
$tableProp->setAccessible(true);
9695

9796
$query = Db::table('users');
9897
$this->assertInstanceOf(Query::class, $query);

tests/Image/Darkroom/GdLibTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public function testSharpen(): void
7070
$gd = new GdLib();
7171

7272
$method = new ReflectionMethod($gd::class, 'sharpen');
73-
$method->setAccessible(true);
7473

7574
$simpleImage = new SimpleImageMock();
7675

@@ -86,7 +85,6 @@ public function testSharpenWithoutValue(): void
8685
$gd = new GdLib();
8786

8887
$method = new ReflectionMethod($gd::class, 'sharpen');
89-
$method->setAccessible(true);
9088

9189
$simpleImage = new SimpleImageMock();
9290

0 commit comments

Comments
 (0)