Skip to content

Commit 1a3bfac

Browse files
authored
Merge pull request #375 from markstory/fix-build
Fix build
2 parents dca5354 + 740dc62 commit 1a3bfac

File tree

14 files changed

+44
-29
lines changed

14 files changed

+44
-29
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: CI
33
on:
44
push:
55
branches:
6-
- master
76
- 5.x
87
pull_request:
98
branches:

.phive/phars.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="1.10.35" installed="1.10.35" location="./tools/phpstan" copy="false"/>
4-
<phar name="psalm" version="5.15.0" installed="5.15.0" location="./tools/psalm" copy="false"/>
3+
<phar name="phpstan" version="~2.0" installed="2.1.12" location="./tools/phpstan" copy="false"/>
54
</phive>

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@
4848
"scripts": {
4949
"check": [
5050
"@cs-check",
51-
"@test",
52-
"@stan"
51+
"@stan",
52+
"@test"
5353
],
5454
"cs-check": "phpcs -p src/ tests/TestCase/",
5555
"cs-fix": "phpcbf src/ tests/TestCase/",
5656
"test": "phpunit --stderr",
5757
"stan": "phpstan analyse src/ && psalm --show-info=false",
5858
"stan-test": "phpstan analyse tests/",
59-
"psalm": "psalm",
60-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~1.8 vimeo/psalm:~4.23 && mv composer.backup composer.json",
59+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:~2.0 && mv composer.backup composer.json",
6160
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
6261
},
6362
"prefer-stable": true,

phpstan.neon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 6
6-
checkMissingIterableValueType: false
5+
level: 7
76
bootstrapFiles:
87
- tests/bootstrap.php
98
paths:
109
- src/
10+
ignoreErrors:
11+
- identifier: missingType.iterableValue

src/Command/BuildCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function execute(Arguments $args, ConsoleIo $io): int
5858
{
5959
$configFinder = new ConfigFinder();
6060
$config = $configFinder->loadAll(
61-
$args->getOption('config'),
62-
(bool)$args->getOption('skip-plugins')
61+
(string)$args->getOption('config'),
62+
(bool)$args->getOption('skip-plugins'),
6363
);
6464
$factory = new Factory($config);
6565

src/Command/ClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
4848
public function execute(Arguments $args, ConsoleIo $io): int
4949
{
5050
$configFinder = new ConfigFinder();
51-
$config = $configFinder->loadAll($args->getOption('config'));
51+
$config = $configFinder->loadAll((string)$args->getOption('config'));
5252
$factory = new Factory($config);
5353

5454
$io->verbose('Clearing build timestamp.');

src/Filter/ImportInline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function scanner(): AssetScanner
2525
}
2626
$this->scanner = new AssetScanner(
2727
$this->_settings['paths'],
28-
$this->_settings['theme'] ?? null
28+
$this->_settings['theme'] ?? null,
2929
);
3030

3131
return $this->scanner;

src/Filter/Sprockets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function _scanner(): AssetScanner
2525
}
2626
$this->_scanner = new AssetScanner(
2727
$this->_settings['paths'],
28-
$this->_settings['theme'] ?? null
28+
$this->_settings['theme'] ?? null,
2929
);
3030

3131
return $this->_scanner;

src/Middleware/AssetCompressMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6060

