Skip to content

Commit

Permalink
Lower the psalm error level to 6 (#78)
Browse files Browse the repository at this point in the history
* psalm: errorLevel="6"

* skip 3 psalm checks for references from DataModel

* Don't need psalm skips..
  • Loading branch information
addwiki-ci committed Mar 6, 2021
1 parent b9d205e commit f606d4c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Api/Service/RevisionGetter.php
Expand Up @@ -32,7 +32,7 @@ public function __construct( ActionApi $api, Deserializer $entityDeserializer )
/**
* @param string|EntityId $id
*/
public function getFromId( $id ): Revision {
public function getFromId( $id ): ?Revision {
if ( $id instanceof EntityId ) {
$id = $id->getSerialization();
}
Expand All @@ -44,30 +44,25 @@ public function getFromId( $id ): Revision {
/**
* @param SiteLink $siteLink
*/
public function getFromSiteLink( SiteLink $siteLink ): Revision {
public function getFromSiteLink( SiteLink $siteLink ): ?Revision {
$result = $this->api->request( ActionRequest::simpleGet(
'wbgetentities',
[ 'sites' => $siteLink->getSiteId(), 'titles' => $siteLink->getPageName() ]
) );
return $this->newRevisionFromResult( array_shift( $result['entities'] ) );
}

public function getFromSiteAndTitle( string $siteId, string $title ): Revision {
public function getFromSiteAndTitle( string $siteId, string $title ): ?Revision {
$result = $this->api->request( ActionRequest::simpleGet(
'wbgetentities',
[ 'sites' => $siteId, 'titles' => $title ]
) );
return $this->newRevisionFromResult( array_shift( $result['entities'] ) );
}

/**
* @param array $entityResult
* @return bool|Revision
* @todo this could be factored into a different class?
*/
private function newRevisionFromResult( array $entityResult ) {
private function newRevisionFromResult( array $entityResult ): ?Revision {
if ( array_key_exists( 'missing', $entityResult ) ) {
return false; // Throw an exception?
return null; // Throw an exception?
}
return new Revision(
$this->getContentFromEntity( $this->entityDeserializer->deserialize( $entityResult ) ),
Expand Down

0 comments on commit f606d4c

Please sign in to comment.