Skip to content

Commit 2d8a51f

Browse files
committed
Fix new static analysis issues due to PhpStan2
1 parent 26c9a2d commit 2d8a51f

6 files changed

Lines changed: 16 additions & 21 deletions

File tree

app/Module/Certificates/Model/Certificate.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ protected function extractDataFromPath(string $path): void
7373
$this->type = $match['type'];
7474
$this->description = $match['descr'];
7575

76-
$day = $match['day'] ?? '';
77-
$month_date = DateTime::createFromFormat('m', $match['month'] ?? '');
76+
$month_date = DateTime::createFromFormat('m', $match['month']);
7877
$month = $month_date !== false ? strtoupper($month_date->format('M')) : '';
79-
$year = $match['year'] ?? '';
8078

81-
$this->date = new Date(sprintf('%s %s %s', $day, $month, $year));
79+
$this->date = new Date(sprintf('%s %s %s', $match['day'], $month, $match['year']));
8280
} else {
8381
$this->description = $this->filename;
8482
}

app/Module/GeoDispersion/PlaceMappers/CoordinatesPlaceMapper.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class CoordinatesPlaceMapper implements PlaceMapperInterface
3838
{
3939
use PlaceMapperTrait;
4040

41-
private ?string $cache_key = null;
4241
private ?GeometryEngine $geometry_engine = null;
4342

4443
/**
@@ -82,7 +81,7 @@ public function map(Place $place, string $feature_property): ?string
8281
$features_index['map_SW'],
8382
$features_index['nb_columns']
8483
);
85-
if ($grid_box === null || !$this->setGeometryEngine() || $this->geometry_engine == null) {
84+
if ($grid_box === null || !$this->setGeometryEngine() || $this->geometry_engine === null) {
8685
return null;
8786
}
8887
$features = $features_index['grid'][$grid_box[0]][$grid_box[1]];
@@ -128,7 +127,7 @@ protected function getGridCell(Point $point, Point $grid_NE, Point $grid_SW, int
128127
/**
129128
* Get an indexed array of the features of the map.
130129
*
131-
* {@internal The map is divided in a grid, eacg cell containing the features which bounding box overlaps that cell.
130+
* {@internal The map is divided in a grid, each cell containing the features which bounding box overlaps that cell.
132131
* The grid is computed once for each map, and cached.}
133132
*
134133
* @phpcs:ignore Generic.Files.LineLength.TooLong
@@ -211,13 +210,10 @@ protected function setGeometryEngine(): bool
211210
*/
212211
protected function cacheKey(): ?string
213212
{
214-
if ($this->cache_key === null) {
215-
$map_def = $this->data('map');
216-
if ($map_def === null || !($map_def instanceof MapDefinitionInterface)) {
217-
return null;
218-
}
219-
return spl_object_id($this) . '-map-' . $map_def->id();
213+
$map_def = $this->data('map');
214+
if ($map_def === null || !($map_def instanceof MapDefinitionInterface)) {
215+
return null;
220216
}
221-
return $this->cache_key;
217+
return spl_object_id($this) . '-map-' . $map_def->id();
222218
}
223219
}

app/Module/GeoDispersion/Services/GeoAnalysisDataService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function placeHierarchyExample(Tree $tree): array
7676
->get()->pluck('g_gedcom')
7777
->flatMap(static function (string $gedcom): array {
7878
preg_match_all('/\n2 PLAC (.+)/', $gedcom, $matches);
79-
return $matches[1] ?? [];
79+
return $matches[1];
8080
})
8181
->sort(I18N::comparator())->reverse()
8282
->mapWithKeys(static function (string $place): array {

app/Module/GeoDispersion/Services/PlacesReferenceTableService.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ public function targetId(string $source, string $source_format, string $target_f
7676
}
7777

7878
$mapping = (array) $rows->first();
79-
if (count($columns_select) === 0) {
80-
return $target_format;
81-
}
8279

8380
return str_replace(
8481
array_map(fn($tag) => '{' . $tag . '}', $columns_select[1]),

app/Module/PatronymicLineage/Model/LineageBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private function buildLineage(LineageNode $node): LineageNode
207207
/** @psalm-suppress RedundantCondition */
208208
if (
209209
$spouse === null ||
210-
($spouse_surname !== '' && I18N::comparator()($child_surname, $spouse_surname) != 0)
210+
($spouse_surname !== '' && I18N::comparator()($child_surname, $spouse_surname) !== 0)
211211
) {
212212
if (I18N::comparator()($child_surname, $indi_surname) === 0) {
213213
$nb_natural++;
@@ -224,7 +224,7 @@ private function buildLineage(LineageNode $node): LineageNode
224224
mb_strlen($child_surname) === 0 ||
225225
mb_strlen($indi_surname) === 0 || mb_strlen($spouse_surname) === 0 ||
226226
I18N::comparator()($child_surname, $indi_surname) === 0 ||
227-
I18N::comparator()($child_surname, $spouse_surname) != 0
227+
I18N::comparator()($child_surname, $spouse_surname) !== 0
228228
) {
229229
$node_child = new LineageNode($child, $node->rootNode());
230230
$node_child = $this->buildLineage($node_child);

phpstan.neon.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: max
5+
level: 9
66
paths:
77
- app
88
- tests
99
checkExplicitMixed: false
1010
ignoreErrors:
1111
- '#^Call to an undefined static method Illuminate\\Database\\Capsule\\Manager::.*\(\)\.$#'
12+
-
13+
identifier: varTag.type
14+
strictRules:
15+
strictArrayFilter: false

0 commit comments

Comments
 (0)