summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2026-02-11 15:28:46 +0000
committerGreg Roach <greg@subaqua.co.uk>2026-02-13 15:07:42 +0000
commitab5cd4f311b8e85fb173c2147fe45ade76f0266a (patch)
tree2610b5b608cb5da0b65939bb99403c4336baeecc
parent6ce876758937baf586cc76babd5cd87dbcba3d91 (diff)
downloadwebtrees-ab5cd4f311b8e85fb173c2147fe45ade76f0266a.tar.gz
webtrees-ab5cd4f311b8e85fb173c2147fe45ade76f0266a.tar.bz2
webtrees-ab5cd4f311b8e85fb173c2147fe45ade76f0266a.zip
Fix phpstan issues
-rw-r--r--app/Services/IndividualFactsService.php37
-rw-r--r--app/Services/RelationshipService.php28
-rw-r--r--phpstan-baseline.neon41
-rw-r--r--phpstan.neon.dist1
4 files changed, 31 insertions, 76 deletions
diff --git a/app/Services/IndividualFactsService.php b/app/Services/IndividualFactsService.php
index 40563c0586..64ba7cfe8d 100644
--- a/app/Services/IndividualFactsService.php
+++ b/app/Services/IndividualFactsService.php
@@ -459,6 +459,7 @@ class IndividualFactsService
'U' => I18N::translate('Marriage of a half-sibling'),
];
+ /** @var Collection<Fact> $facts */
$facts = new Collection();
// Deal with recursion.
@@ -502,24 +503,24 @@ class IndividualFactsService
case '_GCHI':
switch ($relation) {
case 'dau':
- $facts[] = $this->convertEvent($fact, $birth_of_a_grandchild1[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $birth_of_a_grandchild1[$fact->tag()], $child->sex());
break;
case 'son':
- $facts[] = $this->convertEvent($fact, $birth_of_a_grandchild2[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $birth_of_a_grandchild2[$fact->tag()], $child->sex());
break;
case 'chil':
- $facts[] = $this->convertEvent($fact, $birth_of_a_grandchild[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $birth_of_a_grandchild[$fact->tag()], $child->sex());
break;
}
break;
case '_SIBL':
- $facts[] = $this->convertEvent($fact, $birth_of_a_sibling[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $birth_of_a_sibling[$fact->tag()], $child->sex());
break;
case '_HSIB':
- $facts[] = $this->convertEvent($fact, $birth_of_a_half_sibling[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $birth_of_a_half_sibling[$fact->tag()], $child->sex());
break;
case '_CHIL':
- $facts[] = $this->convertEvent($fact, $birth_of_a_child[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $birth_of_a_child[$fact->tag()], $child->sex());
break;
}
}
@@ -533,24 +534,24 @@ class IndividualFactsService
case '_GCHI':
switch ($relation) {
case 'dau':
- $facts[] = $this->convertEvent($fact, $death_of_a_grandchild1[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_grandchild1[$fact->tag()], $child->sex());
break;
case 'son':
- $facts[] = $this->convertEvent($fact, $death_of_a_grandchild2[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_grandchild2[$fact->tag()], $child->sex());
break;
case 'chi':
- $facts[] = $this->convertEvent($fact, $death_of_a_grandchild[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_grandchild[$fact->tag()], $child->sex());
break;
}
break;
case '_SIBL':
- $facts[] = $this->convertEvent($fact, $death_of_a_sibling[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_sibling[$fact->tag()], $child->sex());
break;
case '_HSIB':
- $facts[] = $this->convertEvent($fact, $death_of_a_half_sibling[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_half_sibling[$fact->tag()], $child->sex());
break;
case '_CHIL':
- $facts[] = $this->convertEvent($fact, $death_of_a_child[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_child[$fact->tag()], $child->sex());
break;
}
}
@@ -687,6 +688,7 @@ class IndividualFactsService
'U' => I18N::translate('Marriage of a parent'),
];
+ /** @var Collection<Fact> $facts */
$facts = new Collection();
if ($sosa === 1) {
@@ -740,19 +742,19 @@ class IndividualFactsService
if ($sosa === 1 && Date::compare($fact->date(), $min_date) < 0 || $this->includeFact($fact, $min_date, $max_date)) {
switch ($sosa) {
case 1:
- $facts[] = $this->convertEvent($fact, $death_of_a_parent[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_parent[$fact->tag()], $parent->sex());
break;
case 2:
case 3:
switch ($person->sex()) {
case 'M':
- $facts[] = $this->convertEvent($fact, $death_of_a_paternal_grandparent[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_paternal_grandparent[$fact->tag()], $parent->sex());
break;
case 'F':
- $facts[] = $this->convertEvent($fact, $death_of_a_maternal_grandparent[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_maternal_grandparent[$fact->tag()], $parent->sex());
break;
default:
- $facts[] = $this->convertEvent($fact, $death_of_a_grandparent[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_grandparent[$fact->tag()], $parent->sex());
break;
}
}
@@ -797,12 +799,13 @@ class IndividualFactsService
],
];
+ /** @var Collection<Fact> $facts */
$facts = new Collection();
if (str_contains($SHOW_RELATIVES_EVENTS, '_DEAT_SPOU')) {
foreach ($spouse->facts(['DEAT', 'BURI', 'CREM']) as $fact) {
if ($this->includeFact($fact, $min_date, $max_date)) {
- $facts[] = $this->convertEvent($fact, $death_of_a_spouse[$fact->tag()], $fact->record()->sex());
+ $facts[] = $this->convertEvent($fact, $death_of_a_spouse[$fact->tag()], $spouse->sex());
}
}
}
diff --git a/app/Services/RelationshipService.php b/app/Services/RelationshipService.php
index 3193c3028c..88c0d25c16 100644
--- a/app/Services/RelationshipService.php
+++ b/app/Services/RelationshipService.php
@@ -315,13 +315,8 @@ class RelationshipService
}
/**
- * @param string $path
- * @param Individual|null $person1
- * @param Individual|null $person2
- *
- * @return string
- *
- * @deprecated This code was originally Functions::getRelationshipNameFromPath
+ * This code was originally Functions::getRelationshipNameFromPath
+ * We will need it until all languages have relationship definitions.
*/
public function legacyNameAlgorithm(string $path, Individual|null $person1 = null, Individual|null $person2 = null): string
{
@@ -2219,12 +2214,8 @@ class RelationshipService
/**
* Calculate the name of a cousin.
*
- * @param int $n
- * @param string $sex
- *
- * @return string
- *
- * @deprecated
+ * This code was originally part of Functions::getRelationshipNameFromPath
+ * We will need it until all languages have relationship definitions.
*/
private static function legacyCousinName(int $n, string $sex): string
{
@@ -2355,16 +2346,11 @@ class RelationshipService
}
/**
- * A variation on cousin_name(), for constructs such as “sixth great-nephew”
+ * A variation on legacyCousinName(), for constructs such as “sixth great-nephew”
* Currently used only by Spanish relationship names.
*
- * @param int $n
- * @param string $sex
- * @param string $relation
- *
- * @return string
- *
- * @deprecated
+ * This code was originally part of Functions::getRelationshipNameFromPath
+ * We will need it until all languages have relationship definitions.
*/
private static function legacyCousinName2(int $n, string $sex, string $relation): string
{
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index f706f9c676..df9bc0e890 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1,58 +1,25 @@
parameters:
ignoreErrors:
-
- rawMessage: '''
- Call to deprecated method legacyNameAlgorithm() of class Fisharebest\Webtrees\Services\RelationshipService:
- This code was originally Functions::getRelationshipNameFromPath
- '''
- identifier: method.deprecated
- count: 1
- path: app/Module/PedigreeMapModule.php
-
- -
- rawMessage: '''
- Call to deprecated method legacyNameAlgorithm() of class Fisharebest\Webtrees\Services\RelationshipService:
- This code was originally Functions::getRelationshipNameFromPath
- '''
- identifier: method.deprecated
- count: 5
- path: app/Module/RelationshipsChartModule.php
-
- -
- rawMessage: 'Call to an undefined method Fisharebest\Webtrees\GedcomRecord::sex().'
- identifier: method.notFound
- count: 17
- path: app/Services/IndividualFactsService.php
-
- -
- rawMessage: '''
- Call to deprecated method legacyNameAlgorithm() of class Fisharebest\Webtrees\Services\RelationshipService:
- This code was originally Functions::getRelationshipNameFromPath
- '''
- identifier: method.deprecated
- count: 1
- path: app/Services/RelationshipService.php
-
- -
- rawMessage: 'Call to an undefined method Fisharebest\Webtrees\GedcomRecord::getBirthDate().'
+ message: '#^Call to an undefined method Fisharebest\\Webtrees\\GedcomRecord\:\:getBirthDate\(\)\.$#'
identifier: method.notFound
count: 1
path: resources/views/edit/reorder-children.phtml
-
- rawMessage: 'Call to an undefined method Fisharebest\Webtrees\GedcomRecord::getMarriageDate().'
+ message: '#^Call to an undefined method Fisharebest\\Webtrees\\GedcomRecord\:\:getMarriageDate\(\)\.$#'
identifier: method.notFound
count: 2
path: resources/views/edit/reorder-families.phtml
-
- rawMessage: 'Call to an undefined method Fisharebest\Webtrees\GedcomRecord::displayImage().'
+ message: '#^Call to an undefined method Fisharebest\\Webtrees\\GedcomRecord\:\:displayImage\(\)\.$#'
identifier: method.notFound
count: 1
path: resources/views/edit/reorder-media.phtml
-
- rawMessage: 'Call to an undefined method Fisharebest\Webtrees\GedcomRecord::displayImage().'
+ message: '#^Call to an undefined method Fisharebest\\Webtrees\\GedcomRecord\:\:displayImage\(\)\.$#'
identifier: method.notFound
count: 1
path: resources/views/modules/pedigree-map/events.phtml
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 90a174835e..9c75dbd68a 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -1,6 +1,5 @@
includes:
- phpstan-baseline.neon
- - vendor/phpstan/phpstan/conf/bleedingEdge.neon
parameters:
fileExtensions: