Issues (203)

Plugin/Loader.php (19 issues)

1
<?php
2
namespace NirjharLo\Cgss;
3
4
if ( ! defined( 'ABSPATH' ) ) exit;
5
6
7
use \NirjharLo\Cgss\Lib\Script;
0 ignored issues
show
The type \NirjharLo\Cgss\Lib\Script was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
use \NirjharLo\Cgss\Lib\Action\Scan;
0 ignored issues
show
The type \NirjharLo\Cgss\Lib\Action\Scan was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use \NirjharLo\Cgss\Lib\Action\Insight;
0 ignored issues
show
The type \NirjharLo\Cgss\Lib\Action\Insight was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
use \NirjharLo\Cgss\Src\Db;
0 ignored issues
show
The type \NirjharLo\Cgss\Src\Db was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use \NirjharLo\Cgss\Src\Install;
0 ignored issues
show
The type \NirjharLo\Cgss\Src\Install was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use \NirjharLo\Cgss\Src\Settings;
0 ignored issues
show
The type \NirjharLo\Cgss\Src\Settings was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
17
final class Loader {
18
19
	/**
20
	 * Plugin Instance.
21
	 *
22
	 * @var PLUGIN_BUILD the PLUGIN Instance
0 ignored issues
show
The type NirjharLo\Cgss\PLUGIN_BUILD was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
	 */
24
	protected static $instance;
25
26
27
	/**
28
	 * Main Plugin Instance.
29
	 *
30
	 * @return PLUGIN_BUILD
31
	 */
32
	public static function instance() {
33
34
		if ( is_null( self::$instance ) ) {
35
			self::$instance = new self();
0 ignored issues
show
Documentation Bug introduced by
It seems like new self() of type NirjharLo\Cgss\Loader is incompatible with the declared type NirjharLo\Cgss\PLUGIN_BUILD of property $instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36
			self::$instance->init();
37
		}
38
39
		return self::$instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::instance also could return the type NirjharLo\Cgss\Loader which is incompatible with the documented return type NirjharLo\Cgss\PLUGIN_BUILD.
Loading history...
40
	}
41
42
	public function installation() {
43
44
			$install = new Install();
45
			$install->textDomin = 'cgss';
46
			$install->phpVerAllowed = '5.4';
47
			$install->pluginPageLinks = array(
48
											array(
49
												'slug' => home_url().'/wp-admin/admin.php?page=seo-scan',
0 ignored issues
show
The function home_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

49
												'slug' => /** @scrutinizer ignore-call */ home_url().'/wp-admin/admin.php?page=seo-scan',
Loading history...
50
												'label' => __( 'Dashboard', 'cgss' )
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

50
												'label' => /** @scrutinizer ignore-call */ __( 'Dashboard', 'cgss' )
Loading history...
51
											),
52
										);
53
			$install->execute();
54
	}
55
56
57
	public function db_install() {
58
59
			$db = new Db();
60
			$db->table = 'cgss_insight';
61
			$db->sql = "ID mediumint(9) NOT NULL AUTO_INCREMENT,
62
						item varchar(256) NOT NULL,
63
						remark varchar(512) NOT NULL,
64
						UNIQUE KEY ID (ID)";
65
			$db->build();
66
67
			$insert_data = $this->insert_prelim_data();
0 ignored issues
show
The assignment to $insert_data is dead and can be removed.
Loading history...
Are you sure the assignment to $insert_data is correct as $this->insert_prelim_data() targeting NirjharLo\Cgss\Loader::insert_prelim_data() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
68
	}
69
70
71
	public function db_uninstall() {
72
73
		$tableName = 'cgss_insight';
74
75
		global $wpdb;
76
		$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$tableName" );
77
	}
78
79
80
	public function insert_prelim_data() {
81
82
		global $wpdb;
83
84
		$result = $wpdb->get_results("SELECT * from {$wpdb->prefix}cgss_insight");
85
  		if(count($result) == 0) {
86
87
		$init_insight = array(
88
				__('Score','cgss'),
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

88
				/** @scrutinizer ignore-call */ 
89
    __('Score','cgss'),
Loading history...
89
				__('Snippet','cgss'),
90
				__('Text','cgss'),
91
				__('Links','cgss'),
92
				__('Keywords','cgss'),
93
				__('Images','cgss'),
94
				__('Responsive','cgss'),
95
				__('Speed','cgss'),
96
				__('Social','cgss')
97
			);
98
		$no_data = __( 'No scan reports are available yet', 'cgss' );
99
		foreach ($init_insight as $key => $value) {
100
			$sql = $wpdb->prepare(
101
				"INSERT INTO {$wpdb->prefix}cgss_insight ( ID, item, remark ) VALUES ( %d, %s, %s )", ($key+1), $value, $no_data
102
				);
103
			$query = $wpdb->query($sql);
0 ignored issues
show
The assignment to $query is dead and can be removed.
Loading history...
104
		}
105
		}
106
	}
107
108
109
	//Include scripts
110
	public function scripts() {
111
112
		new Script();
113
	}
114
115
116
117
	//Include settings pages
118
	public function settings() {
119
120
		new Settings();
121
	}
122
123
124
125
	// Add custom insight action
126
	public function insight() {
127
128
		new Insight();
129
	}
130
131
132
133
	// Add custom insight action
134
	public function scan() {
135
136
		new Scan();
137
	}
138
139
140
	public function init() {
141
142
		register_activation_hook( CGSS_FILE, array( $this, 'db_install' ) );
0 ignored issues
show
The function register_activation_hook was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

142
		/** @scrutinizer ignore-call */ 
143
  register_activation_hook( CGSS_FILE, array( $this, 'db_install' ) );
Loading history...
143
		register_uninstall_hook( CGSS_FILE, array( 'BUILD', 'db_uninstall' ) ); //$this won't work here.
0 ignored issues
show
The function register_uninstall_hook was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

143
		/** @scrutinizer ignore-call */ 
144
  register_uninstall_hook( CGSS_FILE, array( 'BUILD', 'db_uninstall' ) ); //$this won't work here.
Loading history...
144
145
		add_action('init', array($this, 'installation'));
0 ignored issues
show
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

145
		/** @scrutinizer ignore-call */ 
146
  add_action('init', array($this, 'installation'));
Loading history...
146
147
		$this->scripts();
148
		$this->settings();
149
150
		// Add custom actions, defined in settings
151
		add_action( 'cgss_scan', array( $this, 'scan' ) );
152
		add_action( 'cgss_fetch_insight', array( $this, 'insight' ) );
153
	}
154
} ?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
155