Denny Vrandecic has submitted this change and it was merged.
Change subject: Get rid of all PropertyValue usage, replace by DataValue type
hinting
......................................................................
Get rid of all PropertyValue usage, replace by DataValue type hinting
Change-Id: I1ce0555a22d28ed163247986e5435297ce743c9e
---
M Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
M Tests/Phpunit/Language/Option/SortOptionsTest.php
M Tests/Phpunit/Language/QueryTest.php
M Tests/Phpunit/Language/Selection/PropertySelectionTest.php
M includes/Ask/Language/Description/SomeProperty.php
M includes/Ask/Language/Option/PropertyValueSortExpression.php
M includes/Ask/Language/Selection/PropertySelection.php
7 files changed, 52 insertions(+), 41 deletions(-)
Approvals:
Denny Vrandecic: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
b/Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
index a7ec411..b2c559d 100644
--- a/Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
+++ b/Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
@@ -2,7 +2,9 @@
namespace Ask\Tests\Phpunit\Language\Option;
+use Ask\Language\Option\PropertyValueSortExpression;
use Ask\Language\Option\SortExpression;
+use DataValues\StringValue;
/**
* @covers Ask\Language\Option\PropertyValueSortExpression
@@ -45,13 +47,13 @@
protected function getInstances() {
$instances = array();
- $instances[] = new
\Ask\Language\Option\PropertyValueSortExpression(
- new \DataValues\PropertyValue( 'foo' ),
+ $instances[] = new PropertyValueSortExpression(
+ new StringValue( 'foo' ),
SortExpression::ASCENDING
);
- $instances[] = new
\Ask\Language\Option\PropertyValueSortExpression(
- new \DataValues\PropertyValue( 'foo' ),
+ $instances[] = new PropertyValueSortExpression(
+ new StringValue( 'foo' ),
SortExpression::DESCENDING
);
diff --git a/Tests/Phpunit/Language/Option/SortOptionsTest.php
b/Tests/Phpunit/Language/Option/SortOptionsTest.php
index c53c853..b20766b 100644
--- a/Tests/Phpunit/Language/Option/SortOptionsTest.php
+++ b/Tests/Phpunit/Language/Option/SortOptionsTest.php
@@ -2,7 +2,10 @@
namespace Ask\Tests\Phpunit\Language\Option;
+use Ask\Language\Option\PropertyValueSortExpression;
+use Ask\Language\Option\SortExpression;
use Ask\Language\Option\SortOptions;
+use DataValues\StringValue;
/**
* @covers Ask\Language\Option\QueryOptions
@@ -46,9 +49,9 @@
$instances[] = new SortOptions( array() );
$instances[] = new SortOptions( array(
- new \Ask\Language\Option\PropertyValueSortExpression(
- new \DataValues\PropertyValue( 'foo' ),
- \Ask\Language\Option\SortExpression::ASCENDING
+ new PropertyValueSortExpression(
+ new StringValue( 'foo' ),
+ SortExpression::ASCENDING
)
) );
diff --git a/Tests/Phpunit/Language/QueryTest.php
b/Tests/Phpunit/Language/QueryTest.php
index 5cde89f..5ac5d5c 100644
--- a/Tests/Phpunit/Language/QueryTest.php
+++ b/Tests/Phpunit/Language/QueryTest.php
@@ -2,8 +2,14 @@
namespace Ask\Tests\Phpunit\Language;
+use Ask\Language\Description\AnyValue;
+use Ask\Language\Description\Conjunction;
+use Ask\Language\Description\Description;
+use Ask\Language\Description\Disjunction;
use Ask\Language\Option\QueryOptions;
use Ask\Language\Query;
+use Ask\Language\Selection\PropertySelection;
+use DataValues\StringValue;
/**
* @covers Ask\Language\Query
@@ -38,9 +44,9 @@
public function descriptionProvider() {
$descriptions = array();
- $descriptions[] = new \Ask\Language\Description\AnyValue();
- $descriptions[] = new \Ask\Language\Description\Conjunction(
array() );
- $descriptions[] = new \Ask\Language\Description\Disjunction(
array() );
+ $descriptions[] = new AnyValue();
+ $descriptions[] = new Conjunction( array() );
+ $descriptions[] = new Disjunction( array() );
return $this->arrayWrap( $descriptions );
}
@@ -48,9 +54,9 @@
/**
* @dataProvider descriptionProvider
*
- * @param \Ask\Language\Description\Description $description
+ * @param Description $description
*/
- public function testGetDescriptions(
\Ask\Language\Description\Description $description ) {
+ public function testGetDescriptions( Description $description ) {
$query = new Query( $description, array(), new QueryOptions(
100, 0 ) );
$obtainedDescription = $query->getDescription();
@@ -64,8 +70,8 @@
$requestsLists = array();
$requestsLists[] = array(
- new \Ask\Language\Selection\PropertySelection( new
\DataValues\PropertyValue( 'q42' ) ),
- new \Ask\Language\Selection\PropertySelection( new
\DataValues\PropertyValue( '_geo' ) ),
+ new PropertySelection( new StringValue( 'q42' ) ),
+ new PropertySelection( new StringValue( '_geo' ) ),
);
return $this->arrayWrap( $requestsLists );
@@ -77,7 +83,7 @@
* @param array $selectionRequests
*/
public function testGetSelectionRequests( array $selectionRequests ) {
- $query = new Query( new \Ask\Language\Description\AnyValue(),
$selectionRequests, new QueryOptions( 100, 0 ) );
+ $query = new Query( new AnyValue(), $selectionRequests, new
QueryOptions( 100, 0 ) );
$obtainedRequests = $query->getSelectionRequests();
@@ -91,10 +97,10 @@
$instances = array();
$instances[] = new Query(
- new \Ask\Language\Description\AnyValue(),
+ new AnyValue(),
array(
- new \Ask\Language\Selection\PropertySelection(
new \DataValues\PropertyValue( 'q42' ) ),
- new \Ask\Language\Selection\PropertySelection(
new \DataValues\PropertyValue( '_geo' ) ),
+ new PropertySelection( new StringValue( 'q42' )
),
+ new PropertySelection( new StringValue( '_geo'
) ),
),
new QueryOptions( 100, 0 )
);
diff --git a/Tests/Phpunit/Language/Selection/PropertySelectionTest.php
b/Tests/Phpunit/Language/Selection/PropertySelectionTest.php
index 22b3243..a1389e9 100644
--- a/Tests/Phpunit/Language/Selection/PropertySelectionTest.php
+++ b/Tests/Phpunit/Language/Selection/PropertySelectionTest.php
@@ -3,6 +3,7 @@
namespace Ask\Tests\Phpunit\Language\Selection;
use Ask\Language\Selection\PropertySelection;
+use DataValues\StringValue;
/**
* @covers Ask\Language\Selection\PropertySelection
@@ -42,11 +43,11 @@
$instances = array();
$instances[] = new PropertySelection(
- new \DataValues\PropertyValue( 'p42' )
+ new StringValue( 'p42' )
);
$instances[] = new PropertySelection(
- new \DataValues\PropertyValue( '_geo' )
+ new StringValue( '_geo' )
);
return $instances;
diff --git a/includes/Ask/Language/Description/SomeProperty.php
b/includes/Ask/Language/Description/SomeProperty.php
index 5f88360..01c48d8 100644
--- a/includes/Ask/Language/Description/SomeProperty.php
+++ b/includes/Ask/Language/Description/SomeProperty.php
@@ -3,7 +3,6 @@
namespace Ask\Language\Description;
use DataValues\DataValue;
-use DataValues\PropertyValue;
use InvalidArgumentException;
/**
@@ -46,7 +45,7 @@
*
* @since 0.1
*
- * @var PropertyValue
+ * @var DataValue
*/
private $propertyId;
diff --git a/includes/Ask/Language/Option/PropertyValueSortExpression.php
b/includes/Ask/Language/Option/PropertyValueSortExpression.php
index 71d958e..e40990f 100644
--- a/includes/Ask/Language/Option/PropertyValueSortExpression.php
+++ b/includes/Ask/Language/Option/PropertyValueSortExpression.php
@@ -2,7 +2,7 @@
namespace Ask\Language\Option;
-use DataValues\PropertyValue;
+use DataValues\DataValue;
use InvalidArgumentException;
/**
@@ -38,7 +38,7 @@
*
* @since 0.1
*
- * @var PropertyValue
+ * @var DataValue
*/
protected $property;
@@ -47,13 +47,13 @@
*
* @since 0.1
*
- * @param PropertyValue $property
+ * @param DataValue $propertyId
* @param string $direction
*
* @throws InvalidArgumentException
*/
- public function __construct( PropertyValue $property, $direction ) {
- $this->property = $property;
+ public function __construct( DataValue $propertyId, $direction ) {
+ $this->property = $propertyId;
if ( !is_string( $direction ) ) {
throw new InvalidArgumentException( '$direction needs
to be one of the direction constants' );
@@ -67,9 +67,9 @@
*
* @since 0.1
*
- * @return PropertyValue
+ * @return DataValue
*/
- public function getProperty() {
+ public function getPropertyId() {
return $this->property;
}
diff --git a/includes/Ask/Language/Selection/PropertySelection.php
b/includes/Ask/Language/Selection/PropertySelection.php
index 1624544..d68ba28 100644
--- a/includes/Ask/Language/Selection/PropertySelection.php
+++ b/includes/Ask/Language/Selection/PropertySelection.php
@@ -2,7 +2,7 @@
namespace Ask\Language\Selection;
-use DataValues\PropertyValue;
+use DataValues\DataValue;
/**
* Selection request specifying that the values for a property should be
obtained.
@@ -37,19 +37,19 @@
*
* @since 0.1
*
- * @var PropertyValue
+ * @var DataValue
*/
- protected $property;
+ protected $propertyId;
/**
* Constructor.
*
* @since 0.1
*
- * @param PropertyValue $property
+ * @param DataValue $propertyId
*/
- public function __construct( PropertyValue $property ) {
- $this->property = $property;
+ public function __construct( DataValue $propertyId ) {
+ $this->propertyId = $propertyId;
}
/**
@@ -68,10 +68,10 @@
*
* @since 0.1
*
- * @return PropertyValue
+ * @return DataValue
*/
- public function getProperty() {
- return $this->property;
+ public function getPropertyId() {
+ return $this->propertyId;
}
/**
@@ -83,7 +83,7 @@
*/
public function getArrayValue() {
return array(
- 'property' => $this->property->toArray()
+ 'property' => $this->propertyId->toArray()
);
}
@@ -98,7 +98,7 @@
*/
public function equals( $mixed ) {
return $mixed instanceof PropertySelection
- && $this->property->equals( $mixed->getProperty() );
+ && $this->propertyId->equals( $mixed->getPropertyId() );
}
/**
@@ -109,7 +109,7 @@
* @return string
*/
public function getHash() {
- return sha1( $this->getType() . $this->property->getHash() );
+ return sha1( $this->getType() . $this->propertyId->getHash() );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/64070
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1ce0555a22d28ed163247986e5435297ce743c9e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits