Restore $uid parameter integer type-hint in Config
- Add integer type-hint to Feature::isEnabled
This commit is contained in:
		
					parent
					
						
							
								19247b62ae
							
						
					
				
			
			
				commit
				
					
						68f5b639eb
					
				
			
		
					 5 changed files with 31 additions and 31 deletions
				
			
		| 
						 | 
				
			
			@ -20,7 +20,7 @@ class Feature
 | 
			
		|||
	 * @return boolean
 | 
			
		||||
	 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
 | 
			
		||||
	 */
 | 
			
		||||
	public static function isEnabled($uid, $feature)
 | 
			
		||||
	public static function isEnabled(int $uid, $feature)
 | 
			
		||||
	{
 | 
			
		||||
		$x = Config::get('feature_lock', $feature, false);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,10 +32,10 @@ class JitPConfiguration extends PConfiguration
 | 
			
		|||
	 * {@inheritDoc}
 | 
			
		||||
	 *
 | 
			
		||||
	 */
 | 
			
		||||
	public function load($uid, string $cat = 'config')
 | 
			
		||||
	public function load(int $uid, string $cat = 'config')
 | 
			
		||||
	{
 | 
			
		||||
		// If not connected or no uid, do nothing
 | 
			
		||||
		if (!is_int($uid) || !$this->configModel->isConnected()) {
 | 
			
		||||
		if (!$uid || !$this->configModel->isConnected()) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -54,9 +54,9 @@ class JitPConfiguration extends PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	public function get($uid, string $cat, string $key, $default_value = null, bool $refresh = false)
 | 
			
		||||
	public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
 | 
			
		||||
	{
 | 
			
		||||
		if (!is_int($uid)) {
 | 
			
		||||
		if (!$uid) {
 | 
			
		||||
			return $default_value;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -84,9 +84,9 @@ class JitPConfiguration extends PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	public function set($uid, string $cat, string $key, $value)
 | 
			
		||||
	public function set(int $uid, string $cat, string $key, $value)
 | 
			
		||||
	{
 | 
			
		||||
		if (!is_int($uid)) {
 | 
			
		||||
		if (!$uid) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -108,9 +108,9 @@ class JitPConfiguration extends PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	public function delete($uid, string $cat, string $key)
 | 
			
		||||
	public function delete(int $uid, string $cat, string $key)
 | 
			
		||||
	{
 | 
			
		||||
		if (!is_int($uid)) {
 | 
			
		||||
		if (!$uid) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,16 +46,16 @@ abstract class PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * Loads all configuration values of a user's config family into a cached storage.
 | 
			
		||||
	 *
 | 
			
		||||
	 * All configuration values of the given user are stored with the $uid in
 | 
			
		||||
	 * the cache ( @param int $uid The user_id
 | 
			
		||||
	 * All configuration values of the given user are stored with the $uid in the cache
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param int $uid The user_id
 | 
			
		||||
	 * @param string $cat The category of the configuration value
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return void
 | 
			
		||||
	 * @see PConfigCache )
 | 
			
		||||
	 *
 | 
			
		||||
	 */
 | 
			
		||||
	abstract public function load($uid, string $cat = 'config');
 | 
			
		||||
	abstract public function load(int $uid, string $cat = 'config');
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get a particular user's config variable given the category name
 | 
			
		||||
| 
						 | 
				
			
			@ -73,7 +73,7 @@ abstract class PConfiguration
 | 
			
		|||
	 *
 | 
			
		||||
	 * @return mixed Stored value or null if it does not exist
 | 
			
		||||
	 */
 | 
			
		||||
	abstract public function get($uid, string $cat, string $key, $default_value = null, bool $refresh = false);
 | 
			
		||||
	abstract public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Sets a configuration value for a user
 | 
			
		||||
| 
						 | 
				
			
			@ -90,7 +90,7 @@ abstract class PConfiguration
 | 
			
		|||
	 *
 | 
			
		||||
	 * @return bool Operation success
 | 
			
		||||
	 */
 | 
			
		||||
	abstract public function set($uid, string $cat, string $key, $value);
 | 
			
		||||
	abstract public function set(int $uid, string $cat, string $key, $value);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Deletes the given key from the users's configuration.
 | 
			
		||||
| 
						 | 
				
			
			@ -105,5 +105,5 @@ abstract class PConfiguration
 | 
			
		|||
	 *
 | 
			
		||||
	 * @return bool
 | 
			
		||||
	 */
 | 
			
		||||
	abstract public function delete($uid, string $cat, string $key);
 | 
			
		||||
	abstract public function delete(int $uid, string $cat, string $key);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,10 +31,10 @@ class PreloadPConfiguration extends PConfiguration
 | 
			
		|||
	 * This loads all config values everytime load is called
 | 
			
		||||
	 *
 | 
			
		||||
	 */
 | 
			
		||||
	public function load($uid, string $cat = 'config')
 | 
			
		||||
	public function load(int $uid, string $cat = 'config')
 | 
			
		||||
	{
 | 
			
		||||
		// Don't load the whole configuration twice or with invalid uid
 | 
			
		||||
		if (!is_int($uid) || !empty($this->config_loaded[$uid])) {
 | 
			
		||||
		if (!$uid || !empty($this->config_loaded[$uid])) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -53,9 +53,9 @@ class PreloadPConfiguration extends PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	public function get($uid, string $cat, string $key, $default_value = null, bool $refresh = false)
 | 
			
		||||
	public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
 | 
			
		||||
	{
 | 
			
		||||
		if (!is_int($uid)) {
 | 
			
		||||
		if (!$uid) {
 | 
			
		||||
			return $default_value;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -79,9 +79,9 @@ class PreloadPConfiguration extends PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	public function set($uid, string $cat, string $key, $value)
 | 
			
		||||
	public function set(int $uid, string $cat, string $key, $value)
 | 
			
		||||
	{
 | 
			
		||||
		if (!is_int($uid)) {
 | 
			
		||||
		if (!$uid) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -105,9 +105,9 @@ class PreloadPConfiguration extends PConfiguration
 | 
			
		|||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	public function delete($uid, string $cat, string $key)
 | 
			
		||||
	public function delete(int $uid, string $cat, string $key)
 | 
			
		||||
	{
 | 
			
		||||
		if (!is_int($uid)) {
 | 
			
		||||
		if (!$uid) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,12 +35,12 @@ class PConfig
 | 
			
		|||
	/**
 | 
			
		||||
	 * @brief Loads all configuration values of a user's config family into a cached storage.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param string $uid The user_id
 | 
			
		||||
	 * @param int    $uid The user_id
 | 
			
		||||
	 * @param string $cat The category of the configuration value
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return void
 | 
			
		||||
	 */
 | 
			
		||||
	public static function load($uid, $cat)
 | 
			
		||||
	public static function load(int $uid, $cat)
 | 
			
		||||
	{
 | 
			
		||||
		self::$config->load($uid, $cat);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +49,7 @@ class PConfig
 | 
			
		|||
	 * @brief Get a particular user's config variable given the category name
 | 
			
		||||
	 * ($cat) and a key.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param string  $uid           The user_id
 | 
			
		||||
	 * @param int     $uid           The user_id
 | 
			
		||||
	 * @param string  $cat           The category of the configuration value
 | 
			
		||||
	 * @param string  $key           The configuration key to query
 | 
			
		||||
	 * @param mixed   $default_value optional, The value to return if key is not set (default: null)
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ class PConfig
 | 
			
		|||
	 *
 | 
			
		||||
	 * @return mixed Stored value or null if it does not exist
 | 
			
		||||
	 */
 | 
			
		||||
	public static function get($uid, $cat, $key, $default_value = null, $refresh = false)
 | 
			
		||||
	public static function get(int $uid, $cat, $key, $default_value = null, $refresh = false)
 | 
			
		||||
	{
 | 
			
		||||
		return self::$config->get($uid, $cat, $key, $default_value, $refresh);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -65,14 +65,14 @@ class PConfig
 | 
			
		|||
	/**
 | 
			
		||||
	 * @brief Sets a configuration value for a user
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param string $uid    The user_id
 | 
			
		||||
	 * @param int    $uid    The user_id
 | 
			
		||||
	 * @param string $cat    The category of the configuration value
 | 
			
		||||
	 * @param string $key    The configuration key to set
 | 
			
		||||
	 * @param mixed  $value  The value to store
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return bool Operation success
 | 
			
		||||
	 */
 | 
			
		||||
	public static function set($uid, $cat, $key, $value)
 | 
			
		||||
	public static function set(int $uid, $cat, $key, $value)
 | 
			
		||||
	{
 | 
			
		||||
		return self::$config->set($uid, $cat, $key, $value);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -80,13 +80,13 @@ class PConfig
 | 
			
		|||
	/**
 | 
			
		||||
	 * @brief Deletes the given key from the users's configuration.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param string $uid The user_id
 | 
			
		||||
	 * @param int    $uid The user_id
 | 
			
		||||
	 * @param string $cat The category of the configuration value
 | 
			
		||||
	 * @param string $key The configuration key to delete
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return bool
 | 
			
		||||
	 */
 | 
			
		||||
	public static function delete($uid, $cat, $key)
 | 
			
		||||
	public static function delete(int $uid, $cat, $key)
 | 
			
		||||
	{
 | 
			
		||||
		return self::$config->delete($uid, $cat, $key);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue