Skip to content

Commit

Permalink
Added phpstan local and github analysis. Some fixes applied
Browse files Browse the repository at this point in the history
  • Loading branch information
franiglesias committed Jun 25, 2020
1 parent f29fce6 commit feefc74
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run test suite
run: composer run-script test

- name: PHPStan
uses: chindit/actions-phpstan@master
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "library",
"require-dev": {
"phpunit/phpunit": "^9.2",
"mikey179/vfsstream": "^1.6"
"mikey179/vfsstream": "^1.6",
"phpstan/phpstan": "^0.12.31"
},
"license": "MIT",
"authors": [
Expand Down
58 changes: 57 additions & 1 deletion composer.lock

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

5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 5
paths:
- src
- tests
4 changes: 3 additions & 1 deletion src/Reader/Mapper/DtoMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

class DtoMapper extends RowMapper
{
/** @var string */
private $dtoClass;

public function __construct($dtoClass)
public function __construct(string $dtoClass)
{
$this->dtoClass = $dtoClass;
}

/** @return mixed */
public function map(array $line, ?array $headers = null)
{
$this->assertHeaders($headers);
Expand Down
6 changes: 5 additions & 1 deletion src/Writer/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
namespace TalkingBit\Csv\Writer;

use TalkingBit\Csv\Shared\CSVFile;
use TalkingBit\Csv\Shared\CSVSettings;
use TalkingBit\Csv\Shared\NoTargetFileDefined;

class Writer
{
/** @var CSVFile */
private $targetFile;
/** @var bool */
private $firstRow = true;

/** @param array<mixed> $row */
public function writeRow($row): void
{
$this->assertCSVFile();
Expand Down Expand Up @@ -54,6 +55,9 @@ public function withEnclosure(string $enclosure): self
return $this;
}

/**
* @param array<mixed> $row
*/
private function writeHeaders(array $row): void
{
$headers = array_keys($row);
Expand Down

0 comments on commit feefc74

Please sign in to comment.