Skip to content

Commit e3903a5

Browse files
committed
Bump up phpstan level
1 parent 52ef250 commit e3903a5

File tree

10 files changed

+35
-7
lines changed

10 files changed

+35
-7
lines changed

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ permissions:
1414
jobs:
1515
testsuite:
1616
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@master
17-
secrets: inherit
17+
secrets:
18+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1819

1920
cs-stan:
2021
uses: ADmad/.github/.github/workflows/cs-stan.yml@master

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 6
5+
level: 8
66
paths:
77
- src
88
excludePaths:

src/Action/AddAction.php

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ protected function _post(): ?Response
128128
}
129129

130130
$saveCallback = [$this->_model(), $subject->saveMethod];
131+
/** @phpstan-ignore argument.type */
131132
if (call_user_func($saveCallback, $subject->entity, $subject->saveOptions)) {
132133
return $this->_success($subject);
133134
}

src/Action/EditAction.php

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ protected function _put(string|int|null $id = null): ?Response
124124
);
125125

126126
$this->_trigger('beforeSave', $subject);
127+
/** @phpstan-ignore argument.type */
127128
if (call_user_func([$this->_model(), $this->saveMethod()], $entity, $this->saveOptions())) {
128129
return $this->_success($subject);
129130
}

src/Controller/Component/CrudComponent.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,10 @@ public function defaults(string $type, array|string $name, mixed $config = null)
607607
return null;
608608
}
609609

610-
/** @psalm-suppress PossiblyInvalidArgument */
610+
/**
611+
* @psalm-suppress PossiblyInvalidArgument
612+
* @phpstan-ignore argument.type
613+
*/
611614
return $this->getConfig(sprintf('%s.%s', $type, $name));
612615
}
613616

@@ -690,6 +693,7 @@ public function getSubject(array $additional = []): Subject
690693
*/
691694
protected function _loadListeners(): void
692695
{
696+
/** @var string $name */
693697
foreach (array_keys($this->getConfig('listeners')) as $name) {
694698
$this->_loadListener($name);
695699
}

src/Controller/ControllerTrait.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* For full copyright and license information, please see the LICENSE.txt
1515
*
1616
* @property \Crud\Controller\Component\CrudComponent $Crud
17+
* @phpstan-ignore trait.unused
1718
*/
1819
trait ControllerTrait
1920
{

src/Error/ExceptionRenderer.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,16 @@ protected function _getQueryLog(): array
131131
$queryLog = [];
132132
$sources = ConnectionManager::configured();
133133
foreach ($sources as $source) {
134-
$logger = ConnectionManager::get($source)->getDriver()->getLogger();
134+
$driver = ConnectionManager::get($source)->getDriver();
135+
if (!method_exists($driver, 'getLogger')) {
136+
continue;
137+
}
138+
139+
$logger = $driver->getLogger();
135140
if ($logger && method_exists($logger, 'getLogs')) {
141+
/**
142+
* @var \Crud\Log\QueryLogger $logger
143+
*/
136144
$queryLog[$source] = $logger->getLogs();
137145
}
138146
}

src/Listener/ApiListener.php

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ protected function _ensureData(Subject $subject): void
281281
}
282282

283283
if (method_exists($subject->entity, $valuePath)) {
284+
/** @phpstan-ignore argument.type */
284285
$data = Hash::insert($data, $keyPath, call_user_func([$subject->entity, $valuePath]));
285286
} elseif (isset($subject->entity->{$valuePath})) {
286287
$data = Hash::insert($data, $keyPath, $subject->entity->{$valuePath});

src/Listener/ApiQueryLogListener.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ public function setupLogging(EventInterface $event): void
6464

6565
foreach ($connections as $connectionName) {
6666
try {
67-
$connection = $this->_getSource($connectionName);
68-
$connection->getDriver()->setLogger(new QueryLogger());
67+
$driver = $this->_getSource($connectionName)->getDriver();
68+
if (method_exists($driver, 'setLogger')) {
69+
$driver->setLogger(new QueryLogger());
70+
}
6971
} catch (MissingDatasourceConfigException $e) {
7072
//Safe to ignore this :-)
7173
}
@@ -99,8 +101,16 @@ protected function _getQueryLogs(): array
99101

100102
$queryLog = [];
101103
foreach ($sources as $source) {
102-
$logger = $this->_getSource($source)->getDriver()->getLogger();
104+
$driver = $this->_getSource($source)->getDriver();
105+
if (!method_exists($driver, 'getLogger')) {
106+
continue;
107+
}
108+
109+
$logger = $driver->getLogger();
103110
if (method_exists($logger, 'getLogs')) {
111+
/**
112+
* @var \Crud\Log\QueryLogger $logger
113+
*/
104114
$queryLog[$source] = $logger->getLogs();
105115
}
106116
}

src/Traits/FindMethodTrait.php

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ protected function _findRecord(string|int|null $id, Subject $subject): EntityInt
6666
/**
6767
* @psalm-suppress PossiblyInvalidArgument
6868
* @psalm-suppress InvalidArrayOffset
69+
* @phpstan-ignore argument.type
6970
*/
7071
$query->where([current($query->aliasField($repository->getPrimaryKey())) => $id]);
7172

0 commit comments

Comments
 (0)