Issues (19)

src/Backend/ExtAst.php (5 issues)

1
<?php
2
declare(strict_types=1);
3
4
namespace Bdelespierre\LaravelBladeLinter\Backend;
5
6
use Bdelespierre\LaravelBladeLinter\Backend;
7
use Bdelespierre\LaravelBladeLinter\ErrorRecord;
8
use function ast\parse_code;
0 ignored issues
show
The function ast\parse_code was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
9
10
final class ExtAst implements Backend
11
{
12
    public function __construct(
13
        private int $astVersion = 85
14
    ) {
15
    }
16
17
    /**
18
     * @param \SplFileInfo $file
19
     * @param string $code
20
     * @return list<ErrorRecord>
0 ignored issues
show
The type Bdelespierre\LaravelBladeLinter\Backend\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
     */
22
    public function analyze(\SplFileInfo $file, string $code): array
23
    {
24
        try {
25
            parse_code($code, $this->astVersion);
0 ignored issues
show
The function parse_code was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            /** @scrutinizer ignore-call */ 
26
            parse_code($code, $this->astVersion);
Loading history...
26
        } catch (\ParseError $e) {
27
            return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(new Bdelesp...name(), $e->getLine())) returns the type array<integer,Bdelespier...ladeLinter\ErrorRecord> which is incompatible with the documented return type Bdelespierre\LaravelBladeLinter\Backend\list.
Loading history...
28
                new ErrorRecord(
29
                    'Parse error: ' . $e->getMessage(),
30
                    $file->getPathname(),
31
                    $e->getLine()
32
                )
33
            ];
34
        }
35
36
        return [];
0 ignored issues
show
Bug Best Practice introduced by
The expression return array() returns the type array which is incompatible with the documented return type Bdelespierre\LaravelBladeLinter\Backend\list.
Loading history...
37
    }
38
39
    public static function name(): string
40
    {
41
        return 'ext-ast';
42
    }
43
}
44