Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for PHP 7.0 and adopt PHP 7.1 #4

Merged
merged 1 commit into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 7.0
- 7.1
- 7.2
- nightly
Expand Down
5 changes: 1 addition & 4 deletions build/cs-ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0"?>
<ruleset name="ConsistenceCodingStandard">
<rule ref="../vendor/consistence/coding-standard/Consistence/ruleset.xml">
<exclude name="SlevomatCodingStandard.Classes.ClassConstantVisibility"/><!-- requires 7.1+ -->
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/><!-- requires PHP 7.1+ -->
</rule>
<rule ref="../vendor/consistence/coding-standard/Consistence/ruleset.xml"/>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array" value="
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"doctrine/inflector": "~1.0"
},
"require-dev": {
"php": "~7.1",
"consistence/coding-standard": "2.4",
"jakub-onderka/php-console-highlighter": "0.3.2",
"jakub-onderka/php-parallel-lint": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NoSentryForIdentificatorException 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 = 'No Sentry can be created for identificator: ' . $sentryIdentificator->getId();
parent::__construct($message, $previous);
Expand Down
10 changes: 5 additions & 5 deletions src/Generated/SentryAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -78,7 +78,7 @@ public function isClassMapReady(): bool
return is_file($this->classMapTargetFile);
}

private function saveClassMap()
private function saveClassMap(): void
{
$fileContent = sprintf('<?php return %s;', var_export($this->classMap, true));
file_put_contents($this->classMapTargetFile, $fileContent);
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/BidirectionalAssociationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class BidirectionalAssociationType extends \Consistence\Enum\Enum
{

const ONE = 'one';
const MANY = 'many';
public const ONE = 'one';
public const MANY = 'many';

}
9 changes: 3 additions & 6 deletions src/Metadata/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
SentryIdentificator $sentryIdentificator,
bool $nullable,
array $sentryMethods,
BidirectionalAssociation $bidirectionalAssociation = null
?BidirectionalAssociation $bidirectionalAssociation = null
)
{
$this->name = $name;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/Visibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/exceptions/MethodNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
string $methodName,
string $className,
string $propertyName,
\Throwable $previous = null
?\Throwable $previous = null
)
{
parent::__construct(sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/exceptions/NoSuitableMethodException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 3 additions & 11 deletions src/Metadata/exceptions/PropertyNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -31,10 +26,7 @@ public function getClassName(): string
return $this->className;
}

/**
* @return string|null
*/
public function getPropertyName()
public function getPropertyName(): ?string
{
return $this->propertyName;
}
Expand Down
12 changes: 6 additions & 6 deletions src/MetadataSource/Annotation/AnnotationMetadataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class NoSentryIdentificatorException extends \Consistence\PhpException
{

public function __construct(\Throwable $previous = null)
public function __construct(?\Throwable $previous = null)
{
parent::__construct('', $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class PropertyMetadataCouldNotBeCreatedException extends \Consistence\PhpException
{

public function __construct(\Throwable $previous = null)
public function __construct(?\Throwable $previous = null)
{
parent::__construct('', $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 2 additions & 12 deletions src/SentryIdentificatorParser/SentryIdentificatorParseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,10 +53,7 @@ public function isNullable(): bool
return $this->nullable;
}

/**
* @return string|null
*/
public function getSourceClass()
public function getSourceClass(): ?string
{
return $this->sourceClass;
}
Expand Down
10 changes: 5 additions & 5 deletions src/SentryIdentificatorParser/SentryIdentificatorParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/Type/AbstractSentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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(
Expand Down Expand Up @@ -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 [];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Type/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Sentry
*
* @return \Consistence\Sentry\Metadata\SentryAccess[]
*/
public function getSupportedAccess();
public function getSupportedAccess(): iterable;

/**
* Generate code for a SentryMethod
Expand All @@ -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;

}
2 changes: 1 addition & 1 deletion src/Type/exceptions/SentryAccessNotSupportedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading