Version 5.0.0 beta 4
This commit is contained in:
1 parent
e86153356a
commit
2f24f9de48
276 files changed
+8614
-6044
No files matched your search
@@ -19,6 +19,7 @@ use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Exception as DbException;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use OutOfRangeException;
|
||||
@@ -66,7 +67,7 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* @brief Array Storage of loaded ID links.
|
||||
*/
|
||||
protected $linkCache = array();
|
||||
protected array $linkCache = array();
|
||||
|
||||
/**
|
||||
* @brief Flag to indicate the log is simply a notice, and that it is informational only. Useful for when data is missing, but can be covered via default values.
|
||||
@@ -88,7 +89,7 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @return ActiveRecordIterator
|
||||
*/
|
||||
public static function apps()
|
||||
public static function apps() : ActiveRecordIterator
|
||||
{
|
||||
return new ActiveRecordIterator( new ArrayIterator( static::getStore() ), 'IPS\convert\App' );
|
||||
}
|
||||
@@ -106,7 +107,7 @@ class App extends ActiveRecord
|
||||
{
|
||||
$rows = iterator_to_array( Db::i()->select( '*', 'convert_apps', array(), 'app_id ASC' ) );
|
||||
}
|
||||
catch ( \IPS\Db\Exception $e )
|
||||
catch ( DbException $e )
|
||||
{
|
||||
if ( $e->getCode() === 1146 )
|
||||
{
|
||||
@@ -172,15 +173,15 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* @brief Session data store
|
||||
*/
|
||||
protected $_sessionData = null;
|
||||
protected ?array $_sessionData = null;
|
||||
|
||||
/**
|
||||
* Save Session Data for this application
|
||||
*
|
||||
* @param array $value Session Data
|
||||
* @param array|null $value Session Data
|
||||
* @return void
|
||||
*/
|
||||
public function set__session( $value )
|
||||
public function set__session( ?array $value ) : void
|
||||
{
|
||||
Db::i()->update( 'convert_app_sessions', array( 'session_app_data' => json_encode( $value ) ), array( 'session_app_id=?', $this->app_id ) );
|
||||
|
||||
@@ -192,7 +193,7 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get__session()
|
||||
public function get__session() : array
|
||||
{
|
||||
/* Use ready-cached session data */
|
||||
if( $this->_sessionData !== null )
|
||||
@@ -221,31 +222,28 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_sw()
|
||||
public function get_sw() : string
|
||||
{
|
||||
switch( $this->_data['sw'] )
|
||||
{
|
||||
case 'board':
|
||||
return 'forums';
|
||||
break;
|
||||
|
||||
case 'ccs':
|
||||
return 'cms';
|
||||
break;
|
||||
|
||||
default:
|
||||
return $this->_data['sw'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Legacy] Automatically fix any legacy application keys that have changed.
|
||||
*
|
||||
* @param string $value App value
|
||||
* @param string|null $value App value
|
||||
* @return void
|
||||
*/
|
||||
public function set_sw( $value )
|
||||
public function set_sw( ?string $value ) : void
|
||||
{
|
||||
switch( $value )
|
||||
{
|
||||
@@ -266,7 +264,7 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* @brief Parent Store
|
||||
*/
|
||||
protected $parentStore = NULL;
|
||||
protected ?App $parentStore = NULL;
|
||||
|
||||
/**
|
||||
* Get parent application
|
||||
@@ -274,7 +272,7 @@ class App extends ActiveRecord
|
||||
* @return App
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function get__parent()
|
||||
public function get__parent() : App
|
||||
{
|
||||
if ( is_null( $this->parentStore ) )
|
||||
{
|
||||
@@ -287,11 +285,7 @@ class App extends ActiveRecord
|
||||
{
|
||||
$this->parentStore = static::constructFromData( Db::i()->select( '*', 'convert_apps', array( "app_id=?", $this->parent ) )->first() );
|
||||
}
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
throw new BadMethodCallException;
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
catch( UnderflowException|OutOfRangeException $e )
|
||||
{
|
||||
throw new BadMethodCallException;
|
||||
}
|
||||
@@ -305,7 +299,7 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @return array|ActiveRecordIterator
|
||||
*/
|
||||
public function children()
|
||||
public function children() : array|ActiveRecordIterator
|
||||
{
|
||||
/* If we have a parent, we are already a child and will not have children */
|
||||
if( $this->parent )
|
||||
@@ -321,13 +315,13 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @param mixed $foreign_id The Foreign ID
|
||||
* @param string|array $type The type of item, or an array of types to check.
|
||||
* @param boolean $parent If set to TRUE, then retrieves from the parent application if one is available.
|
||||
* @param boolean $mainTable If set to TRUE, and the type is of either 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts', then the ID is retrieved from convert_link, rather than the other link tables.
|
||||
* @param bool $parent If set to TRUE, then retrieves from the parent application if one is available.
|
||||
* @param bool $mainTable If set to TRUE, and the type is of either 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts', then the ID is retrieved from convert_link, rather than the other link tables.
|
||||
*
|
||||
* @return integer The Invision Community ID.
|
||||
* @return int The Invision Community ID.
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function getLink( $foreign_id, $type, $parent=FALSE, $mainTable=FALSE )
|
||||
public function getLink( mixed $foreign_id, string|array $type, bool $parent=FALSE, bool $mainTable=FALSE ) : int
|
||||
{
|
||||
if ( !is_array( $type ) )
|
||||
{
|
||||
@@ -393,7 +387,7 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* @brief Sibling Link Cache
|
||||
*/
|
||||
protected $siblingLinkCache = array();
|
||||
protected array $siblingLinkCache = array();
|
||||
|
||||
/**
|
||||
* Retrieves an Invision Community iD from a Foriegn ID in a Sibling Application
|
||||
@@ -401,12 +395,12 @@ class App extends ActiveRecord
|
||||
* @param mixed $foreign_id The Foreign ID.
|
||||
* @param string $type The type of item.
|
||||
* @param string $sibling The sibling software library.
|
||||
* @param boolean $mainTable If set to TRUE, and the type is of either 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts', then the ID is retrieved from convert_link, rather than the other link tables.
|
||||
* @param bool $mainTable If set to TRUE, and the type is of either 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts', then the ID is retrieved from convert_link, rather than the other link tables.
|
||||
*
|
||||
* @return inteer The Invision Community ID.
|
||||
* @return int The Invision Community ID.
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function getSiblingLink( $foreign_id, $type, $sibling, $mainTable=FALSE )
|
||||
public function getSiblingLink( mixed $foreign_id, string $type, string $sibling, bool $mainTable=FALSE ) : int
|
||||
{
|
||||
if ( isset( $this->siblingLinkCache[$type][$sibling][$foreign_id] ) )
|
||||
{
|
||||
@@ -428,14 +422,14 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* Saves a foreign ID to Invision Community ID reference to the convert_link tables.
|
||||
*
|
||||
* @param integer $ips_id The Invision Community ID
|
||||
* @param int $ips_id The Invision Community ID
|
||||
* @param mixed $foreign_id The Foreign ID
|
||||
* @param string $type The type of item
|
||||
* @param boolean $duplicate If TRUE, then this item is a duplicate and was merged into existing $ips_id
|
||||
* @param boolean $mainTable If TRUE, then link will be stored in the main convert_link table even if $type is 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts'
|
||||
* @param bool $duplicate If TRUE, then this item is a duplicate and was merged into existing $ips_id
|
||||
* @param bool $mainTable If TRUE, then link will be stored in the main convert_link table even if $type is 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts'
|
||||
* @return void
|
||||
*/
|
||||
public function addLink( $ips_id, $foreign_id, $type, $duplicate=FALSE, $mainTable=FALSE )
|
||||
public function addLink( int $ips_id, mixed $foreign_id, string $type, bool $duplicate=FALSE, bool $mainTable=FALSE ) : void
|
||||
{
|
||||
$table = 'convert_link';
|
||||
|
||||
@@ -468,8 +462,9 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $map
|
||||
* @return void
|
||||
*/
|
||||
public function preCacheLinks( array $data, array $map )
|
||||
public function preCacheLinks( array $data, array $map ) : void
|
||||
{
|
||||
$cachesToLookup = [];
|
||||
$tables = [];
|
||||
@@ -536,13 +531,13 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* Checks to see if a link exists for an Invision Community ID
|
||||
*
|
||||
* @param integer $ips_id The Invision Community ID.
|
||||
* @param int $ips_id The Invision Community ID.
|
||||
* @param string $type The type of item
|
||||
* @param bool $mainTable If TRUE, then link will be check against the main convert_link table even if $type is 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', or 'forums_posts'
|
||||
* @return void
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function checkLink( $ips_id, $type, $mainTable=FALSE )
|
||||
public function checkLink( int $ips_id, string $type, bool $mainTable=FALSE ) : void
|
||||
{
|
||||
$table = $this->_getLinkTableName( $type, $mainTable );
|
||||
|
||||
@@ -563,7 +558,7 @@ class App extends ActiveRecord
|
||||
* @return void
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function checkForSibling( $software )
|
||||
public function checkForSibling( string $software ) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -582,7 +577,7 @@ class App extends ActiveRecord
|
||||
* @param string $type The type of item
|
||||
* @return void
|
||||
*/
|
||||
public function deleteLink( $foreignId, string $type )
|
||||
public function deleteLink( mixed $foreignId, string $type ) : void
|
||||
{
|
||||
$table = $this->_getLinkTableName( $type );
|
||||
|
||||
@@ -598,7 +593,7 @@ class App extends ActiveRecord
|
||||
/**
|
||||
* @brief Sibling Cache
|
||||
*/
|
||||
protected $siblingCache = array();
|
||||
protected array $siblingCache = array();
|
||||
|
||||
/**
|
||||
* Construct an \IPS\convert\App object for a sibling application.
|
||||
@@ -607,7 +602,7 @@ class App extends ActiveRecord
|
||||
* @return App
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function getSibling( $software )
|
||||
public function getSibling( string $software ) : App
|
||||
{
|
||||
if ( !isset( $this->siblingCache[$software] ) )
|
||||
{
|
||||
@@ -632,14 +627,13 @@ class App extends ActiveRecord
|
||||
* @return Software|string
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getSource( $construct=TRUE, $needDB=TRUE )
|
||||
public function getSource( bool $construct=TRUE, bool $needDB=TRUE ) : Software|string
|
||||
{
|
||||
/* Update software keys for communities converted to 3.x */
|
||||
switch( $this->_data['sw'] )
|
||||
{
|
||||
case 'board':
|
||||
case 'ccs':
|
||||
$this->sw = $this->sw;
|
||||
$this->save();
|
||||
break;
|
||||
}
|
||||
@@ -717,12 +711,12 @@ class App extends ActiveRecord
|
||||
*
|
||||
* @param string $message The message to log.
|
||||
* @param string $method The current conversion method (convert_posts, convert_topics, etc.)
|
||||
* @param integer $severity The severity level of the log. Default to LOG_NOTICE
|
||||
* @param int $severity The severity level of the log. Default to LOG_NOTICE
|
||||
* @param int|NULL $id The item ID
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function log( $message, $method, $severity=1, $id=NULL )
|
||||
public function log( string $message, string $method, int $severity=1, ?int $id=NULL ) : void
|
||||
{
|
||||
if ( ! in_array( $severity, array( static::LOG_NOTICE, static::LOG_WARNING, static::LOG_ERROR ) ) )
|
||||
{
|
||||
@@ -743,9 +737,9 @@ class App extends ActiveRecord
|
||||
* Callback function to return all dependencies not yet converted.
|
||||
*
|
||||
* @param string $value Value from depency array
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function dependencies( $value )
|
||||
public function dependencies( string $value ) : bool
|
||||
{
|
||||
if ( !in_array( $value, $this->_session['completed'] ) )
|
||||
{
|
||||
@@ -762,7 +756,7 @@ class App extends ActiveRecord
|
||||
* @param array $values Values from the form.
|
||||
* @return void
|
||||
*/
|
||||
public function saveMoreInfo( $method, $values=array() )
|
||||
public function saveMoreInfo( string $method, array $values=array() ) : void
|
||||
{
|
||||
$sessionData = $this->_session;
|
||||
|
||||
@@ -777,7 +771,7 @@ class App extends ActiveRecord
|
||||
* @param mixed $key key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset( $key )
|
||||
public function __isset( mixed $key ) : bool
|
||||
{
|
||||
if ( method_exists( $this, 'get_' . $key ) )
|
||||
{
|
||||
@@ -799,9 +793,9 @@ class App extends ActiveRecord
|
||||
* @param bool $status Flag status
|
||||
* @return void
|
||||
*/
|
||||
public function setRunningFlag( $method, $status )
|
||||
public function setRunningFlag( string $method, bool $status ) : void
|
||||
{
|
||||
$running = isset( $this->_session['running'] ) ? $this->_session['running'] : array();
|
||||
$running = $this->_session['running'] ?? array();
|
||||
|
||||
/* If setting running flag, set to a timestamp */
|
||||
if( $status === TRUE )
|
||||
@@ -820,7 +814,7 @@ class App extends ActiveRecord
|
||||
* @param string $method Method name
|
||||
* @return bool|int False or a timestamp
|
||||
*/
|
||||
public function getRunningFlag( $method )
|
||||
public function getRunningFlag( string $method ) : bool|int
|
||||
{
|
||||
if( isset( $this->_session['running'][ $method ] ) )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user