Skip to content

Commit b0a3307

Browse files
author
github-ci
committed
fix+++++++++++
1 parent 7c540ca commit b0a3307

18 files changed

+348
-193
lines changed

src/Analyzer/AnalysisVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PhpPacker\Analyzer\Processor\IncludeProcessor;
99
use PhpPacker\Analyzer\Processor\NodeClassificationProcessor;
1010
use PhpPacker\Analyzer\Processor\SymbolProcessor;
11-
use PhpPacker\Storage\SqliteStorage;
11+
use PhpPacker\Storage\StorageInterface;
1212
use PhpParser\Node;
1313
use PhpParser\NodeVisitorAbstract;
1414

@@ -27,7 +27,7 @@ class AnalysisVisitor extends NodeVisitorAbstract
2727
/**
2828
* @phpstan-ignore-next-line constructor.unusedParameter
2929
*/
30-
public function __construct(SqliteStorage $storage, int $fileId, ?string $namespace, string $filePath)
30+
public function __construct(StorageInterface $storage, int $fileId, ?string $namespace, string $filePath)
3131
{
3232
$this->nodeClassifier = new NodeClassificationProcessor();
3333
$this->symbolProcessor = new SymbolProcessor($storage, $fileId, $namespace);

src/Analyzer/ClassFinder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace PhpPacker\Analyzer;
66

7-
use PhpPacker\Storage\SqliteStorage;
7+
use PhpPacker\Storage\StorageInterface;
88
use Psr\Log\LoggerInterface;
99

1010
class ClassFinder
1111
{
12-
private SqliteStorage $storage;
12+
private StorageInterface $storage;
1313

1414
private LoggerInterface $logger;
1515

@@ -20,7 +20,7 @@ class ClassFinder
2020
private FileVerifier $fileVerifier;
2121

2222
public function __construct(
23-
SqliteStorage $storage,
23+
StorageInterface $storage,
2424
LoggerInterface $logger,
2525
AutoloadResolver $autoloadResolver,
2626
PathResolver $pathResolver,

src/Analyzer/Processor/DependencyFileProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use PhpPacker\Analyzer\FileAnalyzer;
88
use PhpPacker\Analyzer\FileVerifier;
99
use PhpPacker\Analyzer\PathResolver;
10-
use PhpPacker\Storage\SqliteStorage;
10+
use PhpPacker\Storage\StorageInterface;
1111
use Psr\Log\LoggerInterface;
1212

1313
class DependencyFileProcessor
1414
{
15-
private SqliteStorage $storage;
15+
private StorageInterface $storage;
1616

1717
private LoggerInterface $logger;
1818

@@ -23,7 +23,7 @@ class DependencyFileProcessor
2323
private FileVerifier $fileVerifier;
2424

2525
public function __construct(
26-
SqliteStorage $storage,
26+
StorageInterface $storage,
2727
LoggerInterface $logger,
2828
FileAnalyzer $fileAnalyzer,
2929
PathResolver $pathResolver,

src/Analyzer/Processor/DependencyProcessor.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace PhpPacker\Analyzer\Processor;
66

7-
use PhpPacker\Storage\SqliteStorage;
7+
use PhpPacker\Storage\StorageInterface;
88
use PhpParser\Node;
99

1010
class DependencyProcessor
1111
{
12-
private SqliteStorage $storage;
12+
private StorageInterface $storage;
1313

1414
private int $fileId;
1515

@@ -25,7 +25,7 @@ class DependencyProcessor
2525
/** @var array<array{type: string, fqcn: string, line: int, conditional: bool}> */
2626
private array $allDependencies = [];
2727

28-
public function __construct(SqliteStorage $storage, int $fileId)
28+
public function __construct(StorageInterface $storage, int $fileId)
2929
{
3030
$this->storage = $storage;
3131
$this->fileId = $fileId;
@@ -320,10 +320,12 @@ private function addDependency(string $type, string $fqcn, int $line): void
320320

321321
$this->storage->addDependency(
322322
$this->fileId,
323+
null,
323324
$type,
324325
$resolvedName,
325326
$line,
326-
$this->inConditionalContext
327+
$this->inConditionalContext,
328+
null
327329
);
328330
++$this->dependencyCount;
329331
}

src/Analyzer/Processor/IncludeProcessor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
namespace PhpPacker\Analyzer\Processor;
66

7-
use PhpPacker\Storage\SqliteStorage;
7+
use PhpPacker\Storage\StorageInterface;
88
use PhpParser\Node;
99

1010
class IncludeProcessor
1111
{
12-
private SqliteStorage $storage;
12+
private StorageInterface $storage;
1313

1414
private int $fileId;
1515

1616
private int $dependencyCount = 0;
1717

18-
public function __construct(SqliteStorage $storage, int $fileId)
18+
public function __construct(StorageInterface $storage, int $fileId)
1919
{
2020
$this->storage = $storage;
2121
$this->fileId = $fileId;
@@ -36,6 +36,7 @@ public function processInclude(Node\Expr\Include_ $node, bool $inConditionalCont
3636

3737
$this->storage->addDependency(
3838
$this->fileId,
39+
null,
3940
$type,
4041
null,
4142
$node->getStartLine(),

src/Analyzer/Processor/SymbolProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
namespace PhpPacker\Analyzer\Processor;
66

7-
use PhpPacker\Storage\SqliteStorage;
7+
use PhpPacker\Storage\StorageInterface;
88
use PhpParser\Node;
99

1010
class SymbolProcessor
1111
{
12-
private SqliteStorage $storage;
12+
private StorageInterface $storage;
1313

1414
private int $fileId;
1515

1616
private ?string $currentNamespace;
1717

1818
private int $symbolCount = 0;
1919

20-
public function __construct(SqliteStorage $storage, int $fileId, ?string $namespace)
20+
public function __construct(StorageInterface $storage, int $fileId, ?string $namespace)
2121
{
2222
$this->storage = $storage;
2323
$this->fileId = $fileId;

src/Analyzer/TopologicalSorter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
namespace PhpPacker\Analyzer;
66

77
use PhpPacker\Exception\CircularDependencyException;
8-
use PhpPacker\Storage\SqliteStorage;
8+
use PhpPacker\Storage\StorageInterface;
99
use Psr\Log\LoggerInterface;
1010

1111
class TopologicalSorter
1212
{
13-
private SqliteStorage $storage;
13+
private StorageInterface $storage;
1414

1515
private LoggerInterface $logger;
1616

17-
public function __construct(SqliteStorage $storage, LoggerInterface $logger)
17+
public function __construct(StorageInterface $storage, LoggerInterface $logger)
1818
{
1919
$this->storage = $storage;
2020
$this->logger = $logger;

src/Storage/SqliteStorage.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PhpParser\Node;
88
use Psr\Log\LoggerInterface;
99

10-
class SqliteStorage
10+
class SqliteStorage implements StorageInterface
1111
{
1212
private \PDO $pdo;
1313

@@ -261,17 +261,17 @@ private function insertNewFile(array $fileData, ?bool $isEntry): int
261261

262262
public function addSymbol(
263263
int $fileId,
264-
string $type,
265-
string $name,
264+
string $symbolType,
265+
string $symbolName,
266266
string $fqn,
267267
?string $namespace = null,
268268
?string $visibility = null,
269269
bool $isAbstract = false,
270-
bool $isFinal = false,
271-
): int {
270+
bool $isFinal = false
271+
): void {
272272
$stmt = $this->pdo->prepare('
273273
INSERT OR REPLACE INTO symbols (
274-
file_id, symbol_type, symbol_name, fqn, namespace,
274+
file_id, symbol_type, symbol_name, fqn, namespace,
275275
visibility, is_abstract, is_final
276276
) VALUES (
277277
:file_id, :symbol_type, :symbol_name, :fqn, :namespace,
@@ -281,46 +281,44 @@ public function addSymbol(
281281

282282
$stmt->execute([
283283
':file_id' => $fileId,
284-
':symbol_type' => $type,
285-
':symbol_name' => $name,
284+
':symbol_type' => $symbolType,
285+
':symbol_name' => $symbolName,
286286
':fqn' => $fqn,
287287
':namespace' => $namespace,
288288
':visibility' => $visibility,
289289
':is_abstract' => $isAbstract ? 1 : 0,
290290
':is_final' => $isFinal ? 1 : 0,
291291
]);
292-
293-
return (int) $this->pdo->lastInsertId();
294292
}
295293

296294
public function addDependency(
297295
int $sourceFileId,
298-
string $type,
299-
?string $targetSymbol,
296+
?int $targetFileId,
297+
string $dependencyType,
298+
?string $targetSymbol = null,
300299
?int $lineNumber = null,
301300
bool $isConditional = false,
302-
?string $context = null,
303-
): int {
301+
?string $context = null
302+
): void {
304303
$stmt = $this->pdo->prepare('
305304
INSERT INTO dependencies (
306-
source_file_id, dependency_type, target_symbol,
305+
source_file_id, target_file_id, dependency_type, target_symbol,
307306
line_number, is_conditional, context
308307
) VALUES (
309-
:source_file_id, :dependency_type, :target_symbol,
308+
:source_file_id, :target_file_id, :dependency_type, :target_symbol,
310309
:line_number, :is_conditional, :context
311310
)
312311
');
313312

314313
$stmt->execute([
315314
':source_file_id' => $sourceFileId,
316-
':dependency_type' => $type,
315+
':target_file_id' => $targetFileId,
316+
':dependency_type' => $dependencyType,
317317
':target_symbol' => $targetSymbol,
318318
':line_number' => $lineNumber,
319319
':is_conditional' => $isConditional ? 1 : 0,
320320
':context' => $context,
321321
]);
322-
323-
return (int) $this->pdo->lastInsertId();
324322
}
325323

326324
public function addAutoloadRule(string $type, string $path, ?string $prefix = null, int $priority = 100): void

0 commit comments

Comments
 (0)