Skip to content

Commit

Permalink
More CS fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebin committed Aug 20, 2020
1 parent 3eef968 commit 009d4c4
Show file tree
Hide file tree
Showing 32 changed files with 265 additions and 304 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ubuntu-16.04
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4']
php: ['7.0', '7.1', '7.2', '7.3', '7.4']
name: PHP ${{ matrix.php }} tests
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .idea/mc-google-visualization.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 28 additions & 6 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
<?php

$finder = PhpCsFixer\Finder::create()
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->name('.php_cs')
->exclude('vendor')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
return Config::create()
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'php_unit_test_class_requires_covers' => false,
'@DoctrineAnnotation' => true,
'@PHP70Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'backtick_to_shell_exec' => true,
'blank_line_before_statement' => [
'statements' => ['declare', 'return', 'case'],
],
'comment_to_phpdoc' => false,
'declare_equal_normalize' => ['space' => 'single'],
'doctrine_annotation_array_assignment' => ['operator' => '='],
'doctrine_annotation_spaces' => [
'after_array_assignments_equals' => false,
'before_array_assignments_equals' => false
],
'final_static_access' => true,
'global_namespace_import' => true,
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'native_function_invocation' => false,
'no_unset_on_property' => false,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_to_comment' => false,
'self_static_accessor' => true,
])
->setFinder($finder)
;
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
"require": {
"php": "^7.0",
"ext-json": "*",
"ext-pdo": "*"
"ext-pdo": "*",
"symfony/polyfill-php74": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0|^7.0",
"phpstan/phpstan": "^0.9|^0.10|^0.11",
"phpstan/phpstan-phpunit": "^0.9|^0.10|^0.11"
"phpstan/phpstan-phpunit": "^0.9|^0.10|^0.11",
"phpstan/phpstan-strict-rules": "^0.9|^0.10|^0.11"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 6 additions & 3 deletions examples/callback_fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

/** @noinspection PhpUnhandledExceptionInspection */

declare(strict_types = 1);

use MC\Google\Visualization;

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

/**
* @param mixed $row
* @return string|null
*
* @return null|string
*/
function most_common($row)
{
Expand Down Expand Up @@ -60,13 +63,13 @@ function most_common($row)
<script type="text/javascript">
google.load('visualization', '1', {'packages': ['table']});
google.setOnLoadCallback(function() {
var query = new google.visualization.Query('callback_fields.php');
const query = new google.visualization.Query('callback_fields.php');
query.setQuery('select country, most_common from birth_control order by country label country "Country", most_common "Most Common Method"');
query.send(function(res) {
if(res.isError()) {
alert(res.getDetailedMessage());
} else {
var table = new google.visualization.Table(document.getElementById('table-div'));
const table = new google.visualization.Table(document.getElementById('table-div'));
table.draw(res.getDataTable());
}
});
Expand Down
10 changes: 6 additions & 4 deletions examples/complete.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/** @noinspection PhpUnhandledExceptionInspection */

declare(strict_types = 1);

use MC\Google\Visualization;

require_once __DIR__.'/../vendor/autoload.php';
Expand Down Expand Up @@ -45,13 +47,13 @@
motion_chart = null;

function loadChart() {
var metric1 = document.getElementById('metric-1').value;
var metric2 = document.getElementById('metric-2').value;
const metric1 = document.getElementById('metric-1').value;
const metric2 = document.getElementById('metric-2').value;
if (metric1 === metric2) return;

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"';
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"';

var query = new google.visualization.Query('complete.php');
const query = new google.visualization.Query('complete.php');
query.setQuery(str);
query.send(function(res) {
if (res.isError()) {
Expand Down
4 changes: 2 additions & 2 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ul id="example-list">
<?php
foreach (new DirectoryIterator(__DIR__) as $file) {
if ($file->isFile() && '.php' === substr($file->getFilename(), -4) && !in_array($file->getFilename(), ['index.php', 'init.php'], true)) {
echo '<li><a href="'.$file->getFilename().'">'.ucwords(str_replace('_', ' ', substr($file->getFilename(), 0, -4))).'</a></li>';
if ($file->isFile() && '.php' === mb_substr($file->getFilename(), -4) && !in_array($file->getFilename(), ['index.php', 'init.php'], true)) {
echo '<li><a href="'.$file->getFilename().'">'.ucwords(str_replace('_', ' ', mb_substr($file->getFilename(), 0, -4))).'</a></li>';
}
}
?>
Expand Down
10 changes: 6 additions & 4 deletions examples/joins.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/** @noinspection PhpUnhandledExceptionInspection */

declare(strict_types = 1);

use MC\Google\Visualization;

require_once __DIR__.'/../vendor/autoload.php';
Expand Down Expand Up @@ -39,23 +41,23 @@
<script type="text/javascript">
google.charts.load('current', {'packages': ['columnchart', 'linechart']});
window.addEventListener('DOMContentLoaded', function() { google.charts.setOnLoadCallback(function() {
var query = new google.visualization.Query('joins.php');
const query = new google.visualization.Query('joins.php');
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"');
query.send(function(res) {
if(res.isError()) {
alert(res.getDetailedMessage());
} else {
var table = new google.visualization.ColumnChart(document.getElementById('chart-div'));
const table = new google.visualization.ColumnChart(document.getElementById('chart-div'));
table.draw(res.getDataTable(), {'height': 500});
}

var query2 = new google.visualization.Query('joins.php');
const query2 = new google.visualization.Query('joins.php');
query2.setQuery('select gdp_year, sum(gdp_us) from countries group by gdp_year label gdp_us "Per-capita GDP (US Dollars)"');
query2.send(function(res) {
if(res.isError()) {
alert(res.getDetailedMessage());
} else {
var table = new google.visualization.LineChart(document.getElementById('chart2-div'));
const table = new google.visualization.LineChart(document.getElementById('chart2-div'));
table.draw(res.getDataTable(), {'height': 400});
}
});
Expand Down
6 changes: 4 additions & 2 deletions examples/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/** @noinspection PhpUnhandledExceptionInspection */

declare(strict_types = 1);

use MC\Google\Visualization;

require_once __DIR__.'/../vendor/autoload.php';
Expand Down Expand Up @@ -29,13 +31,13 @@
<script type="text/javascript">
google.charts.load('current', {'packages': ['table']});
window.addEventListener('DOMContentLoaded', function() { google.charts.setOnLoadCallback(function() {
var query = new google.visualization.Query('simple.php');
const query = new google.visualization.Query('simple.php');
query.setQuery('select id, name from countries order by name label id "ID", name "Name"');
query.send(function(res) {
if(res.isError()) {
alert(res.getDetailedMessage());
} else {
var table = new google.visualization.Table(document.getElementById('table-div'));
const table = new google.visualization.Table(document.getElementById('table-div'));
table.draw(res.getDataTable(), {'page': 'enable', 'pageSize': 20});
}
});
Expand Down
Loading

0 comments on commit 009d4c4

Please sign in to comment.