Skip to content

Commit 47b079f

Browse files
Fix PHPStand errors
1 parent d1d886c commit 47b079f

File tree

9 files changed

+15
-10
lines changed

9 files changed

+15
-10
lines changed

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ parameters:
22
level: 7
33
paths:
44
- %currentWorkingDirectory%/src/
5+
ignoreErrors:
6+
- '#Property CaptainHook\\App\\Runner\\Hook\\PrepareCommitMsg::\$[a-zA-Z0-9\\_]+ is never read, only written.#'

src/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public function __construct(string $path, bool $fileExists = false, array $setti
9898
/**
9999
* Setup all configured plugins
100100
*
101-
* @param array<int, array<mixed>> $pluginSettings
101+
* @param array<int, array<string, mixed>> $pluginSettings
102102
* @return void
103103
*/
104104
private function setupPlugins(array $pluginSettings): void
105105
{
106106
foreach ($pluginSettings as $plugin) {
107-
$name = $plugin['plugin'];
107+
$name = (string) $plugin['plugin'];
108108
$options = isset($plugin['options']) && is_array($plugin['options'])
109109
? $plugin['options']
110110
: [];

src/Config/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function getJsonData(): array
126126
/**
127127
* Return conditions json data
128128
*
129-
* @return array<int, array>
129+
* @return array<int, mixed>
130130
*/
131131
private function getConditionJsonData(): array
132132
{

src/Hook/PHP/CoverageResolver/CloverXML.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ public function getCoverage(): float
7777
);
7878
}
7979

80-
return $covered / ($statements * 0.01);
80+
return $covered / ((int)$statements * 0.01);
8181
}
8282
}

src/Runner/Action/Cli/Command/Formatter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private function computedPlaceholder(string $rawPlaceholder): string
159159
*/
160160
private function createPlaceholder(string $placeholder): Placeholder
161161
{
162+
/** @var class-string<\CaptainHook\App\Runner\Action\Cli\Command\Placeholder> $class */
162163
$class = self::$placeholders[$placeholder];
163164
return new $class($this->config, $this->repository);
164165
}

src/Runner/Condition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ private function createCondition(Config\Condition $config): ConditionInterface
100100
return new Cli(new Processor(), $config->getExec());
101101
}
102102

103+
/** @var class-string<\CaptainHook\App\Hook\Condition> $class */
103104
$class = $config->getExec();
104105
if (!class_exists($class)) {
105106
throw new RuntimeException('could not find condition class: ' . $class);

src/Runner/Config/Creator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Creator extends Runner
4949
/**
5050
* Path to the currently executed 'binary'
5151
*
52-
* @var string
52+
* @var null|string
5353
*/
5454
protected $executable;
5555

@@ -178,7 +178,7 @@ private function ensureForce(): void
178178
*
179179
* @return string
180180
*/
181-
private function getExecutable()
181+
private function getExecutable(): string
182182
{
183183
return $this->executable ?? 'vendor/bin/captainhook';
184184
}

src/Runner/Config/Editor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ public function run(): void
9090
}
9191

9292
/**
93-
* Create an config edit command
93+
* Create a config edit command
9494
*
9595
* @return \CaptainHook\App\Runner\Config\Change
9696
* @throws \RuntimeException
9797
*/
9898
private function createChange(): Change
9999
{
100+
/** @var class-string<\CaptainHook\App\Runner\Config\Change> $changeClass */
100101
$changeClass = '\\CaptainHook\\App\\Runner\\Config\\Change\\' . $this->change;
101102
if (!class_exists($changeClass)) {
102103
throw new RuntimeException('Invalid change requested');

src/Runner/Hook/PrepareCommitMsg.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class PrepareCommitMsg extends Hook
6868
public function beforeHook(): void
6969
{
7070
$this->commentChar = $this->repository->getConfigOperator()->getSafely('core.commentchar', '#');
71-
$this->file = (string)$this->io->getArgument('file');
72-
$this->mode = (string)$this->io->getArgument('mode');
73-
$this->hash = (string)$this->io->getArgument('hash');
71+
$this->file = $this->io->getArgument('file');
72+
$this->mode = $this->io->getArgument('mode');
73+
$this->hash = $this->io->getArgument('hash');
7474

7575
if (empty($this->file)) {
7676
throw new RuntimeException('commit message file argument is missing');

0 commit comments

Comments
 (0)