Skip to content

Commit

Permalink
phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
noximo committed Aug 20, 2019
1 parent 0e2d4d4 commit e80aed9
Show file tree
Hide file tree
Showing 22 changed files with 603 additions and 288 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"symplify/easy-coding-standard": "^6.0"
},
"scripts": {
"check-cs": "ecs check src",
"fix-cs": "ecs check src --fix",
"check-cs": "ecs check src examples",
"fix-cs": "ecs check src examples --fix",
"lint": "parallel-lint --colors --exclude vendor .",
"phpstan": "phpstan analyze src --level max -c phpstan.neon --error-format=fileoutput",
"phpstan": "phpstan analyze src examples --level max -c phpstan.neon --error-format=fileoutput",
"test": [
"@lint",
"@check-cs",
Expand Down
4 changes: 3 additions & 1 deletion ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ parameters:
SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff: ~
Symplify\CodingStandard\Sniffs\DependencyInjection\NoClassInstantiationSniff: ~
Symplify\CodingStandard\Sniffs\CleanCode\ForbiddenStaticFunctionSniff: ~
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff.MissingTraversableReturnTypeHintSpecification: ~ #DELETE
PhpCsFixer\Fixer\Import\OrderedImportsFixer: ~
Symplify\CodingStandard\Fixer\Commenting\BlockPropertyCommentFixer: ~
Symplify\CodingStandard\Sniffs\ControlStructure\SprintfOverContactSniff: ~
9 changes: 5 additions & 4 deletions examples/badInput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$lineGraph = new Linechart();
Expand All @@ -16,8 +17,8 @@
14 => 8,
8 => 2,
3 => 2,
4 => 2
4 => 2,
];
$lineGraph->addMarkers($lineA, [AsciiColorizer::GREEN, AsciiColorizer::BOLD], [AsciiColorizer::RED]);

echo $lineGraph->chart();
$lineGraph->chart()->print();
10 changes: 5 additions & 5 deletions examples/example.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

Expand All @@ -18,7 +19,7 @@
->setFormat( //control how y axis labels will be printed out
function ($x, Settings $settings) {
$padding = $settings->getPadding();
$paddingLength = \strlen($padding);
$paddingLength = strlen($padding);

return substr($padding . round($x, 2), -$paddingLength);
}
Expand Down Expand Up @@ -57,7 +58,6 @@ function ($x, Settings $settings) {
Linechart::CROSS //Point can be made more visible with crosslines. Default is Linegraph::POINT
);


$graph = $lineGraph->chart(); //Graph is an object with all data drawn. It can be simply echoed or we can leverage its methods for output control

$graph->clearScreen(); //clears already outputed graphs
Expand Down
11 changes: 6 additions & 5 deletions examples/floats.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$settings = new Settings();
Expand All @@ -15,7 +16,7 @@
try {
$line = [];
for ($i = 0; $i < 120; $i++) {
$line[$i] = ($lineA[$i - 1] ?? 1) + (lcg_value() * random_int(-1, 1));
$line[$i] = $lineA[$i - 1] ?? 1 + (lcg_value() * random_int(-1, 1));
}
for ($y = 0; $y < 1500; $y++) {
array_shift($line);
Expand All @@ -27,6 +28,6 @@
$lineGraph->chart()->clearScreen()->print()->wait();
$lineGraph->clearAllMarkers();
}
} catch (Exception $e) {
} catch (\Throwable $e) {
echo $e->getMessage();
}
10 changes: 5 additions & 5 deletions examples/html.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\HTMLColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\HTMLColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$lineGraph = new Linechart();
Expand All @@ -19,5 +20,4 @@
$lineGraph->addMarkers($lineA, ['color: green'], ['color: red']);
$lineGraph->setSettings($settings);


echo $lineGraph->chart();
$lineGraph->chart()->print();
11 changes: 6 additions & 5 deletions examples/image.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Colorizers\ImageColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Settings;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$lineGraph = new Linechart();
Expand All @@ -26,11 +27,11 @@
$font = __DIR__ . '/font/font.ttf';
$fontSize = 40;

$text = $graph->outputChart();
$text = (string) $graph;

// Calculate the required width to hold this text
$enclosingBox = imagettfbbox($fontSize, 0, $font, $text);
$width = ($enclosingBox[2] - $enclosingBox[0]) - 10;
$width = $enclosingBox[2] - $enclosingBox[0] - 10;

$height = $fontSize * $graph->getSettings()->getHeight() * 2;

Expand Down
7 changes: 4 additions & 3 deletions examples/largeKeys.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$lineGraph = new Linechart();
Expand All @@ -25,4 +26,4 @@
];
$lineGraph->addMarkers($lineA, [AsciiColorizer::GREEN, AsciiColorizer::BOLD]);

echo $lineGraph->chart();
$lineGraph->chart()->print();
5 changes: 2 additions & 3 deletions examples/line.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$settings = new Settings();
$settings->setFPS(40);
$settings->setHeight(null);

$lineGraph = new Linechart();
$lineGraph->setSettings($settings);

try {
$linechart = new Linechart();
$linechart->addMarkers([1, 1, 1, 1, 1, 1])->chart()->print();
} catch (Exception $e) {
} catch (\Throwable $e) {
echo $e->getMessage();
}
23 changes: 14 additions & 9 deletions examples/randomValues.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$settings = new Settings();
Expand All @@ -13,11 +14,15 @@
$lineGraph->setSettings($settings);

try {
$lineA = [];
$lineB = [];
$lineC = [];
$lineD = [];
for ($i = 0; $i < 120; $i++) {
$lineA[$i] = ($lineA[$i - 1] ?? 1) + random_int(-2, 2);
$lineB[$i] = ($lineB[$i - 1] ?? 1) + random_int(-2, 2);
$lineC[$i] = ($lineC[$i - 1] ?? 1) + random_int(-2, 2);
$lineD[$i] = ($lineD[$i - 1] ?? 1) + random_int(-2, 2);
$lineA[$i] = $lineA[$i - 1] ?? 1 + random_int(-2, 2);
$lineB[$i] = $lineB[$i - 1] ?? 1 + random_int(-2, 2);
$lineC[$i] = $lineC[$i - 1] ?? 1 + random_int(-2, 2);
$lineD[$i] = $lineD[$i - 1] ?? 1 + random_int(-2, 2);
}
for ($y = 0; $y < 1500; $y++) {
array_shift($lineA);
Expand All @@ -39,6 +44,6 @@
$lineGraph->chart()->clearScreen()->print()->wait();
$lineGraph->clearAllMarkers();
}
} catch (Exception $e) {
echo $e->getMessage();
} catch (Throwable $throwable) {
echo $throwable->getMessage();
}
12 changes: 6 additions & 6 deletions examples/realData.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$settings = new Settings();
$settings->setFPS(40);
$settings->setHeight(null);
$lineGraph = new Linechart();
$lineGraph->setSettings($settings);

try {
$line = [0.0208, 0.020858, 0.021, 0.021, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.021056, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.021124, 0.0214, 0.0215, 0.021436, 0.02149, 0.021488, 0.02149, 0.02145, 0.02145, 0.021406, 0.02145, 0.02145, 0.02145, 0.0214, 0.02145, 0.021487, 0.02149, 0.021482, 0.02148, 0.02148, 0.0215, 0.0215, 0.0215, 0.0215, 0.021499, 0.021473, 0.021454, 0.021497, 0.021489, 0.021454, 0.021705, 0.02151, 0.021513,];
$line = [0.0208, 0.020858, 0.021, 0.021, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.021056, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.0211, 0.021124, 0.0214, 0.0215, 0.021436, 0.02149, 0.021488, 0.02149, 0.02145, 0.02145, 0.021406, 0.02145, 0.02145, 0.02145, 0.0214, 0.02145, 0.021487, 0.02149, 0.021482, 0.02148, 0.02148, 0.0215, 0.0215, 0.0215, 0.0215, 0.021499, 0.021473, 0.021454, 0.021497, 0.021489, 0.021454, 0.021705, 0.02151, 0.021513];

$lineGraph->addMarkers($line, [AsciiColorizer::GREEN], [AsciiColorizer::RED]);

$lineGraph->chart()->clearScreen()->print()->wait();
$lineGraph->clearAllMarkers();
} catch (Exception $e) {
} catch (\Throwable $e) {
echo $e->getMessage();
}
7 changes: 4 additions & 3 deletions examples/sinus.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$lineGraph = new Linechart();
Expand Down
11 changes: 5 additions & 6 deletions examples/stretched.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
declare(strict_types = 1);

use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;
use noximo\PHPColoredAsciiLinechart\Linechart;
declare(strict_types=1);

use noximo\PHPColoredAsciiLinechart\Settings;
use noximo\PHPColoredAsciiLinechart\Linechart;
use noximo\PHPColoredAsciiLinechart\Colorizers\AsciiColorizer;

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$settings = new Settings();
$settings->setFPS(40);
$settings->setHeight(null);

$lineGraph = new Linechart();
$lineGraph->setSettings($settings);
Expand All @@ -23,7 +23,6 @@

$lineGraph->chart()->clearScreen()->print()->wait();
$lineGraph->clearAllMarkers();

} catch (Exception $e) {
} catch (\Throwable $e) {
echo $e->getMessage();
}
Loading

0 comments on commit e80aed9

Please sign in to comment.