PHP code example of kynx / laminas-form-shape
1. Go to this page and download the library: Download kynx/laminas-form-shape library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kynx / laminas-form-shape example snippets
return [
'laminas-form-shape' => [
// custom config here
],
];
return [
'laminas-form-shape' => [
'indent' => "\t", // use tab for indenting
'max-string-length' => 50, // don't output long literal strings
'literal-limit' => 20, // don't output too many literals
],
];
return [
'laminas-form-shape' => [
'input' => [
'file' => [
// Laminas MVC applications
'laminas' => true,
'psr-7' => false,
// Mezzio applications
// 'laminas' => false,
// 'psr-7' => true,
],
],
],
];
return [
'laminas-form-shape' => [
'filter' => [
'allow-list' => [
'allow-empty-list' => false, // empty lists will produce "Cannot get type" error
],
],
],
];
use MyApp\Validator\MyCustomFileValidator;
return [
'laminas-form-shape' => [
'validator' => [
'file' => [
'validators' => [
MyCustomFileValidator::class,
],
],
],
],
];
return [
'laminas-form-shape' => [
'validator' => [
'in-array' => [
'allow-empty-haystack' => false, // empty haystacks will produce "Cannot get type" error
],
],
],
];
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TInt;
use Psalm\Type\Atomic\TString;
return [
'laminas-form-shape' => [
'validator' => [
'regex' => [
'(^-?\d*(\.\d+)?$)' => [TFloat::class, TInt::class, TNumericString::class],
],
],
],
];
use MyApp\Validator\MyCustomStringValidator;
return [
'laminas-form-shape' => [
'validator' => [
'non-empty-string' => [
'validators' => [
MyCustomStringValidator::class,
],
],
],
],
];
commandline
vendor/bin/laminas form:psalm-type src/Forms/Artist.php