Skip to content

Commit

Permalink
upgrade service manager and fix related errors in src
Browse files Browse the repository at this point in the history
Signed-off-by: Gary Lockett <[email protected]>
  • Loading branch information
Gary Lockett committed Jul 17, 2022
1 parent c1a8474 commit 680f57b
Show file tree
Hide file tree
Showing 30 changed files with 595 additions and 543 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"laminas/laminas-eventmanager": "<3.4.0",
"laminas/laminas-i18n": "<2.12.0",
"laminas/laminas-recaptcha": "<3.4.0",
"laminas/laminas-servicemanager": "<3.10.0",
"laminas/laminas-servicemanager": "<3.14.0",
"laminas/laminas-view": "<2.14.0"
},
"require-dev": {
Expand All @@ -34,7 +34,7 @@
"laminas/laminas-i18n": "^2.14.0",
"laminas/laminas-modulemanager": "^2.11.0",
"laminas/laminas-recaptcha": "^3.4.0",
"laminas/laminas-servicemanager": "^3.10.0",
"laminas/laminas-servicemanager": "^3.14.0",
"laminas/laminas-session": "^2.12.1",
"laminas/laminas-text": "^2.9.0",
"laminas/laminas-validator": "^2.16.0",
Expand All @@ -50,7 +50,7 @@
"laminas/laminas-eventmanager": "^3.4, reuired for laminas-form annotations support",
"laminas/laminas-i18n": "^2.12, required when using laminas-form view helpers",
"laminas/laminas-recaptcha": "^3.4, in order to use the ReCaptcha form element",
"laminas/laminas-servicemanager": "^3.10, required to use the form factories or provide services",
"laminas/laminas-servicemanager": "^3.14, required to use the form factories or provide services",
"laminas/laminas-view": "^2.14, required for using the laminas-form view helpers"
},
"config": {
Expand Down
912 changes: 444 additions & 468 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/book/v2/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ This now requires a factory to inject the form instance:
```php
namespace Application\Controller;

use Interop\Container\ContainerInterface;
use Application\Form\MyForm;
use Psr\Container\ContainerInterface;

class IndexControllerFactory
{
Expand Down Expand Up @@ -394,9 +394,9 @@ To enable this, we'll create a factory for our `AlbumFieldset` as follows:
namespace Application\Form;

use Album\Model\AlbumTable;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;

class AlbumFieldsetFactory implements FactoryInterface
{
Expand Down
4 changes: 2 additions & 2 deletions docs/book/v3/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ This now requires a factory to inject the form instance:
```php
namespace Application\Controller;

use Interop\Container\ContainerInterface;
use Application\Form\MyForm;
use Psr\Container\ContainerInterface;

class IndexControllerFactory
{
Expand Down Expand Up @@ -394,8 +394,8 @@ To enable this, we'll create a factory for our `AlbumFieldset` as follows:
namespace Application\Form;

use Album\Model\AlbumTable;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class AlbumFieldsetFactory implements FactoryInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/BuilderAbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Laminas\Form\Annotation;

use Interop\Container\ContainerInterface;
use Laminas\EventManager\EventManagerInterface;
use Laminas\EventManager\ListenerAggregateInterface;
use Laminas\Form\Factory;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;
use Psr\Container\ContainerInterface;

use function is_array;
use function is_subclass_of;
Expand Down
20 changes: 15 additions & 5 deletions src/Element/AbstractDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Laminas\Filter\StringTrim;
use Laminas\Form\Element;
use Laminas\Form\Exception\InvalidArgumentException;
use Laminas\InputFilter\InputFilterInterface;
use Laminas\InputFilter\InputProviderInterface;
use Laminas\Validator\Date as DateValidator;
use Laminas\Validator\DateStep as DateStepValidator;
Expand All @@ -20,6 +21,9 @@
use function date;
use function sprintf;

/**
* @psalm-import-type ValidatorSpecification from InputFilterInterface
*/
abstract class AbstractDateTime extends Element implements InputProviderInterface
{
/**
Expand All @@ -29,7 +33,7 @@ abstract class AbstractDateTime extends Element implements InputProviderInterfac
*/
protected $format = 'Y-m-d\TH:iP';

/** @var array */
/** @var array<ValidatorInterface> */
protected $validators = [];

/**
Expand Down Expand Up @@ -93,7 +97,7 @@ public function getFormat(): string
/**
* Get validators
*
* @return array
* @return array<ValidatorInterface>
*/
protected function getValidators(): array
{
Expand Down Expand Up @@ -184,18 +188,24 @@ protected function getStepValidator(): ValidatorInterface
*
* Attaches default validators for the datetime input.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
'name' => $this->getName(),
$spec = [
'required' => true,
'filters' => [
['name' => StringTrim::class],
],
'validators' => $this->getValidators(),
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/Element/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ public function getCaptcha(): ?LaminasCaptcha\AdapterInterface
*
* Attaches the captcha as a validator.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
$spec = [
'name' => $this->getName(),
'required' => true,
'filters' => [
['name' => StringTrim::class],
],
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

// Test that we have a captcha before adding it to the spec
$captcha = $this->getCaptcha();
if ($captcha instanceof LaminasCaptcha\AdapterInterface) {
Expand Down
8 changes: 6 additions & 2 deletions src/Element/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,19 @@ protected function getValidator(): ?ValidatorInterface
*
* Attaches the captcha as a validator.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
$spec = [
'name' => $this->getName(),
'required' => true,
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

if ($validator = $this->getValidator()) {
$spec['validators'] = [
$validator,
Expand Down
12 changes: 9 additions & 3 deletions src/Element/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ protected function getValidator(): ValidatorInterface
*
* Attaches a color validator.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
'name' => $this->getName(),
$spec = [
'required' => true,
'filters' => [
['name' => StringTrim::class],
Expand All @@ -56,5 +55,12 @@ public function getInputSpecification(): array
$this->getValidator(),
],
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}
}
12 changes: 9 additions & 3 deletions src/Element/Csrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ public function getAttributes(): array
*
* Attaches the captcha as a validator.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
'name' => $this->getName(),
$spec = [
'required' => true,
'filters' => [
['name' => StringTrim::class],
Expand All @@ -132,6 +131,13 @@ public function getInputSpecification(): array
$this->getCsrfValidator(),
],
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}

/**
Expand Down
15 changes: 9 additions & 6 deletions src/Element/DateSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,11 @@ protected function getValidator(): ValidatorInterface
}

/**
* Should return an array specification compatible with
* {@link Laminas\InputFilter\Factory::createInput()}.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
'name' => $this->getName(),
$spec = [
'required' => false,
'filters' => [
['name' => 'DateSelect'],
Expand All @@ -186,6 +182,13 @@ public function getInputSpecification(): array
$this->getValidator(),
],
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}

/**
Expand Down
15 changes: 9 additions & 6 deletions src/Element/DateTimeSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,11 @@ protected function getValidator(): ValidatorInterface
}

/**
* Should return an array specification compatible with
* {@link Laminas\InputFilter\Factory::createInput()}.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
'name' => $this->getName(),
$spec = [
'required' => false,
'filters' => [
['name' => 'DateTimeSelect'],
Expand All @@ -335,6 +331,13 @@ public function getInputSpecification(): array
$this->getValidator(),
],
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}

/**
Expand Down
12 changes: 9 additions & 3 deletions src/Element/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ public function setEmailValidator(ValidatorInterface $validator)
*
* Attaches an email validator.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
'name' => $this->getName(),
$spec = [
'required' => true,
'filters' => [
['name' => StringTrim::class],
Expand All @@ -120,5 +119,12 @@ public function getInputSpecification(): array
$this->getValidator(),
],
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}
}
15 changes: 9 additions & 6 deletions src/Element/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ public function prepareElement(FormInterface $form): void
}

/**
* Should return an array specification compatible with
* {@link Laminas\InputFilter\Factory::createInput()}.
*
* @return array
* {@inheritDoc}
*/
public function getInputSpecification(): array
{
return [
$spec = [
'type' => FileInput::class,
'name' => $this->getName(),
'required' => false,
];

$name = $this->getName();
if ($name !== null) {
$spec['name'] = $name;
}

return $spec;
}
}
Loading

0 comments on commit 680f57b

Please sign in to comment.