Skip to content

Commit af2bbe4

Browse files
authored
Merge pull request #3 from cafuego/php8-updates-for-staging
Php8 updates for staging
2 parents 115df17 + 419bc4c commit af2bbe4

17 files changed

Lines changed: 172 additions & 169 deletions

File tree

.github/workflows/php.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
tools: composer
2121
env:
2222
fail-fast: true
23+
- name: Lint
24+
run: make lint-ci
25+
env:
26+
fail-fast: true
2327
- name: composer
2428
run: composer install
2529
env:
@@ -28,7 +32,7 @@ jobs:
2832
run: composer validate
2933
env:
3034
fail-fast: true
31-
- name: Lint
32-
run: make lint-ci
35+
- name: phpcs
36+
run: make phpcs-ci
3337
env:
3438
fail-fast: true

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ docker-run:
2424
docker: docker-build docker-run
2525

2626
lint:
27-
./vendor/bin/phpcs --tab-width=4 --report=summary www scripts
27+
find -L www scripts -iregex '.*\.php$$' -print0 | xargs -0 -n 1 -P 4 php -l
2828

29-
lint-verbose:
30-
./vendor/bin/phpcs --tab-width=4 www scripts
29+
lint-ci: lint
3130

32-
lint-ci:
33-
./vendor/bin/phpcs --tab-width=4 www scripts --report=json --report-file=phpcs-report.json
31+
phpcs:
32+
./vendor/bin/phpcs --standard=phpcs.xml --tab-width=4 --report=summary www scripts
33+
34+
phpcs-verbose:
35+
./vendor/bin/phpcs --standard=phpcs.xml --tab-width=4 www scripts
36+
37+
phpcs-ci:
38+
./vendor/bin/phpcs --standard=phpcs.xml --tab-width=4 www scripts --report=json --report-file=phpcs-report.json

phpcs.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,22 @@
1414
<!-- Disable a few sniffs. -->
1515
<rule ref="Drupal">
1616
<exclude name="Drupal.Arrays.Array"/>
17+
<exclude name="Drupal.Classes.ClassFileName"/>
1718
<exclude name="Drupal.Commenting.DocComment"/>
19+
<exclude name="Drupal.Commenting.VariableComment"/>
20+
<exclude name="Drupal.NamingConventions.ValidClassName"/>
1821
<exclude name="Drupal.NamingConventions.ValidGlobal"/>
22+
<exclude name="Drupal.NamingConventions.ValidFunctionName"/>
1923
<exclude name="Drupal.NamingConventions.ValidVariableName"/>
2024
</rule>
2125

