Skip to content

Commit

Permalink
Fix remaining PHPStan warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Apr 18, 2024
1 parent 5bd5fbe commit 52ce198
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
ignoreErrors:
- '#PHPDoc tag @var for property Slub\\Mods\\Element\\Xml\\Element::\$values with type array\|false is not subtype of native type array\.#'
- '#PHPDoc tag @return with type array\|false is not subtype of native type array\.#'
- '#Property Slub\\Mods\\Element\\Specific\\OriginInfo\\Issuance::\$allowedValues is never read, only written\.#'
level: 5
paths:
- ../src/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public function __construct(\SimpleXMLElement $xml)
*/
public function getForm(string $query = ''): ?Form
{
return $this->getLanguageElement('./mods:form' . $query);
$xpath = './mods:form' . $query;
$element = new Element($this->xml, $xpath);
if ($element->exists()) {
return new Form($element->getValues()[0]);
}
return null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Mods/Element/Specific/Part/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getLevel(): int
*
* @param string $query The XPath query for metadata search
*
* @return LanguageElement
* @return LanguageElement[]
*/
public function getNumbers(string $query = ''): array
{
Expand All @@ -87,7 +87,7 @@ public function getNumbers(string $query = ''): array
*
* @param string $query The XPath query for metadata search
*
* @return LanguageElement
* @return LanguageElement[]
*/
public function getCaptions(string $query = ''): array
{
Expand All @@ -102,7 +102,7 @@ public function getCaptions(string $query = ''): array
*
* @param string $query The XPath query for metadata search
*
* @return LanguageElement
* @return LanguageElement[]
*/
public function getTitles(string $query = ''): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mods/Element/Subject.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function getTemporals(string $query = ''): array
$element = new Element($this->xml, $xpath);
if ($element->exists()) {
foreach ($element->getValues() as $value) {
$temporals[] = new AuthorityLanguageElement($value);
$temporals[] = new AuthorityDateLanguageElement($value);
}
}
return $temporals;
Expand Down
4 changes: 2 additions & 2 deletions src/Mods/Element/TitleInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public function getSubTitle(string $query = ''): ?LanguageElement
*
* @param string $query The XPath query for metadata search
*
* @return LanguageElement
* @return ?LanguageElement
*/
public function getPartNumber(string $query = ''): LanguageElement
public function getPartNumber(string $query = ''): ?LanguageElement
{
$xpath = './mods:partNumber' . $query;
$element = new Element($this->xml, $xpath);
Expand Down

0 comments on commit 52ce198

Please sign in to comment.