Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
62e7146d
Commit
62e7146d
authored
Mar 29, 2010
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-423] Fixed.
parent
354ede1e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
35 deletions
+93
-35
ArrayCollection.php
lib/Doctrine/Common/Collections/ArrayCollection.php
+1
-1
Collection.php
lib/Doctrine/Common/Collections/Collection.php
+86
-29
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+5
-4
CollectionTest.php
tests/Doctrine/Tests/Common/Collections/CollectionTest.php
+1
-1
No files found.
lib/Doctrine/Common/Collections/ArrayCollection.php
View file @
62e7146d
...
...
@@ -247,7 +247,7 @@ class ArrayCollection implements Collection
* @param mixed $element The element to search for.
* @return mixed The key/index of the element or FALSE if the element was not found.
*/
public
function
search
(
$element
)
public
function
indexOf
(
$element
)
{
return
array_search
(
$element
,
$this
->
_elements
,
true
);
}
...
...
lib/Doctrine/Common/Collections/Collection.php
View file @
62e7146d
...
...
@@ -21,20 +21,21 @@
namespace
Doctrine\Common\Collections
;
use
Closure
,
Countable
,
IteratorAggregate
,
ArrayAccess
;
/**
* The missing (SPL) Collection/Array/OrderedMap interface.
*
* A Collection resembles the nature of a regular PHP array. That is,
* it is essentially an
ordered map that can syntactically
also be used
* it is essentially an
<b>ordered map</b> that can
also be used
* like a list.
*
* A Collection has an internal iterator just like a PHP array. In addition
* A Collection has an internal iterator just like a PHP array. In addition
,
* a Collection can be iterated with external iterators, which is preferrable.
* To use an external iterator simply use the foreach language construct to
* iterate over the collection (which calls
getIterator()
internally) or
* explicitly retrieve an iterator though
getIterator()
which can then be
* iterate over the collection (which calls
{@link getIterator()}
internally) or
* explicitly retrieve an iterator though
{@link getIterator()}
which can then be
* used to iterate over the collection.
*
* You can not rely on the internal iterator of the collection being at a certain
* position unless you explicitly positioned it before. Prefer iteration with
* external iterators.
...
...
@@ -47,10 +48,10 @@ namespace Doctrine\Common\Collections;
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
interface
Collection
extends
\Countable
,
\IteratorAggregate
,
\
ArrayAccess
interface
Collection
extends
Countable
,
IteratorAggregate
,
ArrayAccess
{
/**
* Adds an element
to
the collection.
* Adds an element
at the end of
the collection.
*
* @param mixed $element The element to add.
* @return boolean Always TRUE.
...
...
@@ -64,24 +65,24 @@ interface Collection extends \Countable, \IteratorAggregate, \ArrayAccess
/**
* Checks whether an element is contained in the collection.
* This is an O(n) operation.
* This is an O(n) operation
, where n is the size of the collection
.
*
* @param mixed $element The element to
check
for.
* @param mixed $element The element to
search
for.
* @return boolean TRUE if the collection contains the element, FALSE otherwise.
*/
function
contains
(
$element
);
/**
* Checks whether the collection is empty.
* Checks whether the collection is empty
(contains no elements)
.
*
* @return boolean TRUE if the collection is empty, FALSE otherwise.
*/
function
isEmpty
();
/**
* Removes the element
with the specified key/
index from the collection.
* Removes the element
at the specified
index from the collection.
*
* @param string|integer $key The ke
y
/index of the element to remove.
* @param string|integer $key The ke
x
/index of the element to remove.
* @return mixed The removed element or NULL, if the collection did not contain the element.
*/
function
remove
(
$key
);
...
...
@@ -104,7 +105,7 @@ interface Collection extends \Countable, \IteratorAggregate, \ArrayAccess
function
containsKey
(
$key
);
/**
* Gets
an element with a specified key / at a specified
index.
* Gets
the element at the specified key/
index.
*
* @param string|integer $key The key/index of the element to retrieve.
* @return mixed
...
...
@@ -136,7 +137,7 @@ interface Collection extends \Countable, \IteratorAggregate, \ArrayAccess
function
set
(
$key
,
$value
);
/**
* Gets a
plain
PHP array representation of the collection.
* Gets a
native
PHP array representation of the collection.
*
* @return array
*/
...
...
@@ -175,4 +176,60 @@ interface Collection extends \Countable, \IteratorAggregate, \ArrayAccess
*
*/
function
next
();
/**
* Tests for the existence of an element that satisfies the given predicate.
*
* @param Closure $p The predicate.
* @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise.
*/
function
exists
(
Closure
$p
);
/**
* Returns all the elements of this collection that satisfy the predicate p.
* The order of the elements is preserved.
*
* @param Closure $p The predicate used for filtering.
* @return Collection A collection with the results of the filter operation.
*/
function
filter
(
Closure
$p
);
/**
* Applies the given predicate p to all elements of this collection,
* returning true, if the predicate yields true for all elements.
*
* @param Closure $p The predicate.
* @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
*/
function
forAll
(
Closure
$p
);
/**
* Applies the given function to each element in the collection and returns
* a new collection with the elements returned by the function.
*
* @param Closure $func
* @return Collection
*/
function
map
(
Closure
$func
);
/**
* Partitions this collection in two collections according to a predicate.
* Keys are preserved in the resulting collections.
*
* @param Closure $p The predicate on which to partition.
* @return array An array with two elements. The first element contains the collection
* of elements where the predicate returned TRUE, the second element
* contains the collection of elements where the predicate returned FALSE.
*/
function
partition
(
Closure
$p
);
/**
* Gets the index/key of a given element. The comparison of two elements is strict,
* that means not only the value but also the type must match.
* For objects this means reference equality.
*
* @param mixed $element The element to search for.
* @return mixed The key/index of the element or FALSE if the element was not found.
*/
function
indexOf
(
$element
);
}
\ No newline at end of file
lib/Doctrine/ORM/PersistentCollection.php
View file @
62e7146d
...
...
@@ -22,7 +22,8 @@
namespace
Doctrine\ORM
;
use
Doctrine\ORM\Mapping\AssociationMapping
,
\Closure
;
Doctrine\Common\Collections\Collection
,
Closure
;
/**
* A PersistentCollection represents a collection of elements that have persistent state.
...
...
@@ -40,7 +41,7 @@ use Doctrine\ORM\Mapping\AssociationMapping,
* @author Roman Borschel <roman@code-factory.org>
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
*/
final
class
PersistentCollection
implements
\Doctrine\Common\Collections\
Collection
final
class
PersistentCollection
implements
Collection
{
/**
* A snapshot of the collection at the moment it was fetched from the database.
...
...
@@ -443,10 +444,10 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
/**
* {@inheritdoc}
*/
public
function
search
(
$element
)
public
function
indexOf
(
$element
)
{
$this
->
_initialize
();
return
$this
->
_coll
->
search
(
$element
);
return
$this
->
_coll
->
indexOf
(
$element
);
}
/**
...
...
tests/Doctrine/Tests/Common/Collections/CollectionTest.php
View file @
62e7146d
...
...
@@ -98,7 +98,7 @@ class CollectionTest extends \Doctrine\Tests\DoctrineTestCase
public
function
testSearch
()
{
$this
->
_coll
[
0
]
=
'test'
;
$this
->
assertEquals
(
0
,
$this
->
_coll
->
search
(
'test'
));
$this
->
assertEquals
(
0
,
$this
->
_coll
->
indexOf
(
'test'
));
}
public
function
testGet
()
...
...
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