Skip to content

Commit 7dcddad

Browse files
authored
Table: add _clone() shim from Sugar Calendar. (#131)
For PHP 5.6 compatibility. Fixes #38.
1 parent 2d94af5 commit 7dcddad

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Database/Table.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,24 @@ public function __construct() {
160160
}
161161
}
162162

163+
/**
164+
* Compatibility for clone() method for PHP versions less than 7.0.
165+
*
166+
* See: https://github.com/sugarcalendar/core/issues/105
167+
*
168+
* This shim will be removed at a later date.
169+
*
170+
* @since 2.0.20
171+
*
172+
* @param string $function
173+
* @param array $args
174+
*/
175+
public function __call( $function = '', $args = array() ) {
176+
if ( 'clone' === $function ) {
177+
call_user_func_array( array( $this, '_clone' ), $args );
178+
}
179+
}
180+
163181
/** Abstract **************************************************************/
164182

165183
/**
@@ -488,7 +506,7 @@ public function delete_all() {
488506
*
489507
* @return bool
490508
*/
491-
public function clone( $new_table_name = '' ) {
509+
public function _clone( $new_table_name = '' ) {
492510

493511
// Get the database interface
494512
$db = $this->get_db();

0 commit comments

Comments
 (0)