Skip to content

Commit

Permalink
psalm to level 2
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessandroMinoccheri committed Jul 15, 2021
1 parent 148fdff commit bac4ba8
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
run: XDEBUG_MODE=coverage bin/phpspec run -f progress -c phpspec-coverage.yml

- name: Run behat tests
run: ./bin/behat
run: ./bin/behat --snippets-for
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Removed
* upgrade psalm error level to 2

### Removed
* CircleCI configuration for CI

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use PUGX\Poser\Render\SvgPlasticRender;
use PUGX\Poser\Poser;

$render = new SvgPlasticRender();
$poser = new Poser($render);
$poser = new Poser([$render]);

echo $poser->generate('license', 'MIT', '428F7E', 'plastic');
// or
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"php-cs-fixer": "bin/php-cs-fixer fix -v --ansi",
"phpspec": "bin/phpspec run --format=pretty --ansi",
"phpspec-coverage": "bin/phpspec run -f progress -c phpspec-coverage.yml --ansi",
"behat": "bin/behat",
"behat": "bin/behat --snippets-for",
"docker:build:php74": "docker build -t pugx/poser:php74 -f .docker/base/php74/Dockerfile .",
"docker:push:php74": "docker push pugx/poser:php74",
"docker:build:php80": "docker build -t pugx/poser:php80 -f .docker/base/php80/Dockerfile .",
Expand Down
6 changes: 3 additions & 3 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Context\Context;

/**
* Behat context class.
*/
class FeatureContext implements SnippetAcceptingContext
class FeatureContext implements Context
{
private string $binFolder;
private string $output;
Expand Down Expand Up @@ -80,7 +80,7 @@ private function assertEquals($given, $expected): void
\similar_text($expected, $given, $perc);

if ($perc < 94) {
throw new \Exception('String similarity:' . $perc . '%. String expected:' . $expected . PHP_EOL . ' given:' . $given);
throw new \Exception('String similarity:' . $perc . '%. String expected:' . $expected . \PHP_EOL . ' given:' . $given);
}
}
}
3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="3"
errorLevel="2"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand All @@ -13,6 +13,7 @@
<ignoreFiles>
<directory name="vendor" />
<directory name="spec" />
<directory name="features" />
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 1 addition & 1 deletion spec/PUGX/Poser/PoserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getMatchers(): array
$regex = '/^<svg.*width="((.|\n)*)' . $subject . '((.|\n)*)' . $status . '((.|\n)*)<\/svg>$/';
$matches = [];

return \preg_match($regex, $object, $matches, PREG_OFFSET_CAPTURE, 0);
return \preg_match($regex, $object, $matches, \PREG_OFFSET_CAPTURE, 0);
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion spec/PUGX/Poser/Render/SvgFlatRenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getMatchers(): array
$regex = '/^<svg.*width="((.|\n)*)<\/svg>$/';
$matches = [];

return \preg_match($regex, (string) $subject, $matches, PREG_OFFSET_CAPTURE, 0);
return \preg_match($regex, (string) $subject, $matches, \PREG_OFFSET_CAPTURE, 0);
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion spec/PUGX/Poser/Render/SvgFlatSquareRenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getMatchers(): array
$regex = '/^<svg.*width="((.|\n)*)<\/svg>$/';
$matches = [];

return \preg_match($regex, (string) $subject, $matches, PREG_OFFSET_CAPTURE, 0);
return \preg_match($regex, (string) $subject, $matches, \PREG_OFFSET_CAPTURE, 0);
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion spec/PUGX/Poser/Render/SvgPlasticRenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getMatchers(): array
$regex = '/^<svg.*width="((.|\n)*)<\/svg>$/';
$matches = [];

return \preg_match($regex, (string) $subject, $matches, PREG_OFFSET_CAPTURE, 0);
return \preg_match($regex, (string) $subject, $matches, \PREG_OFFSET_CAPTURE, 0);
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private function __construct(string $content, string $style)
*/
public function __toString(): string
{
return (string) $this->content;
return $this->content;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Poser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ class Poser
*
* @param $renders
*/
public function __construct($renders)
public function __construct(array $renders)
{
$this->renders = [];
if (!\is_array($renders)) {
$renders = [$renders];
}

foreach ($renders as $render) {
$this->addStyleRender($render);
Expand Down
12 changes: 12 additions & 0 deletions src/UI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ class Command extends BaseCommand

protected string $header;

public function __construct(string $name = null)
{
parent::__construct($name);

$this->poser = new Poser([
new SvgPlasticRender(),
new SvgFlatRender(),
new SvgFlatSquareRender(),
]);
$this->header = self::HEADER;
}

private function init(): void
{
$this->poser = new Poser([
Expand Down
2 changes: 1 addition & 1 deletion src/UI/SingleCommandApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(Command $command, string $version = 'UNKNOWN')

// Add the given command as single (accessible) command.
$this->add($command);
$this->commandName = (string) $commandName;
$this->commandName = $commandName;

// Override the Application's definition so that it does not
// require a command name as first argument.
Expand Down

0 comments on commit bac4ba8

Please sign in to comment.