Skip to content

Commit 987be15

Browse files
committed
(chore): perform lint of entire codebase
1 parent 26c983c commit 987be15

File tree

1,103 files changed

+5032
-6149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,103 files changed

+5032
-6149
lines changed

.gitlab-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ test:
3535
script:
3636
- bin/phpspec run
3737

38+
lint:
39+
stage: test
40+
image: minds/php-tests:latest
41+
script:
42+
- bin/php-cs-fixer fix --allow-risky=yes --verbose --dry-run
43+
3844
prepare:fpm:
3945
stage: prepare
4046
image: minds/ci:latest

.php_cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@ $finder = PhpCsFixer\Finder::create()
55
->in(__DIR__);
66

77
return PhpCsFixer\Config::create()
8-
->fixers(['psr2', 'strict_param', 'short_array_syntax', 'no_blank_lines_after_class_opening'])
9-
->finder($finder);
8+
->setRules([
9+
'@PSR2' => true,
10+
'strict_param' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'no_blank_lines_after_class_opening' => true,
13+
])
14+
->setFinder($finder);

Api/Factory.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function build($segments, $request, $response)
5050
if (!$handler instanceof Interfaces\ApiIgnorePam) {
5151
self::pamCheck($request, $response);
5252
}
53-
$pages = array_splice($segments, $loop) ?: array();
53+
$pages = array_splice($segments, $loop) ?: [];
5454
return $handler->$method($pages);
5555
}
5656
}
@@ -65,7 +65,7 @@ public static function build($segments, $request, $response)
6565
if (!$handler instanceof Interfaces\ApiIgnorePam) {
6666
self::pamCheck($request, $response);
6767
}
68-
$pages = array_splice($segments, $loop) ?: array();
68+
$pages = array_splice($segments, $loop) ?: [];
6969
return $handler->$method($pages);
7070
}
7171
--$loop;
@@ -78,7 +78,7 @@ public static function build($segments, $request, $response)
7878
*/
7979
public static function pamCheck($request, $response)
8080
{
81-
if ( $request->getAttribute('oauth_user_id')
81+
if ($request->getAttribute('oauth_user_id')
8282
|| Security\XSRF::validateRequest()
8383
) {
8484
return true;
@@ -89,7 +89,7 @@ public static function pamCheck($request, $response)
8989
header("Access-Control-Allow-Origin: *");
9090
header('HTTP/1.1 401 Unauthorized', true, 401);
9191
echo json_encode([
92-
'error' => 'Sorry, you are not authenticated',
92+
'error' => 'Sorry, you are not authenticated',
9393
'code' => 401,
9494
'loggedin' => false
9595
]);
@@ -111,7 +111,7 @@ private static function adminCheck()
111111
header('Content-type: application/json');
112112
header("Access-Control-Allow-Origin: *");
113113
header('HTTP/1.1 401 Unauthorized', true, 401);
114-
echo json_encode(array('error'=>'You are not an admin', 'code'=>401));
114+
echo json_encode(['error'=>'You are not an admin', 'code'=>401]);
115115
exit;
116116
}
117117
}
@@ -122,7 +122,7 @@ private static function adminCheck()
122122
*/
123123
public static function isLoggedIn()
124124
{
125-
if(Session::isLoggedIn()){
125+
if (Session::isLoggedIn()) {
126126
return true;
127127
} else {
128128
ob_end_clean();
@@ -143,11 +143,11 @@ public static function isLoggedIn()
143143
* Builds an API response
144144
* @param array $data
145145
*/
146-
public static function response($data = array())
146+
public static function response($data = [])
147147
{
148-
$data = array_merge(array(
148+
$data = array_merge([
149149
'status' => 'success', //should success be assumed?
150-
), $data);
150+
], $data);
151151

152152
ob_end_clean();
153153

@@ -162,9 +162,9 @@ public static function response($data = array())
162162
* @return array - an array of the entities
163163
* @deprecated
164164
*/
165-
public static function exportable($entities, $exceptions = array(), $exportContext = false)
165+
public static function exportable($entities, $exceptions = [], $exportContext = false)
166166
{
167-
if(!$entities){
167+
if (!$entities) {
168168
return [];
169169
}
170170
foreach ($entities as $k => $entity) {

Api/Routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
class Routes
88
{
9-
public static $routes = array();
9+
public static $routes = [];
1010

1111
/**
1212
* Adds a custom API route resolution

Cli/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public static function build($segments)
6161
public static function toCamelNsp($namespace)
6262
{
6363
$namespace = explode('\\', $namespace);
64-
$replacer = function($matches) {
64+
$replacer = function ($matches) {
6565
return strtoupper($matches[1]);
6666
};
6767

68-
array_walk($namespace, function(&$segment) use ($replacer) {
68+
array_walk($namespace, function (&$segment) use ($replacer) {
6969
$segment = ucfirst(preg_replace_callback('/_([a-z])/', $replacer, $segment));
7070
});
7171

Cli/Routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
class Routes
88
{
9-
public static $routes = array();
9+
public static $routes = [];
1010

1111
/**
1212
* Adds a custom CLI route resolution

Common/Cookie.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
/**
99
* Class Cookie
1010
* @method Cookie setName(string $name)
11-
* @method Cookie setValue(string $value)
11+
* @method Cookie setValue(string $value)
1212
* @method Cookie setExpire(int $value)
1313
* @method Cookie setPath(string $path)
14-
* @method Cookie setDomain(string $domain)
14+
* @method Cookie setDomain(string $domain)
1515
* @method Cookie setSecure(bool $secure)
1616
* @method Cookie setHttpOnly(bool $httpOnly)
1717
*/
1818
class Cookie
1919
{
20-
2120
use MagicAttributes;
2221

2322
/** @var CONFIG $config */
@@ -71,5 +70,4 @@ public function create()
7170
setcookie($this->name, $this->value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly);
7271
$_COOKIE[$this->name] = $this->value; //set the global cookie
7372
}
74-
7573
}

Components/Controller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
* @todo Create a BaseController class (to be used on Api, Cli, etc) with core DI operations.
1010
* @todo Ensure this class is used EVERYWHERE on Minds\Controllers\api
1111
*/
12-
class Controller {
12+
class Controller
13+
{
1314
protected $di;
1415
protected $config;
1516

Controllers/Cli/AbuseGuard.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function run()
3434
$interval = $this->getOpt('interval') ?: 5;
3535

3636
while (true) {
37-
3837
$guard->setPeriod(
3938
time() - (60 * 60 * 10),
4039
time()
@@ -50,7 +49,6 @@ public function run()
5049

5150
sleep($interval);
5251
}
53-
5452
}
5553

5654
public function sync_single()

Controllers/Cli/Analytics.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function sync_graphs()
122122
foreach ($aggregates as $aggregate) {
123123
$this->out("Syncing {$aggregate}");
124124

125-
try {
125+
try {
126126
$manager->sync([
127127
'aggregate' => $aggregate,
128128
'all' => true,
@@ -132,7 +132,7 @@ public function sync_graphs()
132132
}
133133

134134
$this->out('Completed caching site metrics');
135-
}
135+
}
136136

137137
public function syncViews()
138138
{
@@ -158,5 +158,4 @@ public function syncViews()
158158
}
159159
$this->out('Done');
160160
}
161-
162161
}

Controllers/Cli/Blockchain.php

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function listen()
4646
if (function_exists('pcntl_signal')) {
4747
// Intercept Ctrl+C
4848

49-
pcntl_signal(SIGINT, function() {
49+
pcntl_signal(SIGINT, function () {
5050
$this->filterCleanup();
5151
exit;
5252
});
@@ -106,7 +106,6 @@ public function listen()
106106
}
107107
}
108108
}
109-
110109
}
111110

112111
usleep(500 * 1000); // 500ms
@@ -143,24 +142,24 @@ public function setRate()
143142
{
144143
error_reporting(E_ALL);
145144
ini_set('display_errors', 1);
146-
while (true) {
147-
$ethereum = Di::_()->get('Blockchain\Services\Ethereum');
148-
$config = Di::_()->get('Config');
149-
$ethRate = new EthRate;
150-
$ethPrice = new EthPrice;
151-
$ethPrice->setFrom(strtotime('24 hours ago'))
145+
while (true) {
146+
$ethereum = Di::_()->get('Blockchain\Services\Ethereum');
147+
$config = Di::_()->get('Config');
148+
$ethRate = new EthRate;
149+
$ethPrice = new EthPrice;
150+
$ethPrice->setFrom(strtotime('24 hours ago'))
152151
->setTo(time())
153152
->get();
154153

155-
$eth = round($ethPrice->getNearestPrice(strtotime('1 minute ago')));
156-
$usd = 1.25;
154+
$eth = round($ethPrice->getNearestPrice(strtotime('1 minute ago')));
155+
$usd = 1.25;
157156

158-
$rate = round($eth/$usd);
159-
if ($rate % 2 !== 0) {
160-
$rate++;
161-
}
157+
$rate = round($eth/$usd);
158+
if ($rate % 2 !== 0) {
159+
$rate++;
160+
}
162161

163-
$txHash = $ethereum->sendRawTransaction($config->blockchain['contracts']['token_sale_event']['rate_pkey'], [
162+
$txHash = $ethereum->sendRawTransaction($config->blockchain['contracts']['token_sale_event']['rate_pkey'], [
164163
'from' => $config->blockchain['contracts']['token_sale_event']['rate_address'],
165164
'to' => $config->blockchain['contracts']['token_sale_event']['contract_address'],
166165
'gasLimit' => BigNumber::_(200000)->toHex(true),
@@ -170,31 +169,31 @@ public function setRate()
170169
])
171170
]);
172171

173-
// Wait until mined before updating our backend
172+
// Wait until mined before updating our backend
174173

175-
while (true) {
176-
sleep(1);
177-
$receipt = $ethereum->request('eth_getTransactionReceipt', [ $txHash ]);
178-
echo "\n Waiting for $txHash";
179-
if ($receipt && $receipt['status']) {
180-
if ($receipt['status'] !== '0x1') {
181-
echo "\n$txHash failed";
174+
while (true) {
175+
sleep(1);
176+
$receipt = $ethereum->request('eth_getTransactionReceipt', [ $txHash ]);
177+
echo "\n Waiting for $txHash";
178+
if ($receipt && $receipt['status']) {
179+
if ($receipt['status'] !== '0x1') {
180+
echo "\n$txHash failed";
181+
}
182+
break;
182183
}
183-
break;
184184
}
185-
}
186185

187-
$ethRate->set($rate);
188-
echo "\n Completed: new rate is $rate: $txHash";
189-
echo "\n Now sleeping for one hour";
190-
sleep(3600);
191-
}
186+
$ethRate->set($rate);
187+
echo "\n Completed: new rate is $rate: $txHash";
188+
echo "\n Now sleeping for one hour";
189+
sleep(3600);
190+
}
192191
}
193192

194193
public function balance()
195194
{
196195
error_reporting(E_ALL);
197-
ini_set('display_errors', 1);
196+
ini_set('display_errors', 1);
198197

199198
$username = $this->getOpt('username');
200199
$user = new \Minds\Entities\User($username);

Controllers/Cli/Contributions.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
class Contributions extends Cli\Controller implements Interfaces\CliControllerInterface
1616
{
17-
1817
private $start;
1918
private $elasticsearch;
2019

@@ -49,7 +48,7 @@ public function sync()
4948

5049
$this->out("Getting rewards for all users");
5150

52-
$total = 0;
51+
$total = 0;
5352
$i = 0;
5453
foreach ($users as $guid) {
5554
$i++;
@@ -120,7 +119,7 @@ public function syncCheckins()
120119
$hash = $user->getPhoneNumberHash();
121120

122121
if (isset($hashes[$hash])) { //don't allow multiple phones to claim checkin
123-
$duplicates++;
122+
$duplicates++;
124123
continue;
125124
}
126125
$hashes[$hash] = true;
@@ -143,7 +142,7 @@ public function syncCheckins()
143142
->setUser($checkin['user'])
144143
->issueCheckins($checkin['amount']);
145144
}
146-
}
145+
}
147146

148147
public function test()
149148
{
@@ -162,7 +161,7 @@ public function test()
162161
->setDryRun(true);
163162

164163
if ($user->guid) {
165-
$manager->setUser($user);
164+
$manager->setUser($user);
166165
}
167166
$results = $manager->sync();
168167

@@ -171,9 +170,8 @@ public function test()
171170
foreach ($results as $result) {
172171
$totals += $result->getAmount();
173172
$totals_by_type[$result->getMetric()] += $result->getAmount();
174-
}
173+
}
175174
var_dump($totals);
176175
var_dump($totals_by_type);
177176
}
178-
179177
}

Controllers/Cli/CreateFoundersIndex.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
class CreateFoundersIndex extends Cli\Controller implements Interfaces\CliControllerInterface
1414
{
15-
1615
public function help($command = null)
1716
{
1817
$this->out('TBD');
@@ -21,7 +20,7 @@ public function help($command = null)
2120
public function exec()
2221
{
2322
error_reporting(E_ALL);
24-
ini_set('display_errors', 1);
23+
ini_set('display_errors', 1);
2524
$db = Di::_()->get('Database\Cassandra\Cql');
2625
$entities_by_time = new Core\Data\Call('entities_by_time');
2726

@@ -34,9 +33,8 @@ public function exec()
3433
echo "\n[$i]:$user->guid";
3534
if ($user->founder) {
3635
echo "\n[$i]:$user->guid indexed";
37-
$entities_by_time->insert('user:founders', [ (string) $user->guid => (string) $user->guid ]);
36+
$entities_by_time->insert('user:founders', [ (string) $user->guid => (string) $user->guid ]);
3837
}
3938
}
40-
4139
}
4240
}

0 commit comments

Comments
 (0)