diff --git a/.travis.yml b/.travis.yml index 9dfbfe4..70c727f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: php sudo: false php: - - 7.0 - 7.1 - 7.2 - nightly diff --git a/build/cs-ruleset.xml b/build/cs-ruleset.xml index 11ab78d..eb75f31 100644 --- a/build/cs-ruleset.xml +++ b/build/cs-ruleset.xml @@ -1,9 +1,6 @@ - - - - + getId(); parent::__construct($message, $previous); diff --git a/src/Generated/SentryAutoloader.php b/src/Generated/SentryAutoloader.php index f9e9641..030825e 100644 --- a/src/Generated/SentryAutoloader.php +++ b/src/Generated/SentryAutoloader.php @@ -40,7 +40,7 @@ public function tryLoad(string $type): bool } $file = $this->classMap[$type]; - call_user_func(Closure::bind(function () use ($file) { + call_user_func(Closure::bind(function () use ($file): void { require $file; }, null)); @@ -50,7 +50,7 @@ public function tryLoad(string $type): bool /** * Regenerate all classes and create new class map */ - public function rebuild() + public function rebuild(): void { $this->classMap = $this->generator->generateAll(); $this->saveClassMap(); @@ -61,7 +61,7 @@ public function rebuild() * * @param bool $prepend should be set to true in most cases in order to load the generated classes */ - public function register(bool $prepend = true) + public function register(bool $prepend = true): void { if ($this->isClassMapReady()) { $this->loadClassMap(); @@ -78,7 +78,7 @@ public function isClassMapReady(): bool return is_file($this->classMapTargetFile); } - private function saveClassMap() + private function saveClassMap(): void { $fileContent = sprintf('classMap, true)); file_put_contents($this->classMapTargetFile, $fileContent); @@ -87,7 +87,7 @@ private function saveClassMap() /** * @codeCoverageIgnore private method called only from global dependent code */ - private function loadClassMap() + private function loadClassMap(): void { $this->classMap = require $this->classMapTargetFile; } diff --git a/src/Generated/exceptions/NoMethodsToBeGeneratedException.php b/src/Generated/exceptions/NoMethodsToBeGeneratedException.php index 6492685..39b5b03 100644 --- a/src/Generated/exceptions/NoMethodsToBeGeneratedException.php +++ b/src/Generated/exceptions/NoMethodsToBeGeneratedException.php @@ -12,7 +12,7 @@ class NoMethodsToBeGeneratedException extends \Consistence\PhpException /** @var \Consistence\Sentry\Metadata\ClassMetadata */ private $classMetadata; - public function __construct(ClassMetadata $classMetadata, \Throwable $previous = null) + public function __construct(ClassMetadata $classMetadata, ?\Throwable $previous = null) { parent::__construct( sprintf('Class %s has no methods to be generated', $classMetadata->getName()), diff --git a/src/Metadata/BidirectionalAssociationType.php b/src/Metadata/BidirectionalAssociationType.php index 9c4ff94..ca74b2b 100644 --- a/src/Metadata/BidirectionalAssociationType.php +++ b/src/Metadata/BidirectionalAssociationType.php @@ -7,7 +7,7 @@ class BidirectionalAssociationType extends \Consistence\Enum\Enum { - const ONE = 'one'; - const MANY = 'many'; + public const ONE = 'one'; + public const MANY = 'many'; } diff --git a/src/Metadata/PropertyMetadata.php b/src/Metadata/PropertyMetadata.php index 3966277..5bddd38 100644 --- a/src/Metadata/PropertyMetadata.php +++ b/src/Metadata/PropertyMetadata.php @@ -46,7 +46,7 @@ public function __construct( SentryIdentificator $sentryIdentificator, bool $nullable, array $sentryMethods, - BidirectionalAssociation $bidirectionalAssociation = null + ?BidirectionalAssociation $bidirectionalAssociation = null ) { $this->name = $name; @@ -91,10 +91,7 @@ public function getSentryMethods(): array return $this->sentryMethods; } - /** - * @return \Consistence\Sentry\Metadata\BidirectionalAssociation|null - */ - public function getBidirectionalAssociation() + public function getBidirectionalAssociation(): ?BidirectionalAssociation { return $this->bidirectionalAssociation; } @@ -155,7 +152,7 @@ function (SentryMethod $sentryMethod) use ($methodName, $requiredVisibility): bo /** * @return \Consistence\Sentry\Metadata\SentryAccess[] */ - public function getDefinedSentryAccess() + public function getDefinedSentryAccess(): array { $sentryAccess = []; foreach ($this->getSentryMethods() as $sentryMethod) { diff --git a/src/Metadata/Visibility.php b/src/Metadata/Visibility.php index f043da1..288b73e 100644 --- a/src/Metadata/Visibility.php +++ b/src/Metadata/Visibility.php @@ -7,9 +7,9 @@ class Visibility extends \Consistence\Enum\Enum { - const VISIBILITY_PUBLIC = 'public'; - const VISIBILITY_PROTECTED = 'protected'; - const VISIBILITY_PRIVATE = 'private'; + public const VISIBILITY_PUBLIC = 'public'; + public const VISIBILITY_PROTECTED = 'protected'; + public const VISIBILITY_PRIVATE = 'private'; /** @var int[] */ private static $comparationValues = [ diff --git a/src/Metadata/exceptions/MethodNotFoundException.php b/src/Metadata/exceptions/MethodNotFoundException.php index d29185c..976a245 100644 --- a/src/Metadata/exceptions/MethodNotFoundException.php +++ b/src/Metadata/exceptions/MethodNotFoundException.php @@ -13,7 +13,7 @@ class MethodNotFoundException extends \Consistence\PhpException /** @var string */ private $className; - public function __construct(string $methodName, string $className, \Throwable $previous = null) + public function __construct(string $methodName, string $className, ?\Throwable $previous = null) { parent::__construct(sprintf('Method %s not found on %s', $methodName, $className), $previous); $this->methodName = $methodName; diff --git a/src/Metadata/exceptions/MethodNotFoundForPropertyException.php b/src/Metadata/exceptions/MethodNotFoundForPropertyException.php index 710f925..f552e0d 100644 --- a/src/Metadata/exceptions/MethodNotFoundForPropertyException.php +++ b/src/Metadata/exceptions/MethodNotFoundForPropertyException.php @@ -20,7 +20,7 @@ public function __construct( string $methodName, string $className, string $propertyName, - \Throwable $previous = null + ?\Throwable $previous = null ) { parent::__construct(sprintf( diff --git a/src/Metadata/exceptions/NoSuitableMethodException.php b/src/Metadata/exceptions/NoSuitableMethodException.php index 4ec967c..595b143 100644 --- a/src/Metadata/exceptions/NoSuitableMethodException.php +++ b/src/Metadata/exceptions/NoSuitableMethodException.php @@ -16,7 +16,7 @@ class NoSuitableMethodException extends \Consistence\PhpException /** @var \Consistence\Sentry\Metadata\SentryAccess */ private $sentryAccess; - public function __construct(string $className, string $propertyName, SentryAccess $sentryAccess, \Throwable $previous = null) + public function __construct(string $className, string $propertyName, SentryAccess $sentryAccess, ?\Throwable $previous = null) { parent::__construct( sprintf( diff --git a/src/Metadata/exceptions/PropertyNotFoundException.php b/src/Metadata/exceptions/PropertyNotFoundException.php index 37b453c..83fe2b3 100644 --- a/src/Metadata/exceptions/PropertyNotFoundException.php +++ b/src/Metadata/exceptions/PropertyNotFoundException.php @@ -10,15 +10,10 @@ class PropertyNotFoundException extends \Consistence\PhpException /** @var string */ private $className; - /** @var string */ + /** @var string|null */ private $propertyName; - /** - * @param string $className - * @param string|null $propertyName - * @param \Throwable|null $previous - */ - public function __construct(string $className, $propertyName, \Throwable $previous = null) + public function __construct(string $className, ?string $propertyName, ?\Throwable $previous = null) { $message = sprintf('Property %s not found on class %s', $propertyName, $className); parent::__construct($message, $previous); @@ -31,10 +26,7 @@ public function getClassName(): string return $this->className; } - /** - * @return string|null - */ - public function getPropertyName() + public function getPropertyName(): ?string { return $this->propertyName; } diff --git a/src/MetadataSource/Annotation/AnnotationMetadataSource.php b/src/MetadataSource/Annotation/AnnotationMetadataSource.php index 6b92562..e15b26d 100644 --- a/src/MetadataSource/Annotation/AnnotationMetadataSource.php +++ b/src/MetadataSource/Annotation/AnnotationMetadataSource.php @@ -23,12 +23,12 @@ class AnnotationMetadataSource extends \Consistence\ObjectPrototype implements \Consistence\Sentry\MetadataSource\MetadataSource { - const IDENTIFICATOR_ANNOTATION = 'var'; + public const IDENTIFICATOR_ANNOTATION = 'var'; - const METHOD_PARAM_NAME = 'name'; - const METHOD_PARAM_VISIBILITY = 'visibility'; + public const METHOD_PARAM_NAME = 'name'; + public const METHOD_PARAM_VISIBILITY = 'visibility'; - const DEFAULT_VISIBILITY = Visibility::VISIBILITY_PUBLIC; + public const DEFAULT_VISIBILITY = Visibility::VISIBILITY_PUBLIC; /** @var \Consistence\Sentry\Factory\SentryFactory */ private $sentryFactory; @@ -130,7 +130,7 @@ private function getSentryIdentificator(ReflectionProperty $propertyReflection): * @param \Consistence\Sentry\Type\Sentry $sentry * @return \Consistence\Sentry\Metadata\SentryMethod[] */ - private function createSentryMethods(ReflectionProperty $propertyReflection, Sentry $sentry) + private function createSentryMethods(ReflectionProperty $propertyReflection, Sentry $sentry): array { $sentryMethods = []; foreach ($sentry->getSupportedAccess() as $sentryAccess) { @@ -146,7 +146,7 @@ private function createSentryMethods(ReflectionProperty $propertyReflection, Sen * @param \Consistence\Sentry\Metadata\SentryAccess $sentryAccess * @return \Consistence\Sentry\Metadata\SentryMethod[] */ - private function createSentryMethodsForAccess(ReflectionProperty $propertyReflection, Sentry $sentry, SentryAccess $sentryAccess) + private function createSentryMethodsForAccess(ReflectionProperty $propertyReflection, Sentry $sentry, SentryAccess $sentryAccess): array { $sentryMethodsForAccess = []; $sentryAccessAnnotations = $this->annotationProvider->getPropertyAnnotations($propertyReflection, $sentryAccess->getName()); diff --git a/src/MetadataSource/Annotation/exceptions/NoSentryIdentificatorException.php b/src/MetadataSource/Annotation/exceptions/NoSentryIdentificatorException.php index a05d02c..4b37992 100644 --- a/src/MetadataSource/Annotation/exceptions/NoSentryIdentificatorException.php +++ b/src/MetadataSource/Annotation/exceptions/NoSentryIdentificatorException.php @@ -7,7 +7,7 @@ class NoSentryIdentificatorException extends \Consistence\PhpException { - public function __construct(\Throwable $previous = null) + public function __construct(?\Throwable $previous = null) { parent::__construct('', $previous); } diff --git a/src/MetadataSource/Annotation/exceptions/PropertyMetadataCouldNotBeCreatedException.php b/src/MetadataSource/Annotation/exceptions/PropertyMetadataCouldNotBeCreatedException.php index 2fc4d76..75313b3 100644 --- a/src/MetadataSource/Annotation/exceptions/PropertyMetadataCouldNotBeCreatedException.php +++ b/src/MetadataSource/Annotation/exceptions/PropertyMetadataCouldNotBeCreatedException.php @@ -7,7 +7,7 @@ class PropertyMetadataCouldNotBeCreatedException extends \Consistence\PhpException { - public function __construct(\Throwable $previous = null) + public function __construct(?\Throwable $previous = null) { parent::__construct('', $previous); } diff --git a/src/MetadataSource/exceptions/ClassMetadataCouldNotBeCreatedException.php b/src/MetadataSource/exceptions/ClassMetadataCouldNotBeCreatedException.php index ae22bfd..3406d0a 100644 --- a/src/MetadataSource/exceptions/ClassMetadataCouldNotBeCreatedException.php +++ b/src/MetadataSource/exceptions/ClassMetadataCouldNotBeCreatedException.php @@ -12,7 +12,7 @@ class ClassMetadataCouldNotBeCreatedException extends \Consistence\PhpException /** @var \ReflectionClass */ private $classReflection; - public function __construct(ReflectionClass $classReflection, string $message, \Throwable $previous = null) + public function __construct(ReflectionClass $classReflection, string $message, ?\Throwable $previous = null) { parent::__construct( sprintf( diff --git a/src/SentryIdentificatorParser/SentryIdentificatorParseResult.php b/src/SentryIdentificatorParser/SentryIdentificatorParseResult.php index e80cba3..dc1d2bc 100644 --- a/src/SentryIdentificatorParser/SentryIdentificatorParseResult.php +++ b/src/SentryIdentificatorParser/SentryIdentificatorParseResult.php @@ -24,14 +24,7 @@ class SentryIdentificatorParseResult extends \Consistence\ObjectPrototype /** @var string|null */ private $sourceClass; - /** - * @param \Consistence\Sentry\Metadata\SentryIdentificator $sentryIdentificator - * @param string $type - * @param bool $many - * @param bool $nullable - * @param string|null $sourceClass - */ - public function __construct(SentryIdentificator $sentryIdentificator, string $type, bool $many, bool $nullable, $sourceClass) + public function __construct(SentryIdentificator $sentryIdentificator, string $type, bool $many, bool $nullable, ?string $sourceClass) { $this->sentryIdentificator = $sentryIdentificator; $this->type = $type; @@ -60,10 +53,7 @@ public function isNullable(): bool return $this->nullable; } - /** - * @return string|null - */ - public function getSourceClass() + public function getSourceClass(): ?string { return $this->sourceClass; } diff --git a/src/SentryIdentificatorParser/SentryIdentificatorParser.php b/src/SentryIdentificatorParser/SentryIdentificatorParser.php index fc72931..5487670 100644 --- a/src/SentryIdentificatorParser/SentryIdentificatorParser.php +++ b/src/SentryIdentificatorParser/SentryIdentificatorParser.php @@ -13,12 +13,12 @@ class SentryIdentificatorParser extends \Consistence\ObjectPrototype { - const MATCH_TYPE = 'type'; - const MATCH_MANY = 'many'; - const MATCH_NULLABLE = 'nullable'; - const MATCH_SOURCE_CLASS = 'sourceClass'; + private const MATCH_TYPE = 'type'; + private const MATCH_MANY = 'many'; + private const MATCH_NULLABLE = 'nullable'; + private const MATCH_SOURCE_CLASS = 'sourceClass'; - const SOURCE_CLASS_SEPARATOR = '::'; + public const SOURCE_CLASS_SEPARATOR = '::'; public function parse(SentryIdentificator $sentryIdentificator): SentryIdentificatorParseResult { diff --git a/src/SentryIdentificatorParser/exceptions/PatternDoesNotMatchException.php b/src/SentryIdentificatorParser/exceptions/PatternDoesNotMatchException.php index eb52997..8784130 100644 --- a/src/SentryIdentificatorParser/exceptions/PatternDoesNotMatchException.php +++ b/src/SentryIdentificatorParser/exceptions/PatternDoesNotMatchException.php @@ -12,7 +12,7 @@ class PatternDoesNotMatchException extends \Consistence\PhpException /** @var \Consistence\Sentry\Metadata\SentryIdentificator */ private $sentryIdentificator; - public function __construct(SentryIdentificator $sentryIdentificator, \Throwable $previous = null) + public function __construct(SentryIdentificator $sentryIdentificator, ?\Throwable $previous = null) { $message = 'Pattern does not match identificator ' . $sentryIdentificator->getId(); parent::__construct($message, $previous); diff --git a/src/Type/AbstractSentry.php b/src/Type/AbstractSentry.php index af8caba..f57c545 100644 --- a/src/Type/AbstractSentry.php +++ b/src/Type/AbstractSentry.php @@ -16,13 +16,13 @@ abstract class AbstractSentry extends \Consistence\ObjectPrototype implements \Consistence\Sentry\Type\Sentry { - const GET = 'get'; - const SET = 'set'; + public const GET = 'get'; + public const SET = 'set'; /** * @return \Consistence\Sentry\Metadata\SentryAccess[] */ - public function getSupportedAccess() + public function getSupportedAccess(): array { return [ new SentryAccess(self::GET), @@ -46,7 +46,7 @@ public function generateMethod(PropertyMetadata $property, SentryMethod $sentryM return $this->$callMethod($property, $sentryMethod); } - protected function checkSupportedSentryAccess(PropertyMetadata $property, SentryAccess $requiredSentryAccess) + protected function checkSupportedSentryAccess(PropertyMetadata $property, SentryAccess $requiredSentryAccess): void { try { ArrayType::getValueByCallback( @@ -79,7 +79,7 @@ public function getDefaultMethodName(SentryAccess $sentryAccess, string $propert * @param \Consistence\Sentry\Metadata\BidirectionalAssociationType $bidirectionalAssociationType * @return \Consistence\Sentry\Metadata\SentryAccess[] */ - public function getTargetAssociationAccessForAccess(SentryAccess $sentryAccess, BidirectionalAssociationType $bidirectionalAssociationType) + public function getTargetAssociationAccessForAccess(SentryAccess $sentryAccess, BidirectionalAssociationType $bidirectionalAssociationType): array { return []; } diff --git a/src/Type/CollectionType.php b/src/Type/CollectionType.php index 735e518..b571ceb 100644 --- a/src/Type/CollectionType.php +++ b/src/Type/CollectionType.php @@ -14,14 +14,14 @@ class CollectionType extends \Consistence\Sentry\Type\AbstractSentry { - const ADD = 'add'; - const CONTAINS = 'contains'; - const REMOVE = 'remove'; + public const ADD = 'add'; + public const CONTAINS = 'contains'; + public const REMOVE = 'remove'; /** * @return \Consistence\Sentry\Metadata\SentryAccess[] */ - public function getSupportedAccess() + public function getSupportedAccess(): array { return [ new SentryAccess(self::GET), diff --git a/src/Type/Sentry.php b/src/Type/Sentry.php index 8a788e6..7d5afe5 100644 --- a/src/Type/Sentry.php +++ b/src/Type/Sentry.php @@ -17,7 +17,7 @@ interface Sentry * * @return \Consistence\Sentry\Metadata\SentryAccess[] */ - public function getSupportedAccess(); + public function getSupportedAccess(): iterable; /** * Generate code for a SentryMethod @@ -44,6 +44,6 @@ public function getDefaultMethodName(SentryAccess $sentryAccess, string $propert * @param \Consistence\Sentry\Metadata\BidirectionalAssociationType $bidirectionalAssociationType * @return \Consistence\Sentry\Metadata\SentryAccess[] */ - public function getTargetAssociationAccessForAccess(SentryAccess $sentryAccess, BidirectionalAssociationType $bidirectionalAssociationType); + public function getTargetAssociationAccessForAccess(SentryAccess $sentryAccess, BidirectionalAssociationType $bidirectionalAssociationType): iterable; } diff --git a/src/Type/exceptions/SentryAccessNotSupportedException.php b/src/Type/exceptions/SentryAccessNotSupportedException.php index b3e1336..71dfcb5 100644 --- a/src/Type/exceptions/SentryAccessNotSupportedException.php +++ b/src/Type/exceptions/SentryAccessNotSupportedException.php @@ -15,7 +15,7 @@ class SentryAccessNotSupportedException extends \Consistence\PhpException /** @var string */ private $sentryClassName; - public function __construct(SentryAccess $sentryAccess, string $sentryClassName, \Throwable $previous = null) + public function __construct(SentryAccess $sentryAccess, string $sentryClassName, ?\Throwable $previous = null) { parent::__construct( sprintf('SentryAccess %s is not supported by %s', $sentryAccess->getName(), $sentryClassName), diff --git a/src/Type/exceptions/SentryAccessNotSupportedForPropertyException.php b/src/Type/exceptions/SentryAccessNotSupportedForPropertyException.php index 76331ce..620f105 100644 --- a/src/Type/exceptions/SentryAccessNotSupportedForPropertyException.php +++ b/src/Type/exceptions/SentryAccessNotSupportedForPropertyException.php @@ -23,7 +23,7 @@ public function __construct( PropertyMetadata $property, SentryAccess $sentryAccess, string $sentryClassName, - \Throwable $previous = null + ?\Throwable $previous = null ) { parent::__construct(sprintf( diff --git a/tests/Factory/SentryFactoryTest.php b/tests/Factory/SentryFactoryTest.php index 189c910..d1af7dd 100644 --- a/tests/Factory/SentryFactoryTest.php +++ b/tests/Factory/SentryFactoryTest.php @@ -9,7 +9,7 @@ class SentryFactoryTest extends \PHPUnit\Framework\TestCase { - public function testGetSentry() + public function testGetSentry(): void { $factory = $this->createMock(SentryFactory::class); $factory @@ -19,7 +19,7 @@ public function testGetSentry() $factory->getSentry(new SentryIdentificator('string')); } - public function testNoSentry() + public function testNoSentry(): void { $sentryIdentificator = new SentryIdentificator('string'); $factory = $this->createMock(SentryFactory::class); diff --git a/tests/Factory/Simple/SimpleSentryFactoryTest.php b/tests/Factory/Simple/SimpleSentryFactoryTest.php index 185061a..a11852c 100644 --- a/tests/Factory/Simple/SimpleSentryFactoryTest.php +++ b/tests/Factory/Simple/SimpleSentryFactoryTest.php @@ -44,20 +44,20 @@ public function sentryIdentificatorToSentryProvider(): array * @param \Consistence\Sentry\Metadata\SentryIdentificator $sentryIdentificator * @param \Consistence\Sentry\Type\Sentry $sentry */ - public function testGetSentry(SentryIdentificator $sentryIdentificator, Sentry $sentry) + public function testGetSentry(SentryIdentificator $sentryIdentificator, Sentry $sentry): void { $factory = new SimpleSentryFactory(new SentryIdentificatorParser()); $this->assertTrue($factory->getSentry($sentryIdentificator) instanceof $sentry); } - public function testSameSentryInstance() + public function testSameSentryInstance(): void { $factory = new SimpleSentryFactory(new SentryIdentificatorParser()); $sentry = $factory->getSentry(new SentryIdentificator('string')); $this->assertSame($sentry, $factory->getSentry(new SentryIdentificator('string'))); } - public function testNoSentry() + public function testNoSentry(): void { $factory = new SimpleSentryFactory(new SentryIdentificatorParser()); @@ -66,7 +66,7 @@ public function testNoSentry() $factory->getSentry(new SentryIdentificator('')); } - public function testNonexistingObject() + public function testNonexistingObject(): void { $factory = new SimpleSentryFactory(new SentryIdentificatorParser()); diff --git a/tests/Generated/SentryAutoloaderTest.php b/tests/Generated/SentryAutoloaderTest.php index 9caaa1c..ac1eca4 100644 --- a/tests/Generated/SentryAutoloaderTest.php +++ b/tests/Generated/SentryAutoloaderTest.php @@ -9,7 +9,7 @@ class SentryAutoloaderTest extends \PHPUnit\Framework\TestCase { - public function testRebuild() + public function testRebuild(): void { vfsStream::setup('sentry'); diff --git a/tests/Generated/SentryGeneratorTest.php b/tests/Generated/SentryGeneratorTest.php index 217d4f5..3b1cc24 100644 --- a/tests/Generated/SentryGeneratorTest.php +++ b/tests/Generated/SentryGeneratorTest.php @@ -19,7 +19,7 @@ class SentryGeneratorTest extends \PHPUnit\Framework\TestCase { - public function testGenerateClass() + public function testGenerateClass(): void { vfsStream::setup('sentry'); @@ -79,7 +79,7 @@ public function testGenerateClass() $this->assertFileExists($fileName); } - public function testGenerateClassSkipMethodNameCaseInsensitive() + public function testGenerateClassSkipMethodNameCaseInsensitive(): void { vfsStream::setup('sentry'); @@ -139,7 +139,7 @@ public function testGenerateClassSkipMethodNameCaseInsensitive() } } - public function testGenerateClassNoSentryMethods() + public function testGenerateClassNoSentryMethods(): void { vfsStream::setup('sentry'); @@ -180,7 +180,7 @@ public function testGenerateClassNoSentryMethods() } } - public function testGenerateAll() + public function testGenerateAll(): void { vfsStream::setup('sentry'); @@ -248,7 +248,7 @@ public function testGenerateAll() $this->assertTrue(isset($structure['sentry']['Consistence_Sentry_Generated_FooClass.php'])); } - public function testGenerateAllNoMethods() + public function testGenerateAllNoMethods(): void { vfsStream::setup('sentry'); diff --git a/tests/Generated/data/FooClass.php b/tests/Generated/data/FooClass.php index b78f894..edd2d58 100644 --- a/tests/Generated/data/FooClass.php +++ b/tests/Generated/data/FooClass.php @@ -9,7 +9,7 @@ class FooClass extends \Consistence\ObjectPrototype implements \Consistence\Sent private $fooProperty; - private function getSkipProperty() + private function getSkipProperty(): void { // empty } diff --git a/tests/Metadata/BidirectionalAssociationTest.php b/tests/Metadata/BidirectionalAssociationTest.php index 20a1830..1857a03 100644 --- a/tests/Metadata/BidirectionalAssociationTest.php +++ b/tests/Metadata/BidirectionalAssociationTest.php @@ -7,7 +7,7 @@ class BidirectionalAssociationTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $sentryMethods = [ new SentryMethod( @@ -28,7 +28,7 @@ public function testCreate() $this->assertTrue($bidirectionalAssociation->getTargetType()->equalsValue(BidirectionalAssociationType::ONE)); } - public function testGetTargetMethodForType() + public function testGetTargetMethodForType(): void { $sentryMethods = [ new SentryMethod( @@ -58,7 +58,7 @@ public function testGetTargetMethodForType() $this->assertTrue($targetMethod->getSentryAccess()->equals(new SentryAccess('set'))); } - public function testGetTargetMethodForTypeLooserVisibility() + public function testGetTargetMethodForTypeLooserVisibility(): void { $sentryMethods = [ new SentryMethod( @@ -83,7 +83,7 @@ public function testGetTargetMethodForTypeLooserVisibility() $this->assertTrue($targetMethod->getSentryAccess()->equals(new SentryAccess('set'))); } - public function testGetTargetMethodForTypeRequiredVisibilityNotFound() + public function testGetTargetMethodForTypeRequiredVisibilityNotFound(): void { $sentryMethods = [ new SentryMethod( @@ -112,7 +112,7 @@ public function testGetTargetMethodForTypeRequiredVisibilityNotFound() } } - public function testGetTargetMethodForTypePickByVisibility() + public function testGetTargetMethodForTypePickByVisibility(): void { $sentryMethods = [ new SentryMethod( @@ -142,7 +142,7 @@ public function testGetTargetMethodForTypePickByVisibility() $this->assertTrue($targetMethod->getSentryAccess()->equals(new SentryAccess('set'))); } - public function testGetTargetMethodForTypeMultipleSentryAccessPickByOrder() + public function testGetTargetMethodForTypeMultipleSentryAccessPickByOrder(): void { $sentryMethods = [ new SentryMethod( diff --git a/tests/Metadata/ClassMetadataTest.php b/tests/Metadata/ClassMetadataTest.php index 138501a..1a78926 100644 --- a/tests/Metadata/ClassMetadataTest.php +++ b/tests/Metadata/ClassMetadataTest.php @@ -7,7 +7,7 @@ class ClassMetadataTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $properties = [ new PropertyMetadata( @@ -29,7 +29,7 @@ public function testCreate() $this->assertSame($properties, $classMetadata->getProperties()); } - public function testGetSentryMethodByNameAndRequiredVisibility() + public function testGetSentryMethodByNameAndRequiredVisibility(): void { $sentryIdentificator = new SentryIdentificator('string'); $fooMethod = new SentryMethod( @@ -60,7 +60,7 @@ public function testGetSentryMethodByNameAndRequiredVisibility() $this->assertSame($fooMethod, $searchResult->getSentryMethod()); } - public function testGetSentryMethodByNameAndRequiredVisibilityMethodNotFound() + public function testGetSentryMethodByNameAndRequiredVisibilityMethodNotFound(): void { $fooProperty = new PropertyMetadata( 'fooProperty', @@ -88,7 +88,7 @@ public function testGetSentryMethodByNameAndRequiredVisibilityMethodNotFound() } } - public function testGetPropertyByName() + public function testGetPropertyByName(): void { $propertyName = 'fooProperty'; @@ -106,7 +106,7 @@ public function testGetPropertyByName() $this->assertSame($fooProperty, $classMetadata->getPropertyByName($propertyName)); } - public function testGetPropertyByNameNotFound() + public function testGetPropertyByNameNotFound(): void { $className = 'FooClass'; $classMetadata = new ClassMetadata($className, []); diff --git a/tests/Metadata/PropertyMetadataTest.php b/tests/Metadata/PropertyMetadataTest.php index bd7c892..9338ed0 100644 --- a/tests/Metadata/PropertyMetadataTest.php +++ b/tests/Metadata/PropertyMetadataTest.php @@ -7,7 +7,7 @@ class PropertyMetadataTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $targetClass = 'BarClass'; $sentryIdentificator = new SentryIdentificator($targetClass); @@ -49,7 +49,7 @@ public function testCreate() $this->assertSame($bidirectionalAssociation, $property->getBidirectionalAssociation()); } - public function testCreateScalar() + public function testCreateScalar(): void { $sentryIdentificator = new SentryIdentificator('int'); $property = new PropertyMetadata( @@ -71,7 +71,7 @@ public function testCreateScalar() $this->assertNull($property->getBidirectionalAssociation()); } - public function testGetSentryMethodByAccess() + public function testGetSentryMethodByAccess(): void { $targetClass = 'BarClass'; $sentryIdentificator = new SentryIdentificator($targetClass); @@ -104,7 +104,7 @@ public function testGetSentryMethodByAccess() )); } - public function testGetSentryMethodByAccessNotFound() + public function testGetSentryMethodByAccessNotFound(): void { $targetClass = 'BarClass'; $sentryIdentificator = new SentryIdentificator($targetClass); @@ -133,7 +133,7 @@ public function testGetSentryMethodByAccessNotFound() ); } - public function testGetSentryMethodByNameAndRequiredVisibility() + public function testGetSentryMethodByNameAndRequiredVisibility(): void { $sentryIdentificator = new SentryIdentificator('string'); $fooMethod = new SentryMethod( @@ -157,7 +157,7 @@ public function testGetSentryMethodByNameAndRequiredVisibility() )); } - public function testGetSentryMethodByNameAndRequiredVisibilityMethodNotFound() + public function testGetSentryMethodByNameAndRequiredVisibilityMethodNotFound(): void { $property = new PropertyMetadata( 'fooProperty', @@ -182,7 +182,7 @@ public function testGetSentryMethodByNameAndRequiredVisibilityMethodNotFound() } } - public function testGetSentryMethodByNameAndRequiredVisibilityCaseInsensitive() + public function testGetSentryMethodByNameAndRequiredVisibilityCaseInsensitive(): void { $sentryIdentificator = new SentryIdentificator('string'); $fooMethod = new SentryMethod( @@ -206,7 +206,7 @@ public function testGetSentryMethodByNameAndRequiredVisibilityCaseInsensitive() )); } - public function testGetDefinedSentryAccess() + public function testGetDefinedSentryAccess(): void { $targetClass = 'BarClass'; $sentryIdentificator = new SentryIdentificator($targetClass); diff --git a/tests/Metadata/SentryAccessTest.php b/tests/Metadata/SentryAccessTest.php index 644252f..0c2db0f 100644 --- a/tests/Metadata/SentryAccessTest.php +++ b/tests/Metadata/SentryAccessTest.php @@ -7,19 +7,19 @@ class SentryAccessTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $sentryAccess = new SentryAccess('foo'); $this->assertSame('foo', $sentryAccess->getName()); } - public function testEquals() + public function testEquals(): void { $sentryAccess = new SentryAccess('foo'); $this->assertTrue($sentryAccess->equals(new SentryAccess('foo'))); } - public function testNotEquals() + public function testNotEquals(): void { $sentryAccess = new SentryAccess('foo'); $this->assertFalse($sentryAccess->equals(new SentryAccess('bar'))); diff --git a/tests/Metadata/SentryIdentificatorTest.php b/tests/Metadata/SentryIdentificatorTest.php index 2539d0e..83d15c9 100644 --- a/tests/Metadata/SentryIdentificatorTest.php +++ b/tests/Metadata/SentryIdentificatorTest.php @@ -9,26 +9,26 @@ class SentryIdentificatorTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $sentryIdentificator = new SentryIdentificator('foo'); $this->assertSame('foo', $sentryIdentificator->getId()); } - public function testCreateObjectId() + public function testCreateObjectId(): void { $object = new stdClass(); $sentryIdentificator = new SentryIdentificator($object); $this->assertSame($object, $sentryIdentificator->getId()); } - public function testEquals() + public function testEquals(): void { $sentryIdentificator = new SentryIdentificator('foo'); $this->assertTrue($sentryIdentificator->equals(new SentryIdentificator('foo'))); } - public function testNotEquals() + public function testNotEquals(): void { $sentryIdentificator = new SentryIdentificator('foo'); $this->assertFalse($sentryIdentificator->equals(new SentryIdentificator('bar'))); diff --git a/tests/Metadata/SentryMethodTest.php b/tests/Metadata/SentryMethodTest.php index 9b43baa..f69e41c 100644 --- a/tests/Metadata/SentryMethodTest.php +++ b/tests/Metadata/SentryMethodTest.php @@ -7,7 +7,7 @@ class SentryMethodTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $sentryMethod = new SentryMethod( new SentryAccess('get'), diff --git a/tests/Metadata/VisibilityTest.php b/tests/Metadata/VisibilityTest.php index 612ff6b..db61b34 100644 --- a/tests/Metadata/VisibilityTest.php +++ b/tests/Metadata/VisibilityTest.php @@ -7,19 +7,19 @@ class VisibilityTest extends \PHPUnit\Framework\TestCase { - public function testCreate() + public function testCreate(): void { $this->assertInstanceOf(Visibility::class, Visibility::get(Visibility::VISIBILITY_PRIVATE)); $this->assertInstanceOf(Visibility::class, Visibility::get(Visibility::VISIBILITY_PROTECTED)); $this->assertInstanceOf(Visibility::class, Visibility::get(Visibility::VISIBILITY_PUBLIC)); } - public function testGetName() + public function testGetName(): void { $this->assertSame('public', Visibility::get(Visibility::VISIBILITY_PUBLIC)->getName()); } - public function testLooserOrEqualVisibilityPublic() + public function testLooserOrEqualVisibilityPublic(): void { $public = Visibility::get(Visibility::VISIBILITY_PUBLIC); $this->assertTrue($public->isLooserOrEqualTo(Visibility::get(Visibility::VISIBILITY_PUBLIC))); @@ -27,7 +27,7 @@ public function testLooserOrEqualVisibilityPublic() $this->assertTrue($public->isLooserOrEqualTo(Visibility::get(Visibility::VISIBILITY_PRIVATE))); } - public function testLooserOrEqualVisibilityProtected() + public function testLooserOrEqualVisibilityProtected(): void { $protected = Visibility::get(Visibility::VISIBILITY_PROTECTED); $this->assertFalse($protected->isLooserOrEqualTo(Visibility::get(Visibility::VISIBILITY_PUBLIC))); @@ -35,7 +35,7 @@ public function testLooserOrEqualVisibilityProtected() $this->assertTrue($protected->isLooserOrEqualTo(Visibility::get(Visibility::VISIBILITY_PRIVATE))); } - public function testLooserOrEqualVisibilityPrivate() + public function testLooserOrEqualVisibilityPrivate(): void { $private = Visibility::get(Visibility::VISIBILITY_PRIVATE); $this->assertFalse($private->isLooserOrEqualTo(Visibility::get(Visibility::VISIBILITY_PUBLIC))); @@ -43,7 +43,7 @@ public function testLooserOrEqualVisibilityPrivate() $this->assertTrue($private->isLooserOrEqualTo(Visibility::get(Visibility::VISIBILITY_PRIVATE))); } - public function testGetRequiredVisibilitySameClass() + public function testGetRequiredVisibilitySameClass(): void { $this->assertEquals( Visibility::get(Visibility::VISIBILITY_PRIVATE), @@ -51,7 +51,7 @@ public function testGetRequiredVisibilitySameClass() ); } - public function testGetRequiredVisibilityClassExtends() + public function testGetRequiredVisibilityClassExtends(): void { $this->assertEquals( Visibility::get(Visibility::VISIBILITY_PROTECTED), @@ -59,7 +59,7 @@ public function testGetRequiredVisibilityClassExtends() ); } - public function testGetRequiredVisibilityClassExtended() + public function testGetRequiredVisibilityClassExtended(): void { $this->assertEquals( Visibility::get(Visibility::VISIBILITY_PROTECTED), @@ -67,7 +67,7 @@ public function testGetRequiredVisibilityClassExtended() ); } - public function testGetRequiredVisibilityNoRelationClasses() + public function testGetRequiredVisibilityNoRelationClasses(): void { $this->assertEquals( Visibility::get(Visibility::VISIBILITY_PUBLIC), diff --git a/tests/MetadataSource/Annotation/AnnotationMetadataSourceTest.php b/tests/MetadataSource/Annotation/AnnotationMetadataSourceTest.php index c5f9984..53193ce 100644 --- a/tests/MetadataSource/Annotation/AnnotationMetadataSourceTest.php +++ b/tests/MetadataSource/Annotation/AnnotationMetadataSourceTest.php @@ -20,7 +20,7 @@ class AnnotationMetadataSourceTest extends \PHPUnit\Framework\TestCase { - public function testGet() + public function testGet(): void { $type = 'string'; $className = FooClass::class; @@ -85,7 +85,7 @@ public function testGet() $this->assertNull($fooPropety->getBidirectionalAssociation()); } - public function testCustomMethodName() + public function testCustomMethodName(): void { $type = 'string'; $className = FooClass::class; @@ -144,7 +144,7 @@ public function testCustomMethodName() $this->assertSame('test', $getMethod->getMethodName()); } - public function testCustomMethodVisibility() + public function testCustomMethodVisibility(): void { $type = 'string'; $className = FooClass::class; @@ -203,7 +203,7 @@ public function testCustomMethodVisibility() $this->assertSame(Visibility::get(Visibility::VISIBILITY_PRIVATE), $getMethod->getMethodVisibility()); } - public function testGetMultipleMethods() + public function testGetMultipleMethods(): void { $type = 'string'; $className = FooClass::class; @@ -270,7 +270,7 @@ public function testGetMultipleMethods() $this->assertCount(4, $sentryMethods); } - public function testClassIsNotSentryAware() + public function testClassIsNotSentryAware(): void { $sentryFactory = $this->createMock(SentryFactory::class); @@ -288,7 +288,7 @@ public function testClassIsNotSentryAware() $metedataSource->getMetadataForClass(new ReflectionClass($this)); } - public function testInvalidSentryIdentificator() + public function testInvalidSentryIdentificator(): void { $classReflection = new ReflectionClass(FooClass::class); @@ -316,7 +316,7 @@ public function testInvalidSentryIdentificator() $this->assertEmpty($classMetadata->getProperties()); } - public function testMissingSentryIdentificator() + public function testMissingSentryIdentificator(): void { $classReflection = new ReflectionClass(FooClass::class); $propertyReflection = $classReflection->getProperty('fooProperty'); @@ -343,7 +343,7 @@ public function testMissingSentryIdentificator() $this->assertEmpty($classMetadata->getProperties()); } - public function testNoSentryFound() + public function testNoSentryFound(): void { $classReflection = new ReflectionClass(FooClass::class); $sentryIdentificator = new SentryIdentificator(FooClass::class . '::Foo\Bar'); diff --git a/tests/MetadataSource/MetadataSourceTest.php b/tests/MetadataSource/MetadataSourceTest.php index 0477d7e..93aeeaf 100644 --- a/tests/MetadataSource/MetadataSourceTest.php +++ b/tests/MetadataSource/MetadataSourceTest.php @@ -9,7 +9,7 @@ class MetadataSourceTest extends \PHPUnit\Framework\TestCase { - public function testGetSentry() + public function testGetSentry(): void { $factory = $this->createMock(MetadataSource::class); $factory @@ -19,7 +19,7 @@ public function testGetSentry() $factory->getMetadataForClass(new ReflectionClass(FooClass::class)); } - public function testCouldNotBeCreated() + public function testCouldNotBeCreated(): void { $classReflection = new ReflectionClass(FooClass::class); $factory = $this->createMock(MetadataSource::class); diff --git a/tests/SentryIdentificatorParser/SentryIdentificatorParserTest.php b/tests/SentryIdentificatorParser/SentryIdentificatorParserTest.php index ab34b84..59bdb6e 100644 --- a/tests/SentryIdentificatorParser/SentryIdentificatorParserTest.php +++ b/tests/SentryIdentificatorParser/SentryIdentificatorParserTest.php @@ -63,8 +63,8 @@ public function testMatch( string $expectedType, bool $expectedMany, bool $expectedNullable, - $sourceClass - ) + ?string $sourceClass + ): void { $parser = new SentryIdentificatorParser(); $result = $parser->parse($sentryIdentificator); @@ -81,7 +81,7 @@ public function testMatch( * * @param string $pattern */ - public function testDoesNotMatch(string $pattern) + public function testDoesNotMatch(string $pattern): void { $parser = new SentryIdentificatorParser(); $sentryIdentificator = new SentryIdentificator($pattern); diff --git a/tests/Type/AbstractSentryTest.php b/tests/Type/AbstractSentryTest.php index 82db51c..78efb62 100644 --- a/tests/Type/AbstractSentryTest.php +++ b/tests/Type/AbstractSentryTest.php @@ -14,7 +14,7 @@ class AbstractSentryTest extends \PHPUnit\Framework\TestCase { - public function testSupportedAccess() + public function testSupportedAccess(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); @@ -24,7 +24,7 @@ public function testSupportedAccess() ], $sentry->getSupportedAccess()); } - public function testDefaultMethodNames() + public function testDefaultMethodNames(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); @@ -32,7 +32,7 @@ public function testDefaultMethodNames() $this->assertSame('setFoo', $sentry->getDefaultMethodName(new SentryAccess('set'), 'foo')); } - public function testDefaultMethodNameUnsupportedSentryAccess() + public function testDefaultMethodNameUnsupportedSentryAccess(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class, [], 'MockAbstractSentryTest'); @@ -46,7 +46,7 @@ public function testDefaultMethodNameUnsupportedSentryAccess() } } - public function testTargetAssociationAccessForAccess() + public function testTargetAssociationAccessForAccess(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); @@ -56,7 +56,7 @@ public function testTargetAssociationAccessForAccess() )); } - public function testGenerateGet() + public function testGenerateGet(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); $getMethod = new SentryMethod( @@ -90,7 +90,7 @@ public function getFoo() } - public function testGenerateObjectGet() + public function testGenerateObjectGet(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); $getMethod = new SentryMethod( @@ -123,7 +123,7 @@ public function getFoo() $this->assertSame($method, $sentry->generateMethod($propertyMetadata, $getMethod)); } - public function testGenerateSet() + public function testGenerateSet(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); $setMethod = new SentryMethod( @@ -156,7 +156,7 @@ public function setFoo($newValue) $this->assertSame($method, $sentry->generateMethod($propertyMetadata, $setMethod)); } - public function testGenerateObjectSet() + public function testGenerateObjectSet(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); $setMethod = new SentryMethod( @@ -189,7 +189,7 @@ public function setFoo($newValue) $this->assertSame($method, $sentry->generateMethod($propertyMetadata, $setMethod)); } - public function testGenerateUnsupportedSentryAccess() + public function testGenerateUnsupportedSentryAccess(): void { $sentry = $this->getMockForAbstractClass(AbstractSentry::class); $xxxSentryAccess = new SentryAccess('xxx'); diff --git a/tests/Type/CollectionTest.php b/tests/Type/CollectionTest.php index 6ceb3fd..d88886f 100644 --- a/tests/Type/CollectionTest.php +++ b/tests/Type/CollectionTest.php @@ -13,7 +13,7 @@ class CollectionTest extends \PHPUnit\Framework\TestCase { - public function testSupportedAccess() + public function testSupportedAccess(): void { $collection = new CollectionType(); @@ -26,7 +26,7 @@ public function testSupportedAccess() ], $collection->getSupportedAccess()); } - public function testDefaultMethodNames() + public function testDefaultMethodNames(): void { $collection = new CollectionType(); @@ -37,7 +37,7 @@ public function testDefaultMethodNames() $this->assertSame('containsChild', $collection->getDefaultMethodName(new SentryAccess('contains'), 'children')); } - public function testGenerateGet() + public function testGenerateGet(): void { $collection = new CollectionType(); $getMethod = new SentryMethod( @@ -70,7 +70,7 @@ public function getFoo() $this->assertSame($method, $collection->generateMethod($propertyMetadata, $getMethod)); } - public function testGenerateSet() + public function testGenerateSet(): void { $collection = new CollectionType(); $setMethod = new SentryMethod( @@ -111,7 +111,7 @@ public function setFoo($newValues) $this->assertSame($method, $collection->generateMethod($propertyMetadata, $setMethod)); } - public function testGenerateContains() + public function testGenerateContains(): void { $collection = new CollectionType(); $containsMethod = new SentryMethod( @@ -146,7 +146,7 @@ public function containsFoo($value) $this->assertSame($method, $collection->generateMethod($propertyMetadata, $containsMethod)); } - public function testGenerateAdd() + public function testGenerateAdd(): void { $collection = new CollectionType(); $addMethod = new SentryMethod( @@ -188,7 +188,7 @@ public function addFoo($newValue) $this->assertSame($method, $collection->generateMethod($propertyMetadata, $addMethod)); } - public function testGenerateRemove() + public function testGenerateRemove(): void { $collection = new CollectionType(); $removeMethod = new SentryMethod( diff --git a/tests/Type/SimpleTypeTest.php b/tests/Type/SimpleTypeTest.php index 2db9746..e7185e6 100644 --- a/tests/Type/SimpleTypeTest.php +++ b/tests/Type/SimpleTypeTest.php @@ -13,7 +13,7 @@ class SimpleTypeTest extends \PHPUnit\Framework\TestCase { - public function testGenerateGet() + public function testGenerateGet(): void { $integerSentry = new SimpleType(); $getMethod = new SentryMethod( @@ -46,7 +46,7 @@ public function getFoo() $this->assertSame($method, $integerSentry->generateMethod($propertyMetadata, $getMethod)); } - public function testGenerateNullableGet() + public function testGenerateNullableGet(): void { $integerSentry = new SimpleType(); $getMethod = new SentryMethod( @@ -79,7 +79,7 @@ public function getFoo() $this->assertSame($method, $integerSentry->generateMethod($propertyMetadata, $getMethod)); } - public function testGenerateSet() + public function testGenerateSet(): void { $integerSentry = new SimpleType(); $setMethod = new SentryMethod( @@ -113,7 +113,7 @@ public function setFoo($newValue) $this->assertSame($method, $integerSentry->generateMethod($propertyMetadata, $setMethod)); } - public function testGenerateSetNullable() + public function testGenerateSetNullable(): void { $integerSentry = new SimpleType(); $setMethod = new SentryMethod( diff --git a/tests/Type/TypeHelperTest.php b/tests/Type/TypeHelperTest.php index 457b50e..348d65b 100644 --- a/tests/Type/TypeHelperTest.php +++ b/tests/Type/TypeHelperTest.php @@ -10,7 +10,7 @@ class TypeHelperTest extends \PHPUnit\Framework\TestCase { - public function testStaticConstruct() + public function testStaticConstruct(): void { $this->expectException(\Consistence\StaticClassException::class);