Skip to content

Commit

Permalink
Table: add _clone() shim from Sugar Calendar. (#131)
Browse files Browse the repository at this point in the history
For PHP 5.6 compatibility.

Fixes #38.
  • Loading branch information
JJJ authored Mar 10, 2022
1 parent 2d94af5 commit 7dcddad
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Database/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ public function __construct() {
}
}

/**
* Compatibility for clone() method for PHP versions less than 7.0.
*
* See: https://github.com/sugarcalendar/core/issues/105
*
* This shim will be removed at a later date.
*
* @since 2.0.20
*
* @param string $function
* @param array $args
*/
public function __call( $function = '', $args = array() ) {
if ( 'clone' === $function ) {
call_user_func_array( array( $this, '_clone' ), $args );
}
}

/** Abstract **************************************************************/

/**
Expand Down Expand Up @@ -488,7 +506,7 @@ public function delete_all() {
*
* @return bool
*/
public function clone( $new_table_name = '' ) {
public function _clone( $new_table_name = '' ) {

// Get the database interface
$db = $this->get_db();
Expand Down

0 comments on commit 7dcddad

Please sign in to comment.