Completed
Push — master ( 0ea243...da58d4 )
by Henry
10:25 queued 33s
created

modules/LiveReload/LiveReload.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Modules\LiveReload;
3
4
use Redaxscript\Head;
5
use Redaxscript\Module;
6
use Redaxscript\Reader;
7
8
/**
9
 * live reload
10
 *
11
 * @since 3.3.0
12
 *
13
 * @package Redaxscript
14
 * @category Modules
15
 * @author Henry Ruhs
16
 */
17
18
class LiveReload extends Module\Notification
19
{
20
	/**
21
	 * array of the module
22
	 *
23
	 * @var array
24
	 */
25
26
	protected static $_moduleArray =
27
	[
28
		'name' => 'Live Reload',
29
		'alias' => 'LiveReload',
30
		'author' => 'Redaxmedia',
31
		'description' => 'Launch a local PHP server with live reload',
32
		'version' => '4.0.0',
33
		'access' => '[1]'
34
	];
35
36
	/**
37
	 * array of the option
38
	 *
39
	 * @var array
40
	 */
41
42
	protected $_optionArray =
43
	[
44
		'url' => 'http://localhost:7000/livereload.js'
45
	];
46
47
	/**
48
	 * renderStart
49
	 *
50
	 * @since 3.3.0
51
	 */
52
53
	public function renderStart() : void
54
	{
55
		$this->_registry->set('noCache', true);
0 ignored issues
show
true is of type boolean, but the function expects a string|array|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
		$script = Head\Script::getInstance();
57
		$script
58
			->init('foot')
59
			->appendFile($this->_optionArray['url']);
60
	}
61
62
	/**
63
	 * adminNotification
64
	 *
65
	 * @since 3.3.0
66
	 *
67
	 * @return array|null
68
	 */
69
70
	public function adminNotification() : ?array
71
	{
72
		$reader = new Reader();
73
		$reader->init();
74
		$content = $reader->load($this->_optionArray['url']);
75
76
		/* handle notification */
77
78
		if ($content)
79
		{
80
			$this->setNotification('success', $this->_language->get('server_online', '_live_reload') . $this->_language->get('point'));
81
		}
82
		else
83
		{
84
			$this->setNotification('error', $this->_language->get('server_offline', '_live_reload') . $this->_language->get('colon') . ' ' . $this->_optionArray['url']);
85
		}
86
		return $this->getNotification();
87
	}
88
}
89