diff --git a/src/Connection.php b/src/Connection.php index 68303629..1759ee12 100755 --- a/src/Connection.php +++ b/src/Connection.php @@ -41,6 +41,16 @@ class Connection implements ConnectionInterface */ protected $silence_connection_warning = false; + private static function deprecated($old, $use = null) { + $string = 'The method '.$old.' was deprecated and will not be available in version 1.0.0 of SphinxQL Query Builder.'; + if ($use !== null) { + $string .= ' Use the method '.$use.' instead.'; + } + $string .= ' Refer to the SphinxQL Query Builder README for more information.'; + + trigger_error($string, E_USER_DEPRECATED); + } + /** * Forces the \MySQLi connection to suppress all errors returned. This should only be used * when the production server is running with high error reporting settings. @@ -102,6 +112,8 @@ public function setParam($param, $value) */ public function setConnectionParams($host = '127.0.0.1', $port = 9306) { + static::deprecated('Connection::setConnectionparams()', 'Connection::setParams()'); + $this->setParam('host', $host); $this->setParam('port', $port); } @@ -134,6 +146,8 @@ public function getInternalEncoding() */ public function getConnectionParams() { + static::deprecated('Connection::getConnectionParams()', 'Connection::getParams()'); + return $this->getParams(); } diff --git a/src/SphinxQL.php b/src/SphinxQL.php index 5ccae817..c1bbf28d 100644 --- a/src/SphinxQL.php +++ b/src/SphinxQL.php @@ -219,23 +219,34 @@ public function __construct(ConnectionInterface $connection = null, $static = fa } } + private static function deprecated($old, $use = null) { + $string = 'The method '.$old.' was deprecated and will not be available in version 1.0.0 of SphinxQL Query Builder.'; + if ($use !== null) { + $string .= ' Use the method '.$use.' instead.'; + } + $string .= ' Refer to the SphinxQL Query Builder README for more information.'; + + trigger_error($string, E_USER_DEPRECATED); + } + /** * Forges a SphinxQL object with a Connection shared among all SphinxQL objects * - * @param null|Connection $connection + * @param null|ConnectionInterface $connection * * @return \Foolz\SphinxQL\SphinxQL The current object * @deprecated Use ::create instead, coupled with an own static method if static connection is necessary */ public static function forge(ConnectionInterface $connection = null) { + static::deprecated('SphinxQL::forge()', 'SphinxQL::create()'); return new SphinxQL($connection, true); } /** * Creates and setups a SphinxQL object * - * @param Connection $connection + * @param ConnectionInterface $connection * * @return \Foolz\SphinxQL\SphinxQL The current object */ @@ -428,6 +439,8 @@ public function getCompiled() */ public function setVariable($name, $value, $global = false) { + static::deprecated('SphinxQL::setVariable()', 'Helper::create()'); + $query = 'SET '; if ($global) { @@ -491,6 +504,8 @@ public function transactionRollback() */ public function callSnippets($data, $index, $extra = array()) { + static::deprecated('SphinxQL::callSnippets()', 'Helper::callSnippets()'); + array_unshift($extra, $index); array_unshift($extra, $data); @@ -509,6 +524,8 @@ public function callSnippets($data, $index, $extra = array()) */ public function callKeywords($text, $index, $hits = null) { + static::deprecated('SphinxQL::callKeywords()', 'Helper::callKeywords()'); + $arr = array($text, $index); if ($hits !== null) { $arr[] = $hits; @@ -527,6 +544,8 @@ public function callKeywords($text, $index, $hits = null) */ public function describe($index) { + static::deprecated('SphinxQL::describe()', 'Helper::describe()'); + return $this->getConnection()->query('DESCRIBE '.$this->getConnection()->quoteIdentifier($index)); } @@ -542,6 +561,8 @@ public function describe($index) */ public function createFunction($udf_name, $returns, $so_name) { + static::deprecated('SphinxQL::createFunction()', 'Helper::createFunction()'); + return $this->getConnection()->query('CREATE FUNCTION '.$this->getConnection()->quoteIdentifier($udf_name). ' RETURNS '.$returns.' SONAME '.$this->getConnection()->quote($so_name)); } @@ -556,6 +577,8 @@ public function createFunction($udf_name, $returns, $so_name) */ public function dropFunction($udf_name) { + static::deprecated('SphinxQL::dropFunction()', 'Helper::dropFunction()'); + return $this->getConnection()->query('DROP FUNCTION '.$this->getConnection()->quoteIdentifier($udf_name)); } @@ -570,6 +593,8 @@ public function dropFunction($udf_name) */ public function attachIndex($disk_index, $rt_index) { + static::deprecated('SphinxQL::attachIndex()', 'Helper::attachIndex()'); + return $this->getConnection()->query('ATTACH INDEX '.$this->getConnection()->quoteIdentifier($disk_index). ' TO RTINDEX '. $this->getConnection()->quoteIdentifier($rt_index)); } @@ -584,6 +609,8 @@ public function attachIndex($disk_index, $rt_index) */ public function flushRtIndex($index) { + static::deprecated('SphinxQL::flushRtIndex()', 'Helper::flushRtIndex()'); + return $this->getConnection()->query('FLUSH RTINDEX '.$this->getConnection()->quoteIdentifier($index)); }