Skip to content

Commit

Permalink
Fixed PHPDoc types, PHPStan analyzes *.phpt files
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Jul 26, 2023
1 parent f4c93ee commit 3ae2486
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ parameters:
paths:
- src
- tests

fileExtensions:
- php
- phpt
6 changes: 3 additions & 3 deletions src/ForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ForeignKey
const ACTION_CASCADE = 'CASCADE';
const ACTION_SET_NULL = 'SET NULL';

/** @var string */
/** @var string|NULL */
private $name;

/** @var string[] */
Expand All @@ -30,7 +30,7 @@ class ForeignKey


/**
* @param string $name
* @param string|NULL $name
* @param string[]|string $columns
* @param string|NULL $targetTable
* @param string[]|string $targetColumns
Expand Down Expand Up @@ -59,7 +59,7 @@ public function __construct($name, $columns, $targetTable, $targetColumns)


/**
* @return string
* @return string|NULL
*/
public function getName()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Index
const TYPE_UNIQUE = 'UNIQUE';
const TYPE_FULLTEXT = 'FULLTEXT';

/** @var string */
/** @var string|NULL */
private $name;

/** @var string */
Expand All @@ -21,7 +21,7 @@ class Index


/**
* @param string $name
* @param string|NULL $name
* @param string[]|string $columns
* @param string $type
*/
Expand All @@ -41,7 +41,7 @@ public function __construct($name, $columns = [], $type = self::TYPE_INDEX)


/**
* @return string
* @return string|NULL
*/
public function getName()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getOptions()
* @param string|Column $name
* @param string|NULL $type
* @param array<scalar>|NULL $parameters
* @param array<string, string> $options OPTION => NULL
* @param array<string|int, scalar|NULL> $options OPTION => NULL
* @return Column
*/
public function addColumn($name, $type = NULL, array $parameters = NULL, array $options = [])
Expand Down Expand Up @@ -162,7 +162,7 @@ public function getColumns()


/**
* @param string|Index $name
* @param string|Index|NULL $name
* @param string[]|string $columns
* @param string $type
* @return Index
Expand Down Expand Up @@ -229,7 +229,7 @@ public function getIndexes()


/**
* @param string|ForeignKey $name
* @param string|ForeignKey|NULL $name
* @param string[]|string $columns
* @param string $targetTable
* @param string[]|string $targetColumns
Expand Down
5 changes: 4 additions & 1 deletion tests/SqlSchema/Table.validate.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ test(function () {
test(function () {
$table = new Table('book');
$table->addColumn('id', 'INT');
Assert::null($table->validate());

Assert::noError(function () use ($table) {
$table->validate();
});
});

0 comments on commit 3ae2486

Please sign in to comment.