[MediaWiki-commits] [Gerrit] Enforce coding style - change (labs...guc)

2014-11-20 Thread Krinkle (Code Review)
Krinkle has submitted this change and it was merged.

Change subject: Enforce coding style
..


Enforce coding style

* Trim trailing whitespace.
* Convert Windows (CR) to Git native new lines (LF).
* Set up composer-test and enforce phpcs rules (added a few
  exceptions to keep clean up minimal).

Change-Id: I4c61ce67c60569b47462ac4525d6ffcbeb55e3e3
---
A .gitignore
M app.php
A composer.json
M index.php
M lb/exception.php
M lb/guc.php
M lb/wikicontribs.php
A phpcs.xml
M settings.php
9 files changed, 565 insertions(+), 476 deletions(-)

Approvals:
  Krinkle: Verified; Looks good to me, approved



diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..7579f74
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+vendor
+composer.lock
diff --git a/app.php b/app.php
index 5687de6..3ccbdab 100644
--- a/app.php
+++ b/app.php
@@ -1,46 +1,48 @@
 http://www.gnu.org/licenses/>.
- * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
  */
 
-class lb_app {
+class lb_app
+{
 private $times = array();
 private $clusters = array();
+
 /**
- * Öffnet eine Verbindung zur Datenbank
- * @param type $database
- * @return PDO Verbindung
+ * Open a connection to the database.
+ *
+ * @param string $database
+ * @param int|string $cluster
+ * @return PDO
  */
-private function openDB($database = 'wikidatawiki',$cluster = null) {
+private function openDB($database = 'wikidatawiki', $cluster = null) {
 $this->aTP('Open new Connection to '.$cluster);
-if(is_string($database)) {
+if (is_string($database)) {
 $host = $database.'.labsdb';
 $dbname = $database.'_p';
 }
-if(is_int($cluster)) {
+if (is_int($cluster)) {
 $host = 's'.$cluster.'.labsdb';
-$dbname = (is_string($database)) ? $database.'_p': 
'information_schema'; 
+$dbname = (is_string($database)) ? $database.'_p': 
'information_schema';
 }
-
-if(is_string($cluster)) {
+
+if (is_string($cluster)) {
 $host = $cluster;
-$dbname = (is_string($database)) ? $database.'_p': 
'information_schema'; 
+$dbname = (is_string($database)) ? $database.'_p': 
'information_schema';
 }
-
+
 //Verbindung aufbauen
 try {
 $pdo = new PDO('mysql:host='.$host.';dbname='.$dbname.';', 
settings::getSetting('user'), settings::getSetting('password'));
@@ -49,96 +51,98 @@
 }
 return $pdo;
 }
-
+
 /**
  * Gibt die Verbindung zu einem Wiki zurück (cache)
- * @staticvar array $cluster
+ *
  * @param string $database
- * @return PDO Verbindung
+ * @param $clusterNr
+ * @return PDO
  */
-public function getDB($database = 'meta',$clusterNr = 's1.labsdb') {
+public function getDB($database = 'meta', $clusterNr = 's1.labsdb') {
 $con = null;
-  
-if(!$clusterNr) {
+
+if (!$clusterNr) {
 throw new lb_Exception("try to open DB without cluster 
specification");
-}
-//bereits vorhanden?
-if(key_exists($clusterNr, $this->clusters)) {
+}
+// Bereits vorhanden?
+if (key_exists($clusterNr, $this->clusters)) {
 $con = $this->clusters[$clusterNr];
 } else {
-//Datenbankverbindung öffnen
+// Datenbankverbindung öffnen
 $con = $this->openDB($database, $clusterNr);
 }
-//Datenbank auswählen
+// Datenbank auswählen
 $m = $con->prepare('USE `'.$database.'_p`;');
 $m->execute();
 unset($m);
-
-//Verbindung ablegen
+
+// Verbindung ablegen
 $this->clusters[$clusterNr] = $con;
-
+
 return $con;
 }
-
+
 public function aTP($text) {
 $this->times[] = array(microtime(true), $text);
 }
-
+
 public function printTimes() {
 $this->aTP("Finish");
 $timebefore = null;
 $first = null;
-foreach($this->times as $nr => $data) {
-
+foreach ($this->times as $nr => $data) {
+
 $diff = ($timebefore === null) ? 0.0 : $data[0] - $timebefore;
-if($timebefore === null) $first = $data[0

[MediaWiki-commits] [Gerrit] Enforce coding style - change (labs...guc)

2014-11-20 Thread Krinkle (Code Review)
Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/174894

Change subject: Enforce coding style
..

Enforce coding style

* Trim trailing whitespace.
* Convert Windows (CR) to Git native new lines (LF).
* Set up composer-test and enforce phpcs rules (added a few
  exceptions to keep clean up minimal).

Change-Id: I4c61ce67c60569b47462ac4525d6ffcbeb55e3e3
---
A .gitignore
M app.php
A composer.json
M index.php
M lb/exception.php
M lb/guc.php
M lb/wikicontribs.php
A phpcs.xml
M settings.php
9 files changed, 565 insertions(+), 476 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/labs/tools/guc 
refs/changes/94/174894/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..7579f74
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+vendor
+composer.lock
diff --git a/app.php b/app.php
index 5687de6..3ccbdab 100644
--- a/app.php
+++ b/app.php
@@ -1,46 +1,48 @@
 http://www.gnu.org/licenses/>.
- * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
  */
 
-class lb_app {
+class lb_app
+{
 private $times = array();
 private $clusters = array();
+
 /**
- * Öffnet eine Verbindung zur Datenbank
- * @param type $database
- * @return PDO Verbindung
+ * Open a connection to the database.
+ *
+ * @param string $database
+ * @param int|string $cluster
+ * @return PDO
  */
-private function openDB($database = 'wikidatawiki',$cluster = null) {
+private function openDB($database = 'wikidatawiki', $cluster = null) {
 $this->aTP('Open new Connection to '.$cluster);
-if(is_string($database)) {
+if (is_string($database)) {
 $host = $database.'.labsdb';
 $dbname = $database.'_p';
 }
-if(is_int($cluster)) {
+if (is_int($cluster)) {
 $host = 's'.$cluster.'.labsdb';
-$dbname = (is_string($database)) ? $database.'_p': 
'information_schema'; 
+$dbname = (is_string($database)) ? $database.'_p': 
'information_schema';
 }
-
-if(is_string($cluster)) {
+
+if (is_string($cluster)) {
 $host = $cluster;
-$dbname = (is_string($database)) ? $database.'_p': 
'information_schema'; 
+$dbname = (is_string($database)) ? $database.'_p': 
'information_schema';
 }
-
+
 //Verbindung aufbauen
 try {
 $pdo = new PDO('mysql:host='.$host.';dbname='.$dbname.';', 
settings::getSetting('user'), settings::getSetting('password'));
@@ -49,96 +51,98 @@
 }
 return $pdo;
 }
-
+
 /**
  * Gibt die Verbindung zu einem Wiki zurück (cache)
- * @staticvar array $cluster
+ *
  * @param string $database
- * @return PDO Verbindung
+ * @param $clusterNr
+ * @return PDO
  */
-public function getDB($database = 'meta',$clusterNr = 's1.labsdb') {
+public function getDB($database = 'meta', $clusterNr = 's1.labsdb') {
 $con = null;
-  
-if(!$clusterNr) {
+
+if (!$clusterNr) {
 throw new lb_Exception("try to open DB without cluster 
specification");
-}
-//bereits vorhanden?
-if(key_exists($clusterNr, $this->clusters)) {
+}
+// Bereits vorhanden?
+if (key_exists($clusterNr, $this->clusters)) {
 $con = $this->clusters[$clusterNr];
 } else {
-//Datenbankverbindung öffnen
+// Datenbankverbindung öffnen
 $con = $this->openDB($database, $clusterNr);
 }
-//Datenbank auswählen
+// Datenbank auswählen
 $m = $con->prepare('USE `'.$database.'_p`;');
 $m->execute();
 unset($m);
-
-//Verbindung ablegen
+
+// Verbindung ablegen
 $this->clusters[$clusterNr] = $con;
-
+
 return $con;
 }
-
+
 public function aTP($text) {
 $this->times[] = array(microtime(true), $text);
 }
-
+
 public function printTimes() {
 $this->aTP("Finish");
 $timebefore = null;
 $first = null;
-foreach($this->times as $nr => $data) {
-
+foreach ($this->times as $nr => $data) {
+
 $diff = ($timebefore === null) ? 0.0 : $data[0] - $timebefo