26+
<!-- Override some settings -->
27+
<rule ref="Drupal.WhiteSpace.ScopeIndent">
28+
<properties>
29+
<property name="indent" value="4"/>
30+
</properties>
31+
</rule>
32+
2233
<!--Exclude third party code.-->
2334
<exclude-pattern>./vendor/*</exclude-pattern>
2435

www/includes/data.php

Lines changed: 9 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,16 @@
7272
*/
7373
class DATA {
7474

75+
private $metadata;
76+
7577
/**
7678
*
7779
*/
78-
public function Data() {
80+
public function __construct() {
7981

8082
// Defined in config.php.
8183
include_once METADATAPATH;
84+
$this->metadata = new Metadata();
8285

8386
}
8487

@@ -103,14 +106,14 @@ public function set_section() {
103106
* $key is the element of metadata you want to retrieve.
104107
*/
105108
public function page_metadata($page, $key) {
106-
return $this->_get_metadata(["page" => $page, "key" => $key], "page");
109+
return $this->metadata->get_metadata(["page" => $page, "key" => $key], "page");
107110
}
108111

109112
/**
110113
*
111114
*/
112115
public function section_metadata($section, $key) {
113-
return $this->_get_metadata(["section" => $section, "key" => $key], "section");
116+
return $this->metadata->get_metadata(["section" => $section, "key" => $key], "section");
114117
}
115118

116119
// Setting page and section.
@@ -119,14 +122,14 @@ public function section_metadata($section, $key) {
119122
* $page/$section, $key and $value should make sense...
120123
*/
121124
public function set_page_metadata($page, $key, $value) {
122-
$this->_set_metadata(["page" => $page, "key" => $key, "value" => $value]);
125+
$this->metadata->set_metadata(["page" => $page, "key" => $key, "value" => $value]);
123126
}
124127

125128
/**
126129
*
127130
*/
128131
public function set_section_metadata($section, $key, $value) {
129-
$this->_set_metadata(["section" => $section, "key" => $key, "value" => $value]);
132+
$this->metadata->set_metadata(["section" => $section, "key" => $key, "value" => $value]);
130133
}
131134

132135
// DEPRECATED.
@@ -135,97 +138,9 @@ public function set_section_metadata($section, $key, $value) {
135138
* Directly access an item.
136139
*/
137140
public function metadata($type, $item, $key) {
138-
if ($this->test_for_metadata($type, $item, $key)) {
139-
return $this->$type[$item][$key];
140-
}
141-
else {
142-
return "INVALID METADATA: $type[$item][$key]";
143-
}
144-
}
145-
146-
// Test for the presence of something.
147-
148-
/**
149-
* Eg $exists = $DATA->test_for_metadata("page", "about", "title")
150-
*/
151-
public function test_for_metadata($type, $item, $key) {
152-
$dataarray =& $this->$type;
153-
154-
if (isset($dataarray[$item][$key])) {
155-
return TRUE;
156-
}
157-
else {
158-
return FALSE;
159-
}
141+
return "ACCESS DEBIED FOR type[$item][$key] USE THE PUBLIC METHODS";
160142
}
161143

162-
//
163-
// PRIVATE METADATA ACCESS FUNCTIONS //
164-
// .
165-
166-
/**
167-
* Only accessed through page_metadata() or section_metadata()
168-
*/
169-
public function _get_metadata($args = "", $type) {
170-
// $type is either 'page' or 'section'
171-
global $this_page, $this_section;
172-
173-
if (is_array($args)) {
174-
$item = $args[$type];
175-
$key = $args['key'];
176-
}
177-
else {
178-
$var = "this_" . $type;
179-
// $this_page or $this_section.
180-
$item = $$var;
181-
$key = $args;
182-
}
183-
184-
twfy_debug("DATA", "$type: $item, $key");
185-
$dataarray =& $this->$type;
186-
187-
if ($this->test_for_metadata($type, $item, $key)) {
188-
$return = $dataarray[$item][$key];
189-
$debugtext = "Key: " . $type . "[" . $item . "][" . $key . "]";
190-
191-
}
192-
elseif ($this->test_for_metadata($type, "default", $key)) {
193-
$return = $dataarray["default"][$key];
194-
$debugtext = "Key: " . $type . "['default'][" . $key . "]";
195-
196-
}
197-
else {
198-
$return = FALSE;
199-
$debugtext = "No metadata found for key '$key'";
200-
}
201-
202-
twfy_debug("DATA", "$debugtext, returning '" . print_r($return, TRUE) . "'.");
203-
204-
return $return;
205-
}
206-
207-
/**
208-
*
209-
*/
210-
public function _set_metadata($args) {
211-
212-
if (isset($args["section"])) {
213-
$type = "section";
214-
$item = $args["section"];
215-
}
216-
else {
217-
$type = "page";
218-
$item = $args["page"];
219-
}
220-
221-
$key = $args["key"];
222-
$value = $args["value"];
223-
224-
twfy_debug("DATA", "Setting: " . $type . "[" . $item . "][" . $key . "] = '" . print_r($value, TRUE) . "'");
225-
226-
$dataarray =& $this->$type;
227-
$dataarray[$item][$key] = $value;
228-
}
229144

230145
}
231146

www/includes/easyparliament/commentlist.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535
class COMMENTLIST
3636
{
3737

38-
/**
39-
*
40-
*/
41-
public function COMMENTLIST()
42-
{
43-
global $this_page;
38+
private $db = null;
39+
40+
/**
41+
*
42+
*/
43+
public function __construct() {
44+
global $this_page;
4445

4546
$this->db = new ParlDB();
4647

www/includes/easyparliament/hansardlist.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
class HANSARDLIST
5050
{
5151

52+
private $db;
53+
5254
// We add 'wrans' or 'debate' onto the end of this in the appropriate classes'
5355
// constructors.
5456
// If you change this, change it in COMMENTSLIST->_fix_gid() too!
@@ -116,7 +118,7 @@ class HANSARDLIST
116118
/**
117119
*
118120
*/
119-
public function HANSARDLIST()
121+
public function __construct()
120122
{
121123
$this->db = new ParlDB();
122124
}

0 commit comments

Comments
 (0)