Skip to content

Commit

Permalink
style: fix various issues raised by phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed Oct 25, 2024
1 parent 495ef7c commit d3e3400
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/PropertyAnnotators/LinksToPropertyAnnotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* @private
* @ingroup SESP
*
* @license GNU GPL v2+
* @license GPL-2.0-or-later
* @since 3.0.4
*/
class LinksToPropertyAnnotator implements PropertyAnnotator {

/**
* Predefined property ID
*/
const PROP_ID = '___LINKSTO';
public const PROP_ID = '___LINKSTO';

/**
* @var AppFactory
Expand Down Expand Up @@ -53,7 +53,7 @@ public function setEnabledNamespaces( array $namespaces ) {
* {@inheritDoc}
*/
public function isAnnotatorFor( DIProperty $property ) {
return $property->getKey() === self::PROP_ID ;
return $property->getKey() === self::PROP_ID;
}

/**
Expand All @@ -64,7 +64,11 @@ public function isAnnotatorFor( DIProperty $property ) {
public function addAnnotation( DIProperty $property, SemanticData $semanticData ) {
$page = $semanticData->getSubject()->getTitle();

if ( $page === null || ( !empty( $this->enabledNamespaces ) && !$page->inNamespaces( $this->enabledNamespaces ) ) ) {
if (
$page === null ||
( !empty( $this->enabledNamespaces ) &&
!$page->inNamespaces( $this->enabledNamespaces ) )
) {
return;
}

Expand All @@ -89,7 +93,7 @@ public function addAnnotation( DIProperty $property, SemanticData $semanticData
[ 'page' => [ 'JOIN', 'page_id=pl_from' ] ]
);

foreach( $res as $row ) {
foreach ( $res as $row ) {

Check warning on line 96 in src/PropertyAnnotators/LinksToPropertyAnnotator.php

View check run for this annotation

Codecov / codecov/patch

src/PropertyAnnotators/LinksToPropertyAnnotator.php#L96

Added line #L96 was not covered by tests
$title = Title::newFromText( $row->sel_title, $row->sel_ns );
if ( $title !== null && $title->exists() ) {
$semanticData->addPropertyObjectValue( $property, DIWikiPage::newFromTitle( $title ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace SESP\Tests\PropertyAnnotators;

use PHPUnit_Framework_TestCase;
use SESP\AppFactory;
use SESP\PropertyAnnotators\LinksToPropertyAnnotator;
use SMW\DIProperty;
Expand All @@ -14,10 +13,10 @@
* @covers \SESP\PropertyAnnotators\LinksToPropertyAnnotator
* @group semantic-extra-special-properties
*
* @license GNU GPL v2+
* @license GPL-2.0-or-later
* @since 2.0
*/
class LinksToPropertyAnnotatorTest extends PHPUnit_Framework_TestCase {
class LinksToPropertyAnnotatorTest extends \PHPUnit\Framework\TestCase {

private $property;
private $appFactory;
Expand All @@ -33,15 +32,13 @@ protected function setUp(): void {
}

public function testCanConstruct() {

$this->assertInstanceOf(
LinksToPropertyAnnotator::class,
new LinksToPropertyAnnotator( $this->appFactory )
);
}

public function testIsAnnotatorFor() {

$instance = new LinksToPropertyAnnotator(
$this->appFactory
);
Expand All @@ -56,7 +53,7 @@ public function testAddAnnotation() {
->disableOriginalConstructor()
->getMock();

$factory->expects( $this->once() )->method('getConnection');
$factory->expects( $this->once() )->method( 'getConnection' );

$subject = $this->getMockBuilder( DIWikiPage::class )
->disableOriginalConstructor()
Expand Down Expand Up @@ -90,7 +87,7 @@ public function testNotAddAnnotation() {
->getMock();

$factory->expects( $this->never() )
->method('getConnection');
->method( 'getConnection' );

$subject = $this->getMockBuilder( DIWikiPage::class )
->disableOriginalConstructor()
Expand Down

0 comments on commit d3e3400

Please sign in to comment.