Browse Source

Prevent duplicate class declarations

Andreas Braun 10 years ago
parent
commit
d08e992a4d

+ 4 - 0
lib/Mongo/Mongo.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('Mongo', false)) {
+    return;
+}
+
 /**
  * The connection point between MongoDB and PHP.
  * This class is used to initiate a connection and for database server commands.

+ 4 - 0
lib/Mongo/MongoBinData.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoBinData', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\Binary;
 use MongoDB\BSON\Type;

+ 4 - 0
lib/Mongo/MongoClient.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoClient', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\Helper;
 use Alcaeus\MongoDbAdapter\ExceptionConverter;
 use MongoDB\Client;

+ 4 - 0
lib/Mongo/MongoCode.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCode', false)) {
+    return;
+}
+
 class MongoCode implements \Alcaeus\MongoDbAdapter\TypeInterface
 {
     /**

+ 4 - 0
lib/Mongo/MongoCollection.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCollection', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\Helper;
 use Alcaeus\MongoDbAdapter\TypeConverter;
 use Alcaeus\MongoDbAdapter\ExceptionConverter;

+ 4 - 0
lib/Mongo/MongoCommandCursor.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCommandCursor', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\AbstractCursor;
 use Alcaeus\MongoDbAdapter\TypeConverter;
 

+ 4 - 0
lib/Mongo/MongoConnectionException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoConnectionException', false)) {
+    return;
+}
+
 class MongoConnectionException extends MongoException {
 
 }

+ 4 - 0
lib/Mongo/MongoCursor.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCursor', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\AbstractCursor;
 use Alcaeus\MongoDbAdapter\TypeConverter;
 use Alcaeus\MongoDbAdapter\ExceptionConverter;

+ 4 - 0
lib/Mongo/MongoCursorException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCursorException', false)) {
+    return;
+}
+
 class MongoCursorException extends MongoException {
 
 }

+ 4 - 0
lib/Mongo/MongoCursorInterface.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCursorInterface', false)) {
+    return;
+}
+
 interface MongoCursorInterface extends Iterator
 {
     /**

+ 4 - 0
lib/Mongo/MongoCursorTimeoutException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoCursorTimeoutException', false)) {
+    return;
+}
+
 class MongoCursorTimeoutException extends MongoCursorException {
 
 }

+ 4 - 0
lib/Mongo/MongoDB.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoDB', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\Helper;
 use Alcaeus\MongoDbAdapter\TypeConverter;
 use Alcaeus\MongoDbAdapter\ExceptionConverter;

+ 4 - 0
lib/Mongo/MongoDBRef.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoDBRef', false)) {
+    return;
+}
+
 class MongoDBRef
 {
     /**

+ 4 - 0
lib/Mongo/MongoDate.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoDate', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\UTCDateTime;
 

+ 4 - 0
lib/Mongo/MongoDeleteBatch.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoDeleteBatch', false)) {
+    return;
+}
+
 /**
  * Constructs a batch of DELETE operations
  *

+ 4 - 0
lib/Mongo/MongoDuplicateKeyException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoDuplicateKeyException', false)) {
+    return;
+}
+
 /**
  * <p>(PECL mongo &gt;= 1.5.0)</p>
  * @link http://php.net/manual/en/class.mongoduplicatekeyexception.php

+ 4 - 0
lib/Mongo/MongoException.php

@@ -13,5 +13,9 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoException', false)) {
+    return;
+}
+
 class MongoException extends Exception {
 }

+ 4 - 0
lib/Mongo/MongoExecutionTimeoutException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoExecutionTimeoutException', false)) {
+    return;
+}
+
 /**
  * <p>(PECL mongo &gt;= 1.5.0)</p>
  * @link http://php.net/manual/en/class.mongoexecutiontimeoutexception.php

+ 4 - 0
lib/Mongo/MongoGridFS.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoGridFS', false)) {
+    return;
+}
+
 class MongoGridFS extends MongoCollection
 {
     const ASCENDING = 1;

+ 4 - 0
lib/Mongo/MongoGridFSCursor.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoGridFSCursor', false)) {
+    return;
+}
+
 class MongoGridFSCursor extends MongoCursor
 {
     /**

+ 4 - 0
lib/Mongo/MongoGridFSException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoGridFSException', false)) {
+    return;
+}
+
 class MongoGridFSException extends MongoException {
 
 }

+ 4 - 0
lib/Mongo/MongoGridFSFile.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoGridFSFile', false)) {
+    return;
+}
+
 class MongoGridFSFile
 {
     /**

+ 4 - 0
lib/Mongo/MongoId.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoId', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\ObjectID;
 

+ 4 - 0
lib/Mongo/MongoInsertBatch.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoInsertBatch', false)) {
+    return;
+}
+
 /**
  * Constructs a batch of INSERT operations
  *

+ 4 - 0
lib/Mongo/MongoInt32.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoInt32', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 
 class MongoInt32 implements TypeInterface

+ 4 - 0
lib/Mongo/MongoInt64.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoInt64', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 
 class MongoInt64 implements TypeInterface

+ 4 - 0
lib/Mongo/MongoLog.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoLog', false)) {
+    return;
+}
+
 class MongoLog
 {
     /**

+ 4 - 0
lib/Mongo/MongoMaxKey.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoMaxKey', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\MaxKey;
 

+ 4 - 0
lib/Mongo/MongoMinKey.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoMinKey', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\MinKey;
 

+ 4 - 0
lib/Mongo/MongoPool.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoPool', false)) {
+    return;
+}
+
 /**
  * @deprecated The current (1.3.0+) releases of the driver no longer implements pooling. This class and its methods are therefore deprecated and should not be used.
  */

+ 4 - 0
lib/Mongo/MongoProtocolException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoProtocolException', false)) {
+    return;
+}
+
 /**
  * <p>(PECL mongo &gt;= 1.5.0)</p>
  */

+ 4 - 0
lib/Mongo/MongoRegex.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoRegex', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\Regex;
 

+ 4 - 0
lib/Mongo/MongoResultException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoResultException', false)) {
+    return;
+}
+
 /**
  * <p>(PECL mongo &gt;= 1.3.0)</p>
  * @link http://php.net/manual/en/class.mongoresultexception.php#mongoresultexception.props.document

+ 4 - 0
lib/Mongo/MongoTimestamp.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoTimestamp', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeInterface;
 use MongoDB\BSON\Timestamp;
 

+ 4 - 0
lib/Mongo/MongoUpdateBatch.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoUpdateBatch', false)) {
+    return;
+}
+
 /**
  * Constructs a batch of UPDATE operations
  *

+ 4 - 0
lib/Mongo/MongoWriteBatch.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoWriteBatch', false)) {
+    return;
+}
+
 use Alcaeus\MongoDbAdapter\TypeConverter;
 use Alcaeus\MongoDbAdapter\Helper\WriteConcernConverter;
 

+ 4 - 0
lib/Mongo/MongoWriteConcernException.php

@@ -13,6 +13,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+if (class_exists('MongoWriteConcernException', false)) {
+    return;
+}
+
 /**
  * <p>(PECL mongo &gt;= 1.5.0)</p>
  * @link http://php.net/manual/en/class.mongowriteconcernexception.php#class.mongowriteconcernexception