-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from kynx/static-analysis-tests
More collection fixes; added static analysis tests
- Loading branch information
Showing
16 changed files
with
208 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Regenerate docblocks on test/StaticAnalysis files so psalm will pick up any breakages | ||
|
||
WORKDIR=$2 | ||
JOB=$3 | ||
COMMAND=$(echo "${JOB}" | jq -r '.command') | ||
if [[ ! ${COMMAND} =~ psalm ]];then | ||
exit 0 | ||
fi | ||
|
||
cd "$WORKDIR" | ||
vendor/bin/laminas --container test/container.php form:psalm-type test/StaticAnalysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ public function testElementAsTargetElementValidates(): void | |
{ | ||
$expected = <<<EOT | ||
array{ | ||
foo?: array<array-key, non-empty-string>, | ||
foo: array<array-key, non-empty-string>, | ||
} | ||
EOT; | ||
$data = ['foo' => ['[email protected]']]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KynxTest\Laminas\FormShape\StaticAnalysis; | ||
|
||
use Laminas\Form\Element\Hidden; | ||
use Laminas\Form\Element\Number; | ||
use Laminas\Form\Element\Select; | ||
use Laminas\Form\Element\Text; | ||
use Laminas\Form\Fieldset; | ||
use Laminas\InputFilter\InputFilterProviderInterface; | ||
|
||
/** | ||
* @psalm-type TAlbumData = array{ | ||
* id: null|string, | ||
* title: non-empty-string, | ||
* genre: '1'|'2'|'3', | ||
* rating: numeric-string, | ||
* } | ||
*/ | ||
final class Album extends Fieldset implements InputFilterProviderInterface | ||
{ | ||
/** | ||
* @param int|null|string $name | ||
*/ | ||
public function __construct($name = null, array $options = []) | ||
{ | ||
parent::__construct($name, $options); | ||
|
||
$this->add(new Hidden('id')); | ||
$this->add(new Text('title')); | ||
$this->add(new Select('genre', ['value_options' => [1 => 'Good', 2 => 'Bad', 3 => "Ugly"]])); | ||
$this->add(new Number('rating', ['min' => 1, 'max' => 10])); | ||
} | ||
|
||
public function getInputFilterSpecification(): array | ||
{ | ||
return [ | ||
'id' => [ | ||
'required' => true, | ||
'allow_empty' => true, | ||
], | ||
'title' => [ | ||
'required' => true, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KynxTest\Laminas\FormShape\StaticAnalysis; | ||
|
||
use Laminas\Form\Element\Collection; | ||
use Laminas\Form\Element\Hidden; | ||
use Laminas\Form\Element\Text; | ||
use Laminas\Form\Form; | ||
|
||
/** | ||
* @psalm-import-type TAlbumData from Album | ||
* @psalm-type TArtistData = array{ | ||
* id: null|string, | ||
* name: null|string, | ||
* albums: array<array-key, TAlbumData>, | ||
* } | ||
* @extends Form<TArtistData> | ||
*/ | ||
final class Artist extends Form | ||
{ | ||
/** | ||
* @param int|null|string $name | ||
*/ | ||
public function __construct($name = null, array $options = []) | ||
{ | ||
parent::__construct($name, $options); | ||
|
||
$this->add(new Hidden('id')); | ||
$this->add(new Text('name')); | ||
$collection = new Collection('albums'); | ||
$collection->setTargetElement(new Album()); | ||
$this->add($collection); | ||
} | ||
} |
Oops, something went wrong.