Skip to content

Commit 20f762e

Browse files
committed
Fix issues found by psalm
1 parent 1e8f0f8 commit 20f762e

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

psalm.xml

+28
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@
1111
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
1212
>
1313
<projectFiles>
14+
<directory name="config" />
1415
<directory name="src" />
16+
<ignoreFiles>
17+
<file name="config/bootstrap.php" />
18+
</ignoreFiles>
1519
</projectFiles>
20+
<issueHandlers>
21+
<PossiblyUnusedMethod>
22+
<errorLevel type="suppress">
23+
<!-- Only called via dependency injection -->
24+
<referencedMethod name="Phpcq\RepositoryBuilder\Api\GithubClient::__construct"/>
25+
<referencedMethod name="Phpcq\RepositoryBuilder\Command\RebuildCommand::__construct"/>
26+
<referencedMethod name="Phpcq\RepositoryBuilder\Kernel::configureContainer"/>
27+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\Plugin\Github\RepositoryFactory::__construct"/>
28+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\Tool\Github\TagProviderRepositoryFactory::__construct"/>
29+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\Tool\PharIo\RepositoryFactory::__construct"/>
30+
31+
<!-- Only called via from tests for now - will be used when adding more loaders? -->
32+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\LoaderContext::getPluginConstraint"/>
33+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\LoaderContext::getPluginName"/>
34+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\Plugin\Github\JsonEntry::getRepository"/>
35+
<referencedMethod name="Phpcq\RepositoryBuilder\SourceProvider\Plugin\Github\JsonEntry::getTagName"/>
36+
37+
<!-- Writing of XML files currently not needed in this project. -->
38+
<referencedMethod name="Phpcq\RepositoryBuilder\File\XmlFile::createElement"/>
39+
<referencedMethod name="Phpcq\RepositoryBuilder\File\XmlFile::addElement"/>
40+
<referencedMethod name="Phpcq\RepositoryBuilder\File\XmlFile::save"/>
41+
</errorLevel>
42+
</PossiblyUnusedMethod>
43+
</issueHandlers>
1644
</psalm>

src/SourceProvider/Plugin/Github/JsonEntry.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public function getContents(): array
143143
private function makeAbsolute(string $uri): string
144144
{
145145
$scheme = parse_url($uri, PHP_URL_SCHEME);
146-
if (empty($scheme)) {
146+
assert((null === $scheme) || is_string($scheme));
147+
if ((null === $scheme) || ('' === $scheme)) {
147148
// Must be relative to repository then.
148149
return $this->githubClient->fileUri($this->repository, $this->tagName, $uri);
149150
}

src/SourceProvider/Plugin/Github/Repository.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function handleJsonFile(JsonEntry $jsonEntry): void
9595
private function loadPluginRequirements(?array $requirements): PluginRequirements
9696
{
9797
$result = new PluginRequirements();
98-
if (empty($requirements)) {
98+
if ([] === $requirements || null === $requirements) {
9999
return $result;
100100
}
101101

@@ -129,7 +129,8 @@ private function loadPluginRequirements(?array $requirements): PluginRequirement
129129
private function createHash(string $absoluteUriPlugin): PluginHash
130130
{
131131
$scheme = parse_url($absoluteUriPlugin, PHP_URL_SCHEME);
132-
if (!empty($scheme) && $scheme !== 'file') {
132+
assert((null === $scheme) || is_string($scheme));
133+
if (null !== $scheme && $scheme !== 'file') {
133134
try {
134135
return PluginHash::createForString(
135136
$this->httpClient->request('GET', $absoluteUriPlugin)->getContent()

src/SourceProvider/PluginProviderRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getPluginIterator(): Generator
100100
private function loadPluginRequirements(?array $requirements): PluginRequirements
101101
{
102102
$result = new PluginRequirements();
103-
if (empty($requirements)) {
103+
if ([] === $requirements || null === $requirements) {
104104
return $result;
105105
}
106106

0 commit comments

Comments
 (0)