Skip to content

Commit b8bc678

Browse files
committed
Fix SA
1 parent b54406d commit b8bc678

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
}
2222
],
2323
"require": {
24-
"php": "^7.3 || ^8.0"
24+
"php": "^7.3||^8.0"
2525
},
2626
"require-dev": {
2727
"codeigniter4/codeigniter4": "dev-develop",

src/Libraries/Assets.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use CodeIgniter\Config\Config;
2929
use CodeIgniter\Config\Services;
3030
use CodeIgniter\Router\RouteCollectionInterface;
31+
use Tatter\Assets\Config\Assets as AssetsConfig;
3132
use Tatter\Assets\Exceptions\AssetsException;
3233

3334
/*** CLASS ***/
@@ -36,14 +37,14 @@ class Assets
3637
/**
3738
* Our configuration instance.
3839
*
39-
* @var \Tatter\Assets\Config\Assets
40+
* @var AssetsConfig
4041
*/
4142
protected $config;
4243

4344
/**
4445
* Array of asset paths detected for the current route
4546
*
46-
* @var array
47+
* @var array|null
4748
*/
4849
protected $paths;
4950

@@ -61,7 +62,7 @@ class Assets
6162
* The URI to use for matching routed assets.
6263
* Defaults to uri_string()
6364
*
64-
* @var string
65+
* @var string|null
6566
*/
6667
protected $route;
6768

@@ -76,7 +77,7 @@ class Assets
7677
/**
7778
* Route collection used to determine the default route (if needed).
7879
*
79-
* @var CodeIgniter\Router\RouteCollectionInterface
80+
* @var RouteCollectionInterface|null
8081
*/
8182
protected $collection;
8283

@@ -147,7 +148,7 @@ public function getPaths($extension = null): array
147148
$tmpPaths = [];
148149
foreach ($this->paths as $path)
149150
{
150-
if (strtolower(pathinfo($path, PATHINFO_EXTENSION) == $extension))
151+
if (strtolower(pathinfo($path, PATHINFO_EXTENSION)) == $extension)
151152
{
152153
$tmpPaths[] = $path;
153154
}
@@ -197,16 +198,13 @@ public function tag(string $path)
197198
{
198199
case 'css':
199200
return link_tag($url);
200-
break;
201201

202202
case 'js':
203203
return script_tag($url);
204-
break;
205204

206205
case 'img':
207206
$alt = ucfirst(pathinfo($path, PATHINFO_FILENAME));
208207
return img($url, false, ['alt' => $alt]);
209-
break;
210208

211209
default:
212210
if ($this->config->silent)
@@ -281,7 +279,7 @@ protected function sanitizeRoute()
281279
if (Config::get('App')->negotiateLocale)
282280
{
283281
$route = explode('/', $this->route);
284-
if (count($route) && $route[0] == Services::request()->getLocale())
282+
if (count($route) && $route[0] == Services::request()->getLocale()) // @phpstan-ignore-line
285283
{
286284
unset($route[0]);
287285
}

src/Libraries/Manifests.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use CodeIgniter\Files\Exceptions\FileException;
55
use CodeIgniter\Files\Exceptions\FileNotFoundException;
66
use Tatter\Assets\Exceptions\ManifestsException;
7+
use stdClass;
78

89
class Manifests
910
{
@@ -294,7 +295,14 @@ public function expandPaths(&$resource, &$manifest)
294295
trim($resource->destination ?? '', '/') . '/';
295296
}
296297

297-
// Parse a resource and copy it to the determined destination
298+
/**
299+
* Parses a resource and copies it to
300+
* the determined destination.
301+
*
302+
* @param stdClass $resource
303+
*
304+
* @return bool
305+
*/
298306
protected function publishResource($resource): bool
299307
{
300308
// Validate the source
@@ -327,7 +335,15 @@ protected function publishResource($resource): bool
327335
return $this->publishFile($resource->source, $resource->destination);
328336
}
329337

330-
// Scan a directory and apply filters, publishing each file
338+
339+
/**
340+
* Scans a directory and applies filters,
341+
* publishing each file.
342+
*
343+
* @param stdClass $resource
344+
*
345+
* @return bool
346+
*/
331347
protected function publishResourceDirectory($resource): bool
332348
{
333349
$result = true;

tests/_support/ManifestsTestCase.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
<?php namespace Tests\Support;
22

33
use CodeIgniter\Test\CIUnitTestCase;
4+
use Tatter\Assets\Config\Assets as AssetsConfig;
45
use Tatter\Assets\Libraries\Manifests;
56
use org\bovigo\vfs\vfsStream;
7+
use org\bovigo\vfs\vfsStreamDirectory;
8+
use stdClass;
69

710
class ManifestsTestCase extends CIUnitTestCase
811
{
912
/**
10-
* @var \Tatter\Assets\Libraries\Manifests
13+
* @var vfsStreamDirectory|null
14+
*/
15+
protected $root;
16+
17+
/**
18+
* @var Manifests
1119
*/
1220
protected $manifests;
1321

1422
/**
15-
* @var \Tatter\Assets\Config\Assets
23+
* @var AssetsConfig
1624
*/
1725
protected $config;
1826

27+
/**
28+
* @var stdClass
29+
*/
30+
protected $testManifest;
31+
1932
public function setUp(): void
2033
{
2134
parent::setUp();

tests/manifests/PublishTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testExplicitFiles()
3434
];
3535

3636
$visitor = new vfsStreamStructureVisitor();
37-
$result = vfsStream::inspect($visitor, $this->root)->getStructure();
37+
$result = vfsStream::inspect($visitor, $this->root)->getStructure(); // @phpstan-ignore-line
3838

3939
$this->assertEquals($expected, $result);
4040
}
@@ -48,7 +48,7 @@ public function testRecursiveFlatten()
4848
$this->assertTrue($result);
4949

5050
$visitor = new vfsStreamStructureVisitor();
51-
$result = vfsStream::inspect($visitor, $this->root)->getStructure();
51+
$result = vfsStream::inspect($visitor, $this->root)->getStructure(); // @phpstan-ignore-line
5252

5353
$this->assertTrue($this->root->hasChild('assets/vendor/frontend/frontend.css'));
5454
$this->assertTrue($this->root->hasChild('assets/vendor/frontend/frontend.js'));

0 commit comments

Comments
 (0)