Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
{"name": "Konsta Vesterinen", "email": "[email protected]"},
{"name": "Jonathan Wage", "email": "[email protected]"}
],
"repositories": [
{
"type": "git",
"url": "[email protected]:zf1s/compat.git"
}
],
"replace": {
"doctrine/doctrine1": "*"
},
"require": {
"php": ">=5.3.3",
"ext-pdo": "*"
"ext-pdo": "*",
"zf1s/compat": "^1.0"
},
"autoload": {
"psr-0": {
Expand Down
10 changes: 8 additions & 2 deletions lib/Doctrine/Cli.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use Zf1s\Compat\Types;

/*
* $Id: Cli.php 2761 2007-10-07 23:42:29Z zYne $
*
Expand Down Expand Up @@ -71,11 +74,14 @@ class Doctrine_Cli
/**
* __construct
*
* @param array [$config=array()]
* @param array|null [$config=array()]
* @param object|null [$formatter=null] Doctrine_Cli_Formatter
*/
public function __construct(array $config = array(), Doctrine_Cli_Formatter $formatter = null)
public function __construct($config = array(), $formatter = null)
{
Types::isNullable('config', $config, 'array');
Types::isNullable('formatter', $formatter, 'Doctrine_Cli_Formatter');

$this->setConfig($config);
$this->setFormatter($formatter ? $formatter : new Doctrine_Cli_AnsiColorFormatter());
$this->includeAndRegisterTaskClasses();
Expand Down
115 changes: 62 additions & 53 deletions lib/Doctrine/Collection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use Zf1s\Compat\Types;

/*
* $Id: Collection.php 7686 2010-08-24 16:54:40Z jwage $
*
Expand Down Expand Up @@ -137,7 +140,7 @@ public function getTable()
* @param array $data
* @return Doctrine_Collection
*/
public function setData(array $data)
public function setData(array $data)
{
$this->data = $data;
}
Expand Down Expand Up @@ -188,7 +191,7 @@ public function unserialize($serialized)
{
$this->__unserialize(unserialize($serialized));
}

/**
* As of PHP 8.1.0, a class which implements Serializable without also implementing __serialize() and __unserialize() will generate a deprecation warning.
* @see https://php.watch/versions/8.1/serializable-deprecated
Expand Down Expand Up @@ -225,7 +228,7 @@ public function __unserialize(array $array)
public function setKeyColumn($column)
{
$this->keyColumn = $column;

return $this;
}

Expand Down Expand Up @@ -299,7 +302,7 @@ public function setReference(Doctrine_Record $record, Doctrine_Relation $relatio
$this->reference = $record;
$this->relation = $relation;

if ($relation instanceof Doctrine_Relation_ForeignKey ||
if ($relation instanceof Doctrine_Relation_ForeignKey ||
$relation instanceof Doctrine_Relation_LocalKey) {
$this->referenceField = $relation->getForeignFieldName();

Expand Down Expand Up @@ -355,7 +358,7 @@ public function contains($key)
/**
* Search a Doctrine_Record instance
*
* @param string $Doctrine_Record
* @param string $Doctrine_Record
* @return void
*/
public function search(Doctrine_Record $record)
Expand Down Expand Up @@ -396,7 +399,7 @@ public function get($key)
if ($key === null) {
$this->data[] = $record;
} else {
$this->data[$key] = $record;
$this->data[$key] = $record;
}

if (isset($this->keyColumn)) {
Expand Down Expand Up @@ -522,26 +525,26 @@ public function add($record, $key = null)

return true;
}

/**
* Merges collection into $this and returns merged collection
*
*
* @param Doctrine_Collection $coll
* @return Doctrine_Collection
*/
public function merge(Doctrine_Collection $coll)
{
$localBase = $this->getTable()->getComponentName();
$otherBase = $coll->getTable()->getComponentName();

if ($otherBase != $localBase && !is_subclass_of($otherBase, $localBase) ) {
throw new Doctrine_Collection_Exception("Can't merge collections with incompatible record types");
}

foreach ($coll->getData() as $record) {
$this->add($record);
}

return $this;
}

Expand Down Expand Up @@ -685,7 +688,7 @@ public function getNormalIterator()
public function takeSnapshot()
{
$this->_snapshot = $this->data;

return $this;
}

Expand All @@ -710,7 +713,7 @@ public function getSnapshot()
*
* @return Doctrine_Collection
*/
public function processDiff()
public function processDiff()
{
foreach (array_udiff($this->_snapshot, $this->data, array($this, "compareRecords")) as $record) {
$record->delete();
Expand All @@ -728,20 +731,20 @@ public function toArray($deep = true, $prefixKey = false)
{
$data = array();
foreach ($this as $key => $record) {

$key = $prefixKey ? get_class($record) . '_' .$key:$key;

$data[$key] = $record->toArray($deep, $prefixKey);
}

return $data;
}

/**
* Build an array made up of the values from the 2 specified columns
*
* @param string $key
* @param string $value
* @param string $key
* @param string $value
* @return array $result
*/
public function toKeyValueArray($key, $value)
Expand Down Expand Up @@ -804,7 +807,7 @@ public function toHierarchy()
/**
* Populate a Doctrine_Collection from an array of data
*
* @param string $array
* @param string $array
* @return void
*/
public function fromArray($array, $deep = true)
Expand Down Expand Up @@ -852,8 +855,8 @@ public function synchronizeFromArray(array $array)
/**
* Export a Doctrine_Collection to one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $deep
* @param string $type
* @param string $deep
* @return void
*/
public function exportTo($type, $deep = true)
Expand All @@ -868,8 +871,8 @@ public function exportTo($type, $deep = true)
/**
* Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats
*
* @param string $type
* @param string $data
* @param string $type
* @param string $data
* @return void
*/
public function importFrom($type, $data)
Expand Down Expand Up @@ -906,8 +909,8 @@ public function getInsertDiff()
*
* @throws Doctrine_Collection_Exception
*
* @param Doctrine_Record $a
* @param Doctrine_Record $b
* @param Doctrine_Record $a
* @param Doctrine_Record $b
* @return integer
*/
protected function compareRecords($a, $b)
Expand All @@ -924,23 +927,25 @@ protected function compareRecords($a, $b)
if ($a->getOid() == $b->getOid()) {
return 0;
}

return ($a->getOid() > $b->getOid()) ? 1 : -1;
}

/**
* Saves all records of this collection and processes the
* Saves all records of this collection and processes the
* difference of the last snapshot and the current data
*
* @param Doctrine_Connection $conn optional connection parameter
* @param Doctrine_Connection|null $conn optional connection parameter
* @return Doctrine_Collection
*/
public function save(Doctrine_Connection $conn = null, $processDiff = true)
public function save($conn = null, $processDiff = true)
{
Types::isNullable('conn', $conn, 'Doctrine_Connection');

if ($conn == null) {
$conn = $this->_table->getConnection();
}

try {
$conn->beginInternalTransaction();

Expand All @@ -964,14 +969,16 @@ public function save(Doctrine_Connection $conn = null, $processDiff = true)
}

/**
* Replaces all records of this collection and processes the
* Replaces all records of this collection and processes the
* difference of the last snapshot and the current data
*
* @param Doctrine_Connection $conn optional connection parameter
* @param Doctrine_Connection|null $conn optional connection parameter
* @return Doctrine_Collection
*/
public function replace(Doctrine_Connection $conn = null, $processDiff = true)
public function replace($conn = null, $processDiff = true)
{
Types::isNullable('conn', $conn, 'Doctrine_Connection');

if ($conn == null) {
$conn = $this->_table->getConnection();
}
Expand Down Expand Up @@ -1003,12 +1010,14 @@ public function replace(Doctrine_Connection $conn = null, $processDiff = true)
*
* @return Doctrine_Collection
*/
public function delete(Doctrine_Connection $conn = null, $clearColl = true)
public function delete($conn = null, $clearColl = true)
{
Types::isNullable('conn', $conn, 'Doctrine_Connection');

if ($conn == null) {
$conn = $this->_table->getConnection();
}

try {
$conn->beginInternalTransaction();
$conn->transaction->addCollection($this);
Expand All @@ -1022,14 +1031,14 @@ public function delete(Doctrine_Connection $conn = null, $clearColl = true)
$conn->rollback();
throw $e;
}

if ($clearColl) {
$this->clear();
}

return $this;
}

/**
* Clears the collection.
*
Expand Down Expand Up @@ -1084,7 +1093,7 @@ public function __toString()
{
return Doctrine_Lib::getCollectionAsString($this);
}

/**
* Returns the relation object
*
Expand All @@ -1095,22 +1104,22 @@ public function getRelation()
return $this->relation;
}

/**
* checks if one of the containing records is modified
* returns true if modified, false otherwise
*
* @return boolean
*/
final public function isModified() {
$dirty = (count($this->getInsertDiff()) > 0 || count($this->getDeleteDiff()) > 0);
if ( ! $dirty) {
foreach($this as $record) {
/**
* checks if one of the containing records is modified
* returns true if modified, false otherwise
*
* @return boolean
*/
final public function isModified() {
$dirty = (count($this->getInsertDiff()) > 0 || count($this->getDeleteDiff()) > 0);
if ( ! $dirty) {
foreach($this as $record) {
if ($dirty = $record->isModified()) {
break;
}
}
}
return $dirty;
}
}
}
return $dirty;
}

// [OV2] added
Expand Down
Loading
Loading