Issues (1686)

sources/ElkArte/Modules/AbstractModule.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * Abstract for modules.
5
 *
6
 * @package   ElkArte Forum
7
 * @copyright ElkArte Forum contributors
8
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
9
 *
10
 * @version 2.0 dev
11
 *
12
 */
13
14
namespace ElkArte\Modules;
15
16
use ElkArte\Helper\HttpReq;
17
use ElkArte\UserInfo;
18
19
/**
20
 * Abstract AbstractModule Provides some standard values to modules
21
 *
22
 * @package ElkArte\sources\modules
23
 */
24
abstract class AbstractModule implements ModuleInterface
25
{
26
	/** @var HttpReq|null Access to post/get data */
27
	protected $_req;
28
29
	/** @var UserInfo|null User Info ValuesContainer */
30
	protected $user;
31
32
	/**
33
	 * AbstractModule constructor.
34
	 *
35
	 * @param HttpReq $req
36
	 * @param UserInfo $user
37
	 */
38
	public function __construct(HttpReq $req, UserInfo $user)
39
	{
40
		$this->_req = $req;
41
		$this->user = $user;
42
	}
43
44
	/**
45
	 * Helper function to see if a request is asking for any api processing
46
	 *
47
	 * @return string|false
48
	 */
49
	public function getApi()
50
	{
51
		// API Call?
52
		$api = $this->_req->getRequest('api', 'trim', '');
0 ignored issues
show
The method getRequest() does not exist on null. ( Ignorable by Annotation )

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

52
		/** @scrutinizer ignore-call */ 
53
  $api = $this->_req->getRequest('api', 'trim', '');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
54
		return in_array($api, ['xml', 'json', 'html']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) ? $api : false;
55
	}
56
}
57