Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
f8a74094
Commit
f8a74094
authored
Sep 11, 2013
by
Dorian Villet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add strong type hinting on the DocumentInterface for 'getDocument(s)'-like methods.
parent
bc946ef5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
14 deletions
+25
-14
library/Solarium/QueryType/Analysis/Query/Document.php
library/Solarium/QueryType/Analysis/Query/Document.php
+15
-7
library/Solarium/QueryType/Extract/Query.php
library/Solarium/QueryType/Extract/Query.php
+1
-1
library/Solarium/QueryType/Update/Query/Command/Add.php
library/Solarium/QueryType/Update/Query/Command/Add.php
+8
-5
library/Solarium/QueryType/Update/Query/Query.php
library/Solarium/QueryType/Update/Query/Query.php
+1
-1
No files found.
library/Solarium/QueryType/Analysis/Query/Document.php
View file @
f8a74094
...
@@ -38,9 +38,10 @@
...
@@ -38,9 +38,10 @@
*/
*/
namespace
Solarium\QueryType\Analysis\Query
;
namespace
Solarium\QueryType\Analysis\Query
;
use
Solarium\Core\Client\Client
;
use
Solarium\Core\Client\Client
;
use
Solarium\Exception\RuntimeException
;
use
Solarium\QueryType\Analysis\ResponseParser\Document
as
ResponseParser
;
use
Solarium\QueryType\Analysis\ResponseParser\Document
as
ResponseParser
;
use
Solarium\QueryType\Analysis\RequestBuilder\Document
as
RequestBuilder
;
use
Solarium\QueryType\Analysis\RequestBuilder\Document
as
RequestBuilder
;
use
Solarium\QueryType\Select\Result\Document
as
ResultDocument
;
use
Solarium\QueryType\Select\Result\Document
Interface
;
/**
/**
* Analysis document query
* Analysis document query
...
@@ -51,7 +52,7 @@ class Document extends Query
...
@@ -51,7 +52,7 @@ class Document extends Query
/**
/**
* Documents to analyze
* Documents to analyze
*
*
* @var
ResultDocument
[]
* @var
DocumentInterface
[]
*/
*/
protected
$documents
=
array
();
protected
$documents
=
array
();
...
@@ -99,10 +100,10 @@ class Document extends Query
...
@@ -99,10 +100,10 @@ class Document extends Query
/**
/**
* Add a single document
* Add a single document
*
*
* @param
object
$document
* @param
DocumentInterface
$document
* @return self Provides fluent interface
* @return self
Provides fluent interface
*/
*/
public
function
addDocument
(
$document
)
public
function
addDocument
(
DocumentInterface
$document
)
{
{
$this
->
documents
[]
=
$document
;
$this
->
documents
[]
=
$document
;
...
@@ -113,10 +114,17 @@ class Document extends Query
...
@@ -113,10 +114,17 @@ class Document extends Query
* Add multiple documents
* Add multiple documents
*
*
* @param DocumentInterface[] $documents
* @param DocumentInterface[] $documents
* @return self fluent interface
* @return self Provides fluent interface
* @throws RuntimeException If any of the given documents does not implement DocumentInterface
*/
*/
public
function
addDocuments
(
$documents
)
public
function
addDocuments
(
$documents
)
{
{
foreach
(
$documents
as
$document
)
{
if
(
!
(
$document
instanceof
DocumentInterface
))
{
throw
new
RuntimeException
(
'Documents must implement DocumentInterface.'
);
}
}
$this
->
documents
=
array_merge
(
$this
->
documents
,
$documents
);
$this
->
documents
=
array_merge
(
$this
->
documents
,
$documents
);
return
$this
;
return
$this
;
...
@@ -125,7 +133,7 @@ class Document extends Query
...
@@ -125,7 +133,7 @@ class Document extends Query
/**
/**
* Get all documents
* Get all documents
*
*
* @return
ResultDocument
[]
* @return
DocumentInterface
[]
*/
*/
public
function
getDocuments
()
public
function
getDocuments
()
{
{
...
...
library/Solarium/QueryType/Extract/Query.php
View file @
f8a74094
...
@@ -134,7 +134,7 @@ class Query extends BaseQuery
...
@@ -134,7 +134,7 @@ class Query extends BaseQuery
* @param DocumentInterface $document
* @param DocumentInterface $document
* @return self
* @return self
*/
*/
public
function
setDocument
(
$document
)
public
function
setDocument
(
DocumentInterface
$document
)
{
{
return
$this
->
setOption
(
'document'
,
$document
);
return
$this
->
setOption
(
'document'
,
$document
);
}
}
...
...
library/Solarium/QueryType/Update/Query/Command/Add.php
View file @
f8a74094
...
@@ -73,12 +73,8 @@ class Add extends Command
...
@@ -73,12 +73,8 @@ class Add extends Command
* @param DocumentInterface $document
* @param DocumentInterface $document
* @return self Provides fluent interface
* @return self Provides fluent interface
*/
*/
public
function
addDocument
(
$document
)
public
function
addDocument
(
DocumentInterface
$document
)
{
{
if
(
!
(
$document
instanceof
DocumentInterface
))
{
throw
new
RuntimeException
(
'Documents must implement the document interface'
);
}
$this
->
documents
[]
=
$document
;
$this
->
documents
[]
=
$document
;
return
$this
;
return
$this
;
...
@@ -89,9 +85,16 @@ class Add extends Command
...
@@ -89,9 +85,16 @@ class Add extends Command
*
*
* @param array|\Traversable $documents
* @param array|\Traversable $documents
* @return self Provides fluent interface
* @return self Provides fluent interface
* @throws RuntimeException If any of the given documents does not implement DocumentInterface
*/
*/
public
function
addDocuments
(
$documents
)
public
function
addDocuments
(
$documents
)
{
{
foreach
(
$documents
as
$document
)
{
if
(
!
(
$document
instanceof
DocumentInterface
))
{
throw
new
RuntimeException
(
'Documents must implement DocumentInterface.'
);
}
}
//if we don't have documents so far, accept arrays or Traversable objects as-is
//if we don't have documents so far, accept arrays or Traversable objects as-is
if
(
empty
(
$this
->
documents
))
{
if
(
empty
(
$this
->
documents
))
{
$this
->
documents
=
$documents
;
$this
->
documents
=
$documents
;
...
...
library/Solarium/QueryType/Update/Query/Query.php
View file @
f8a74094
...
@@ -354,7 +354,7 @@ class Query extends BaseQuery
...
@@ -354,7 +354,7 @@ class Query extends BaseQuery
* @param int $commitWithin
* @param int $commitWithin
* @return self Provides fluent interface
* @return self Provides fluent interface
*/
*/
public
function
addDocument
(
$document
,
$overwrite
=
null
,
public
function
addDocument
(
DocumentInterface
$document
,
$overwrite
=
null
,
$commitWithin
=
null
)
$commitWithin
=
null
)
{
{
return
$this
->
addDocuments
(
array
(
$document
),
$overwrite
,
$commitWithin
);
return
$this
->
addDocuments
(
array
(
$document
),
$overwrite
,
$commitWithin
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment