Skip to content

Commit

Permalink
Minor CS and SA fixes
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jun 19, 2024
1 parent f2bd3af commit adf2270
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 55 deletions.
12 changes: 6 additions & 6 deletions composer.lock

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

53 changes: 26 additions & 27 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1706,54 +1706,39 @@
</file>
<file src="src/ValidatorPluginManager.php">
<DeprecatedMethod>
<code><![CDATA[getServiceLocator]]></code>
<code><![CDATA[getServiceLocator]]></code>
<code><![CDATA[addInitializer]]></code>
<code><![CDATA[addInitializer]]></code>
</DeprecatedMethod>
<MethodSignatureMismatch>
<code><![CDATA[ValidatorPluginManager]]></code>
</MethodSignatureMismatch>
<MissingParamType>
<code><![CDATA[$configOrContainerInstance]]></code>
</MissingParamType>
<MixedArgument>
<code><![CDATA[$configOrContainerInstance]]></code>
<code><![CDATA[$container->get('MvcTranslator')]]></code>
</MixedArgument>
<PossiblyUnusedMethod>
<code><![CDATA[validatePlugin]]></code>
</PossiblyUnusedMethod>
<PossiblyUnusedProperty>
<code><![CDATA[$shareByDefault]]></code>
</PossiblyUnusedProperty>
<RedundantConditionGivenDocblockType>
<code><![CDATA[$container->getServiceLocator()]]></code>
</RedundantConditionGivenDocblockType>
<NonInvariantDocblockPropertyType>
<code><![CDATA[$instanceOf]]></code>
</NonInvariantDocblockPropertyType>
<UnusedParam>
<code><![CDATA[$container]]></code>
</UnusedParam>
</file>
<file src="src/ValidatorPluginManagerAwareInterface.php">
<MissingReturnType>
<code><![CDATA[setValidatorPluginManager]]></code>
</MissingReturnType>
</file>
<file src="src/ValidatorPluginManagerFactory.php">
<DeprecatedClass>
<code><![CDATA[new Config($config['validators'])]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[ValidatorPluginManagerFactory]]></code>
</DeprecatedInterface>
<MixedArgument>
<code><![CDATA[$config['validators']]]></code>
</MixedArgument>
<ParamNameMismatch>
<code><![CDATA[$container]]></code>
</ParamNameMismatch>
</file>
<file src="src/ValidatorProviderInterface.php">
<UnusedClass>
<code><![CDATA[ValidatorProviderInterface]]></code>
</UnusedClass>
</file>
<file src="test/AbstractValidatorTest.php">
<DeprecatedMethod>
<code><![CDATA[setService]]></code>
<code><![CDATA[setService]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[$options]]></code>
</InvalidArgument>
Expand Down Expand Up @@ -1874,6 +1859,9 @@
</PossiblyUnusedMethod>
</file>
<file src="test/EmailAddressTest.php">
<DeprecatedMethod>
<code><![CDATA[setService]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[Hostname::ALLOW_ALL]]></code>
<code><![CDATA[Hostname::ALLOW_ALL]]></code>
Expand Down Expand Up @@ -2221,6 +2209,9 @@
</PossiblyUnusedMethod>
</file>
<file src="test/HostnameTest.php">
<DeprecatedMethod>
<code><![CDATA[setService]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[$option]]></code>
<code><![CDATA[$option]]></code>
Expand Down Expand Up @@ -2442,6 +2433,9 @@
</PossiblyInvalidCast>
</file>
<file src="test/StaticValidatorTest.php">
<DeprecatedMethod>
<code><![CDATA[setService]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[1]]></code>
</InvalidArgument>
Expand Down Expand Up @@ -2538,6 +2532,11 @@
<code><![CDATA[$errnum]]></code>
</UnusedParam>
</file>
<file src="test/ValidatorPluginManagerTest.php">
<DeprecatedMethod>
<code><![CDATA[setService]]></code>
</DeprecatedMethod>
</file>
<file src="test/_files/MyBarcode1.php">
<UnusedClass>
<code><![CDATA[MyBarcode1]]></code>
Expand Down
8 changes: 0 additions & 8 deletions src/ValidatorPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
*/
final class ValidatorPluginManagerFactory
{
/**
* {@inheritDoc}
*
* @param string $name
* @param ServiceManagerConfiguration|null $options
* @return ValidatorPluginManager
* @psalm-suppress MoreSpecificImplementedParamType
*/
public function __invoke(ContainerInterface $container): ValidatorPluginManager
{
// If this is in a laminas-mvc application, the ServiceListener will inject
Expand Down
5 changes: 3 additions & 2 deletions test/StaticAnalysis/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace LaminasTest\Validator\StaticAnalysis;

use Laminas\ServiceManager\ServiceManager;
use Laminas\Validator\Uuid;
use Laminas\Validator\ValidatorInterface;
use Laminas\Validator\ValidatorPluginManager;
Expand All @@ -13,13 +14,13 @@ final class PluginManager
{
public function validateAssertsPluginType(mixed $input): ValidatorInterface
{
(new ValidatorPluginManager())->validate($input);
(new ValidatorPluginManager(new ServiceManager()))->validate($input);

return $input;
}

public function getWithClassStringReturnsCorrectInstanceType(): ValidatorInterface
{
return (new ValidatorPluginManager())->get(Uuid::class);
return (new ValidatorPluginManager(new ServiceManager()))->get(Uuid::class);
}
}
6 changes: 0 additions & 6 deletions test/ValidatorPluginManagerCompatibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Laminas\ServiceManager\AbstractSingleInstancePluginManager;
use Laminas\ServiceManager\ServiceManager;
use Laminas\ServiceManager\Test\CommonPluginManagerTrait;
use Laminas\Validator\Exception\RuntimeException;
use Laminas\Validator\ValidatorInterface;
use Laminas\Validator\ValidatorPluginManager;
use PHPUnit\Framework\TestCase;
Expand All @@ -33,11 +32,6 @@ protected static function getPluginManager(array $config = []): AbstractSingleIn
return new ValidatorPluginManager(new ServiceManager(), $config);
}

protected function getV2InvalidPluginException(): string
{
return RuntimeException::class;
}

protected function getInstanceOf(): string
{
return ValidatorInterface::class;
Expand Down
11 changes: 5 additions & 6 deletions test/ValidatorPluginManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
use Laminas\Validator\ValidatorPluginManager;
use Laminas\Validator\ValidatorPluginManagerFactory;
use LaminasTest\Validator\TestAsset\InMemoryContainer;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;

final class ValidatorPluginManagerFactoryTest extends TestCase
{
public function testFactoryReturnsPluginManager(): void
{
$factory = new ValidatorPluginManagerFactory();
$validators = $factory(new InMemoryContainer(), ValidatorPluginManagerFactory::class);
$validators = $factory(new InMemoryContainer());

self::assertInstanceOf(ValidatorPluginManager::class, $validators);
}
Expand All @@ -41,7 +40,7 @@ public function testConfiguresValidatorServicesWhenFound(): void
$container->set('config', $config);

$factory = new ValidatorPluginManagerFactory();
$validators = $factory($container, 'ValidatorManager');
$validators = $factory($container);

self::assertInstanceOf(ValidatorPluginManager::class, $validators);
self::assertTrue($validators->has('test'));
Expand All @@ -66,7 +65,7 @@ public function testDoesNotConfigureValidatorServicesWhenServiceListenerPresent(
->with('config');

$factory = new ValidatorPluginManagerFactory();
$validators = $factory($container, 'ValidatorManager');
$validators = $factory($container);

self::assertInstanceOf(ValidatorPluginManager::class, $validators);
self::assertFalse($validators->has('test'));
Expand All @@ -77,7 +76,7 @@ public function testDoesNotConfigureValidatorServicesWhenConfigServiceNotPresent
{
$container = new InMemoryContainer();
$factory = new ValidatorPluginManagerFactory();
$validators = $factory($container, 'ValidatorManager');
$validators = $factory($container);

self::assertInstanceOf(ValidatorPluginManager::class, $validators);
}
Expand All @@ -87,7 +86,7 @@ public function testDoesNotConfigureValidatorServicesWhenConfigServiceDoesNotCon
$container = new InMemoryContainer();
$container->set('config', ['foo' => 'bar']);
$factory = new ValidatorPluginManagerFactory();
$validators = $factory($container, 'ValidatorManager');
$validators = $factory($container);

self::assertInstanceOf(ValidatorPluginManager::class, $validators);
self::assertFalse($validators->has('foo'));
Expand Down

0 comments on commit adf2270

Please sign in to comment.