Skip to content

Commit 009d4c4

Browse files
committed
More CS fixes.
1 parent 3eef968 commit 009d4c4

32 files changed

+265
-304
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88

99
jobs:
1010
tests:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-16.04
1212
strategy:
1313
matrix:
14-
php: ['7.1', '7.2', '7.3', '7.4']
14+
php: ['7.0', '7.1', '7.2', '7.3', '7.4']
1515
name: PHP ${{ matrix.php }} tests
1616
steps:
1717
- uses: actions/checkout@v2

.idea/mc-google-visualization.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.php_cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
<?php
22

3-
$finder = PhpCsFixer\Finder::create()
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
$finder = Finder::create()
7+
->name('.php_cs')
48
->exclude('vendor')
59
->in(__DIR__)
610
;
711

8-
return PhpCsFixer\Config::create()
12+
return Config::create()
913
->setRules([
10-
'@PSR1' => true,
11-
'@PSR2' => true,
1214
'@PhpCsFixer' => true,
1315
'@PhpCsFixer:risky' => true,
14-
'array_syntax' => ['syntax' => 'short'],
15-
'php_unit_test_class_requires_covers' => false,
16+
'@DoctrineAnnotation' => true,
17+
'@PHP70Migration:risky' => true,
18+
'@PHPUnit75Migration:risky' => true,
19+
'backtick_to_shell_exec' => true,
20+
'blank_line_before_statement' => [
21+
'statements' => ['declare', 'return', 'case'],
22+
],
23+
'comment_to_phpdoc' => false,
24+
'declare_equal_normalize' => ['space' => 'single'],
25+
'doctrine_annotation_array_assignment' => ['operator' => '='],
26+
'doctrine_annotation_spaces' => [
27+
'after_array_assignments_equals' => false,
28+
'before_array_assignments_equals' => false
29+
],
30+
'final_static_access' => true,
31+
'global_namespace_import' => true,
32+
'linebreak_after_opening_tag' => true,
33+
'mb_str_functions' => true,
1634
'native_function_invocation' => false,
35+
'no_unset_on_property' => false,
36+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
37+
'phpdoc_to_comment' => false,
38+
'self_static_accessor' => true,
1739
])
1840
->setFinder($finder)
1941
;

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
"require": {
2525
"php": "^7.0",
2626
"ext-json": "*",
27-
"ext-pdo": "*"
27+
"ext-pdo": "*",
28+
"symfony/polyfill-php74": "^1.0"
2829
},
2930
"require-dev": {
3031
"phpunit/phpunit": "^6.0|^7.0",
3132
"phpstan/phpstan": "^0.9|^0.10|^0.11",
32-
"phpstan/phpstan-phpunit": "^0.9|^0.10|^0.11"
33+
"phpstan/phpstan-phpunit": "^0.9|^0.10|^0.11",
34+
"phpstan/phpstan-strict-rules": "^0.9|^0.10|^0.11"
3335
},
3436
"autoload": {
3537
"psr-4": {

examples/callback_fields.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
/** @noinspection PhpUnhandledExceptionInspection */
44

5+
declare(strict_types = 1);
6+
57
use MC\Google\Visualization;
68

79
require_once __DIR__.'/../vendor/autoload.php';
810

911
/**
1012
* @param mixed $row
11-
* @return string|null
13+
*
14+
* @return null|string
1215
*/
1316
function most_common($row)
1417
{
@@ -60,13 +63,13 @@ function most_common($row)
6063
<script type="text/javascript">
6164
google.load('visualization', '1', {'packages': ['table']});
6265
google.setOnLoadCallback(function() {
63-
var query = new google.visualization.Query('callback_fields.php');
66+
const query = new google.visualization.Query('callback_fields.php');
6467
query.setQuery('select country, most_common from birth_control order by country label country "Country", most_common "Most Common Method"');
6568
query.send(function(res) {
6669
if(res.isError()) {
6770
alert(res.getDetailedMessage());
6871
} else {
69-
var table = new google.visualization.Table(document.getElementById('table-div'));
72+
const table = new google.visualization.Table(document.getElementById('table-div'));
7073
table.draw(res.getDataTable());
7174
}
7275
});

examples/complete.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/** @noinspection PhpUnhandledExceptionInspection */
44

5+
declare(strict_types = 1);
6+
57
use MC\Google\Visualization;
68

79
require_once __DIR__.'/../vendor/autoload.php';
@@ -45,13 +47,13 @@
4547
motion_chart = null;
4648

4749
function loadChart() {
48-
var metric1 = document.getElementById('metric-1').value;
49-
var metric2 = document.getElementById('metric-2').value;
50+
const metric1 = document.getElementById('metric-1').value;
51+
const metric2 = document.getElementById('metric-2').value;
5052
if (metric1 === metric2) return;
5153

52-
var str = 'select country, year, ' + metric1 + ', ' + metric2 + ' where ' + metric1 + '!=0 AND ' + metric2 + '!=0 group by country, year label country "Country", year "Year", birth_control "Birth Control Penetration", gdp_us "Per-capita GDP (US Dollars)", savings_rate "Savings Rate", investment_rate "Investment Rate", infant_mort "Infant Mortality", life_expect "Life Expectancy" format year "%d"';
54+
const str = 'select country, year, ' + metric1 + ', ' + metric2 + ' where ' + metric1 + '!=0 AND ' + metric2 + '!=0 group by country, year label country "Country", year "Year", birth_control "Birth Control Penetration", gdp_us "Per-capita GDP (US Dollars)", savings_rate "Savings Rate", investment_rate "Investment Rate", infant_mort "Infant Mortality", life_expect "Life Expectancy" format year "%d"';
5355

54-
var query = new google.visualization.Query('complete.php');
56+
const query = new google.visualization.Query('complete.php');
5557
query.setQuery(str);
5658
query.send(function(res) {
5759
if (res.isError()) {

examples/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ul id="example-list">
88
<?php
99
foreach (new DirectoryIterator(__DIR__) as $file) {
10-
if ($file->isFile() && '.php' === substr($file->getFilename(), -4) && !in_array($file->getFilename(), ['index.php', 'init.php'], true)) {
11-
echo '<li><a href="'.$file->getFilename().'">'.ucwords(str_replace('_', ' ', substr($file->getFilename(), 0, -4))).'</a></li>';
10+
if ($file->isFile() && '.php' === mb_substr($file->getFilename(), -4) && !in_array($file->getFilename(), ['index.php', 'init.php'], true)) {
11+
echo '<li><a href="'.$file->getFilename().'">'.ucwords(str_replace('_', ' ', mb_substr($file->getFilename(), 0, -4))).'</a></li>';
1212
}
1313
}
1414
?>

examples/joins.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/** @noinspection PhpUnhandledExceptionInspection */
44

5+
declare(strict_types = 1);
6+
57
use MC\Google\Visualization;
68

79
require_once __DIR__.'/../vendor/autoload.php';
@@ -39,23 +41,23 @@
3941
<script type="text/javascript">
4042
google.charts.load('current', {'packages': ['columnchart', 'linechart']});
4143
window.addEventListener('DOMContentLoaded', function() { google.charts.setOnLoadCallback(function() {
42-
var query = new google.visualization.Query('joins.php');
44+
const query = new google.visualization.Query('joins.php');
4345
query.setQuery('select avg(life_male), avg(life_female), avg(life_both) from countries label life_male "Life Expectancy (Male)", life_female "Life Expectancy (Female)", life_both "Life Expectancy (Combined)" format life_male "%.2f years", life_female "%.2f years", life_both "%.2f years"');
4446
query.send(function(res) {
4547
if(res.isError()) {
4648
alert(res.getDetailedMessage());
4749
} else {
48-
var table = new google.visualization.ColumnChart(document.getElementById('chart-div'));
50+
const table = new google.visualization.ColumnChart(document.getElementById('chart-div'));
4951
table.draw(res.getDataTable(), {'height': 500});
5052
}
5153

52-
var query2 = new google.visualization.Query('joins.php');
54+
const query2 = new google.visualization.Query('joins.php');
5355
query2.setQuery('select gdp_year, sum(gdp_us) from countries group by gdp_year label gdp_us "Per-capita GDP (US Dollars)"');
5456
query2.send(function(res) {
5557
if(res.isError()) {
5658
alert(res.getDetailedMessage());
5759
} else {
58-
var table = new google.visualization.LineChart(document.getElementById('chart2-div'));
60+
const table = new google.visualization.LineChart(document.getElementById('chart2-div'));
5961
table.draw(res.getDataTable(), {'height': 400});
6062
}
6163
});

examples/simple.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/** @noinspection PhpUnhandledExceptionInspection */
44

5+
declare(strict_types = 1);
6+
57
use MC\Google\Visualization;
68

79
require_once __DIR__.'/../vendor/autoload.php';
@@ -29,13 +31,13 @@
2931
<script type="text/javascript">
3032
google.charts.load('current', {'packages': ['table']});
3133
window.addEventListener('DOMContentLoaded', function() { google.charts.setOnLoadCallback(function() {
32-
var query = new google.visualization.Query('simple.php');
34+
const query = new google.visualization.Query('simple.php');
3335
query.setQuery('select id, name from countries order by name label id "ID", name "Name"');
3436
query.send(function(res) {
3537
if(res.isError()) {
3638
alert(res.getDetailedMessage());
3739
} else {
38-
var table = new google.visualization.Table(document.getElementById('table-div'));
40+
const table = new google.visualization.Table(document.getElementById('table-div'));
3941
table.draw(res.getDataTable(), {'page': 'enable', 'pageSize': 20});
4042
}
4143
});

0 commit comments

Comments
 (0)