6161
// Make sure the request looks like an asset.
6262
$targetName = $this->getName($config, $request->getUri()->getPath());
63-
if (!$targetName) {
63+
if (!is_string($targetName)) {
6464
return $handler->handle($request);
6565
}
6666

src/View/Helper/AssetCompressHelper.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function css(string $file, array $options = []): ?string
175175
$file = $this->_addExt($file, '.css');
176176
if (!$this->collection()->contains($file)) {
177177
throw new RuntimeException(
178-
"Cannot create a stylesheet tag for a '$file'. That build is not defined."
178+
"Cannot create a stylesheet tag for a '$file'. That build is not defined.",
179179
);
180180
}
181181
$output = '';
@@ -218,7 +218,7 @@ public function script(string $file, array $options = []): ?string
218218
$file = $this->_addExt($file, '.js');
219219
if (!$this->collection()->contains($file)) {
220220
throw new RuntimeException(
221-
"Cannot create a script tag for a '$file'. That build is not defined."
221+
"Cannot create a script tag for a '$file'. That build is not defined.",
222222
);
223223
}
224224
$output = '';
@@ -250,7 +250,9 @@ protected function _relativizePath(string $path): string
250250
{
251251
$plugins = Plugin::loaded();
252252
$index = array_search('AssetCompress', $plugins);
253-
unset($plugins[$index]);
253+
if ($index !== false) {
254+
unset($plugins[$index]);
255+
}
254256

255257
foreach ($plugins as $plugin) {
256258
$pluginPath = Plugin::path($plugin) . 'webroot';

tests/TestCase/Command/AssetCompressCommandsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public function setUp(): void
2626
mkdir(WWW_ROOT . 'cache_js');
2727
mkdir(WWW_ROOT . 'cache_css');
2828
mkdir(WWW_ROOT . 'cache_svg');
29-
30-
$this->loadPlugins(['AssetCompress']);
3129
}
3230

3331
/**

tests/TestCase/FactoryTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
class FactoryTest extends TestCase
1313
{
14+
protected $config;
15+
protected $integrationFile;
16+
protected $themedFile;
17+
protected $pluginFile;
18+
protected $overrideFile;
19+
protected $timestampFile;
20+
1421
public function setUp(): void
1522
{
1623
parent::setUp();
@@ -85,7 +92,7 @@ public function testAssetCollection()
8592
$this->assertEquals(
8693
str_replace(DS, '/', WWW_ROOT . 'cache_js/libs.js'),
8794
str_replace(DS, '/', $asset->path()),
88-
'Asset path is wrong'
95+
'Asset path is wrong',
8996
);
9097
}
9198

@@ -112,7 +119,7 @@ public function testAssetCollectionThemed()
112119
$this->assertCount(1, $files);
113120
$this->assertEquals(
114121
str_replace(DS, '/', APP . 'Plugin/Red/webroot/theme.css'),
115-
str_replace(DS, '/', $files[0]->path())
122+
str_replace(DS, '/', $files[0]->path()),
116123
);
117124
}
118125

@@ -138,15 +145,15 @@ public function testAssetCollectionPlugins()
138145
$this->assertCount(1, $asset->files());
139146
$this->assertEquals(
140147
str_replace('/', DS, APP . 'Plugin/TestAsset/webroot/plugin.js'),
141-
$asset->files()[0]->path()
148+
$asset->files()[0]->path(),
142149
);
143150

144151
$asset = $collection->get('plugins.css');
145152
$files = $asset->files();
146153
$this->assertCount(2, $files);
147154
$this->assertEquals(
148155
APP . 'css' . DS . 'nav.css',
149-
$asset->files()[0]->path()
156+
$asset->files()[0]->path(),
150157
);
151158
}
152159

@@ -163,15 +170,15 @@ public function testAssetCreationWithAdditionalPath()
163170
$this->assertCount(3, $files);
164171
$this->assertEquals(
165172
APP . 'js' . DS . 'base.js',
166-
$files[0]->path()
173+
$files[0]->path(),
167174
);
168175
$this->assertEquals(
169176
APP . 'js' . DS . 'library_file.js',
170-
$files[1]->path()
177+
$files[1]->path(),
171178
);
172179
$this->assertEquals(
173180
APP . 'js' . DS . 'classes' . DS . 'base_class.js',
174-
$files[2]->path()
181+
$files[2]->path(),
175182
);
176183
}
177184

tests/TestCase/Middleware/AssetCompressMiddlewareTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class AssetCompressMiddlewareTest extends TestCase
1414
{
1515
protected $nextInvoked = false;
1616

17+
protected $testConfig;
18+
protected $middleware;
19+
protected $request;
20+
protected $response;
21+
protected $handler;
22+
1723
/**
1824
* Setup method
1925
*

tests/TestCase/View/Helper/AssetCompressHelperTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
class AssetCompressHelperTest extends TestCase
1616
{
17+
protected $_testFiles;
18+
protected $View;
19+
protected $Helper;
20+
1721
/**
1822
* start a test
1923
*
@@ -325,13 +329,13 @@ public function testUrlFullOption()
325329
$result = $this->Helper->url('libs.js', ['full' => true]);
326330
$this->assertEquals(
327331
'http://localhost/cache_js/libs.js',
328-
$result
332+
$result,
329333
);
330334

331335
$result = $this->Helper->url('libs.js', true);
332336
$this->assertEquals(
333337
'http://localhost/cache_js/libs.js',
334-
$result
338+
$result,
335339
);
336340
}
337341

0 commit comments

Comments
 (0)