Issues (1358)

modules/HybridAuth/functions.php (2 issues)

1
<?php
2
/**
3
 * @package  HybridAuth
4
 * @category modules
5
 * @author   Nazar Mokrynskyi <[email protected]>
6
 * @license  0BSD
7
 */
8
namespace cs\modules\HybridAuth;
9
use
10
	Hybrid_Auth,
11
	cs\Config,
12
	cs\Request,
13
	cs\Session,
14
	cs\User;
15
16
/**
17
 * Get HybridAuth instance with current configuration. Strongly recommended instead of direct usage
18
 *
19
 * @param null|string $provider
20
 * @param null|string $base_url
21
 *
22
 * @return Hybrid_Auth
23
 */
24
function get_hybridauth_instance ($provider = null, $base_url = null) {
25
	require_once __DIR__.'/Hybrid/Auth.php';
26
	$Config     = Config::instance();
27
	$User       = User::instance();
28
	$HybridAuth = new Hybrid_Auth(
29
		[
30
			'base_url'  => $base_url ?: $Config->base_url()."/HybridAuth/$provider/endpoint/".md5($provider.Session::instance()->get_id()),
0 ignored issues
show
Are you sure cs\Session::instance()->get_id() of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
			'base_url'  => $base_url ?: $Config->base_url()."/HybridAuth/$provider/endpoint/".md5($provider./** @scrutinizer ignore-type */ Session::instance()->get_id()),
Loading history...
31
			'providers' => $Config->module('HybridAuth')->providers
0 ignored issues
show
Bug Best Practice introduced by
The property providers does not exist on cs\Config\Module_Properties. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
		]
33
	);
34
	if ($User->user() && Request::instance()->current_module != 'HybridAuth') {
35
		$HybridAuth->restoreSessionData(serialize($User->get_data('HybridAuth_session')));
36
	}
37
	return $HybridAuth;
38
}
39