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

modules/Disqus/Disqus.php (1 issue)

Severity

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\Disqus;
3
4
use Redaxscript\Head;
5
use Redaxscript\Html;
6
use Redaxscript\Module;
7
8
/**
9
 * replace comments with disqus
10
 *
11
 * @since 2.2.0
12
 *
13
 * @package Redaxscript
14
 * @category Modules
15
 * @author Henry Ruhs
16
 */
17
18
class Disqus extends Module\Module
19
{
20
	/**
21
	 * array of the module
22
	 *
23
	 * @var array
24
	 */
25
26
	protected static $_moduleArray =
27
	[
28
		'name' => 'Disqus',
29
		'alias' => 'Disqus',
30
		'author' => 'Redaxmedia',
31
		'description' => 'Replace comments with Disqus',
32
		'version' => '4.0.0'
33
	];
34
35
	/**
36
	 * array of the option
37
	 *
38
	 * @var array
39
	 */
40
41
	protected $_optionArray =
42
	[
43
		'id' => 'disqus_thread',
44
		'url' => 'https://example.disqus.com/embed.js'
45
	];
46
47
	/**
48
	 * renderStart
49
	 *
50
	 * @since 2.2.0
51
	 */
52
53
	public function renderStart() : void
54
	{
55
		$this->_registry->set('commentReplace', 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
	}
57
58
	/**
59
	 * commentReplace
60
	 *
61
	 * @since 4.0.0
62
	 *
63
	 * @return string
64
	*/
65
66
	public function commentReplace() : string
67
	{
68
		$script = Head\Script::getInstance();
69
		$script
70
			->init('foot')
71
			->appendFile(
72
			[
73
				$this->_optionArray['url'],
74
				'modules/Disqus/assets/scripts/init.js'
75
			]);
76
77
		/* html element */
78
79
		$boxElement = new Html\Element();
80
		$boxElement->init('div',
81
		[
82
			'id' => $this->_optionArray['id']
83
		]);
84
85
		/* collect output */
86
87
		$output = $boxElement;
88
		return $output;
89
	}
90
}
91