Skip to content

Commit 29c98e1

Browse files
authored
Merge pull request #135 from FriendsOfCake/fixes
Remove deprecations, fix up PHPStan level 8
2 parents 3e5124f + 3befc18 commit 29c98e1

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
}
4545
],
4646
"require":{
47-
"cakephp/cakephp": "^4.0"
47+
"cakephp/cakephp": "^4.2"
4848
},
4949
"require-dev": {
50-
"phpunit/phpunit": "~8.5.0",
50+
"phpunit/phpunit": "^9.5.0",
5151
"cakephp/cakephp-codesniffer": "^4.0"
5252
},
5353
"autoload": {
@@ -77,7 +77,12 @@
7777
"stan": "phpstan analyse && psalm",
7878
"phpstan": "phpstan analyse",
7979
"psalm": "psalm --show-info=false",
80-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 vimeo/psalm:^3.7 && mv composer.backup composer.json",
80+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^1.0.0 vimeo/psalm:^5.0 && mv composer.backup composer.json",
8181
"test-coverage": "phpunit --coverage-clover=clover.xml"
82+
},
83+
"config": {
84+
"allow-plugins": {
85+
"dealerdirect/phpcodesniffer-composer-installer": true
86+
}
8287
}
8388
}

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
2-
level: 6
2+
level: 8
33
checkMissingIterableValueType: false
44
paths:
5-
- src
5+
- src/
66
bootstrapFiles:
77
- tests/bootstrap.php

src/View/CsvView.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace CsvView\View;
55

6+
use Cake\Core\Exception\CakeException;
67
use Cake\Datasource\EntityInterface;
78
use Cake\Utility\Hash;
89
use Cake\View\SerializedView;
@@ -304,7 +305,11 @@ protected function _generateRow(?array $row = null)
304305
}
305306

306307
if ($fp === false) {
307-
$fp = fopen('php://temp', 'r+');
308+
$stream = 'php://temp';
309+
$fp = fopen($stream, 'r+');
310+
if ($fp === false) {
311+
throw new CakeException(sprintf('Cannot open stream `%s`', $stream));
312+
}
308313

309314
$setSeparator = $this->getConfig('setSeparator');
310315
if ($setSeparator) {

tests/TestCase/View/CsvViewTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use Cake\Http\Response;
77
use Cake\Http\ServerRequest as Request;
8-
use Cake\I18n\Time;
8+
use Cake\I18n\FrozenTime;
99
use Cake\ORM\TableRegistry;
1010
use Cake\TestSuite\TestCase;
1111
use CsvView\View\CsvView;
@@ -34,7 +34,7 @@ class CsvViewTest extends TestCase
3434

3535
public function setUp(): void
3636
{
37-
Time::setToStringFormat('yyyy-MM-dd HH:mm:ss');
37+
FrozenTime::setToStringFormat('yyyy-MM-dd HH:mm:ss');
3838

3939
$this->request = new Request();
4040
$this->response = new Response();
@@ -267,7 +267,7 @@ public function testRenderViaExtract()
267267
[
268268
'User' => [
269269
'username' => 'jose',
270-
'created' => new Time('2010-01-05'),
270+
'created' => new FrozenTime('2010-01-05'),
271271
],
272272
'Item' => [
273273
'name' => 'beach',
@@ -343,7 +343,7 @@ public function testRenderViaExtractWithCallable()
343343
$data = [
344344
[
345345
'username' => 'jose',
346-
'created' => new Time('2010-01-05'),
346+
'created' => new FrozenTime('2010-01-05'),
347347
'item' => [
348348
'name' => 'beach',
349349
],

0 commit comments

Comments
 (0)