Skip to content

Commit

Permalink
require php 7.1 and phpunit 6
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Nov 1, 2017
1 parent ad63dba commit 43a00a4
Show file tree
Hide file tree
Showing 54 changed files with 316 additions and 323 deletions.
69 changes: 19 additions & 50 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,25 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
$finder = PhpCsFixer\Finder::create()
->in([__DIR__.'/lib', __DIR__.'/tests'])
->exclude(['bin'])
;

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->finder($finder)
->fixers([
'-psr0',
'array_element_no_space_before_comma',
'array_element_white_space_after_comma',
'blankline_after_open_tag',
'concat_without_spaces',
'double_arrow_multiline_whitespaces',
'duplicate_semicolon',
'extra_empty_lines',
'function_typehint_space',
'include',
'join_function',
'list_commas',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'new_with_braces',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'object_operator',
'operators_spaces',
'phpdoc_inline_tag',
'phpdoc_no_access',
'phpdoc_no_package',
'phpdoc_scalar',
'phpdoc_type_to_var',
'phpdoc_types',
'pre_increment',
'print_to_echo',
'return',
'self_accessor',
'short_bool_cast',
'single_array_no_trailing_comma',
'single_blank_line_before_namespace',
'single_quote',
'spaces_before_semicolon',
'standardize_not_equal',
'ternary_spaces',
'trim_array_spaces',
'unalign_double_arrow',
'unalign_equals',
'unneeded_control_parentheses',
'unused_use',
'whitespacy_lines',
'ordered_use',
'short_array_syntax'
return PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'psr0' => false,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'none'],
'blank_line_after_opening_tag' => false,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => true,
])
;
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ cache:
- $HOME/.composer/cache

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

matrix:
allow_failures:
- php: hhvm

before_script:
- composer self-update
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"license": "MIT",
"type": "library",
"require": {
"php": ">= 5.4.0"
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0",
"phpunit/phpunit": "^6.0",
"doctrine/cache": "~1.4",
"doctrine/annotations": "~1.2",
"symfony/event-dispatcher": "~2.0|~3.0",
Expand All @@ -35,7 +35,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
"dev-master": "2.x-dev"
}
},
"authors": [
Expand Down
16 changes: 8 additions & 8 deletions lib/ClassMetadata.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata;

Expand Down Expand Up @@ -33,7 +33,7 @@ public function __construct(\ReflectionClass $class)
/**
* {@inheritdoc}
*/
public function getReflectionClass()
public function getReflectionClass(): \ReflectionClass
{
if (null === $this->reflectionClass) {
$this->reflectionClass = new \ReflectionClass($this->name);
Expand All @@ -45,7 +45,7 @@ public function getReflectionClass()
/**
* {@inheritdoc}
*/
public function merge(MetadataInterface $metadata)
public function merge(MetadataInterface $metadata): void
{
if ($metadata instanceof NullMetadata) {
return;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function merge(MetadataInterface $metadata)
/**
* {@inheritdoc}
*/
public function getAttributeMetadata($name)
public function getAttributeMetadata($name): MetadataInterface
{
if (! isset($this->attributesMetadata[$name])) {
return new NullMetadata($name);
Expand All @@ -90,23 +90,23 @@ public function getAttributeMetadata($name)
/**
* {@inheritdoc}
*/
public function getAttributesMetadata()
public function getAttributesMetadata(): array
{
return $this->attributesMetadata;
}

/**
* {@inheritdoc}
*/
public function addAttributeMetadata(MetadataInterface $metadata)
public function addAttributeMetadata(MetadataInterface $metadata): void
{
$this->attributesMetadata[ $metadata->getName() ] = $metadata;
$this->attributesMetadata[$metadata->getName()] = $metadata;
}

/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->getReflectionClass()->name;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/ClassMetadataInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata;

Expand All @@ -7,28 +7,28 @@ interface ClassMetadataInterface extends MetadataInterface
/**
* @return \ReflectionClass
*/
public function getReflectionClass();
public function getReflectionClass(): \ReflectionClass;

/**
* Returns a metadata instance for a given attribute
* Returns a metadata instance for a given attribute.
*
* @param $name
*
* @return MetadataInterface
*/
public function getAttributeMetadata($name);
public function getAttributeMetadata($name): MetadataInterface;

/**
* Returns all attributes' metadata
* Returns all attributes' metadata.
*
* @return MetadataInterface[]
*/
public function getAttributesMetadata();
public function getAttributesMetadata(): array;

/**
* Adds an attribute metadata
* Adds an attribute metadata.
*
* @param MetadataInterface $metadata
*/
public function addAttributeMetadata(MetadataInterface $metadata);
public function addAttributeMetadata(MetadataInterface $metadata): void;
}
4 changes: 2 additions & 2 deletions lib/Event/ClassMetadataLoadedEvent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Event;

Expand All @@ -22,7 +22,7 @@ public function __construct(ClassMetadataInterface $metadata)
/**
* @return ClassMetadataInterface
*/
public function getMetadata()
public function getMetadata(): ClassMetadataInterface
{
return $this->metadata;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/IOException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Exception;

Expand Down
8 changes: 4 additions & 4 deletions lib/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Exception;

Expand All @@ -11,13 +11,13 @@ class InvalidArgumentException extends \InvalidArgumentException
const INVALID_PROCESSOR_INTERFACE_CLASS = 5;

/**
* Create a new instance of InvalidArgumentException with meaningful message
* Create a new instance of InvalidArgumentException with meaningful message.
*
* @param $reason
*
* @return static
* @return self
*/
public static function create($reason)
public static function create($reason): self
{
$arguments = func_get_args();

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/InvalidMetadataException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Exception;

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Exception;

Expand Down
20 changes: 10 additions & 10 deletions lib/Factory/AbstractMetadataFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Factory;

Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct(LoaderInterface $loader, EventDispatcherInterface $e
/**
* {@inheritdoc}
*/
public function getMetadataFor($value)
public function getMetadataFor($value): ClassMetadataInterface
{
$class = $this->getClass($value);
if (empty($class)) {
Expand Down Expand Up @@ -89,24 +89,24 @@ public function getMetadataFor($value)
/**
* {@inheritdoc}
*/
public function hasMetadataFor($value)
public function hasMetadataFor($value): bool
{
$class = $this->getClass($value);

return ! empty($class) && (class_exists($class) || interface_exists($class));
}

public function setCache(Cache $cache = null)
public function setCache(?Cache $cache): void
{
$this->cache = $cache;
}

public function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null)
public function setEventDispatcher(?EventDispatcherInterface $eventDispatcher): void
{
$this->eventDispatcher = $eventDispatcher;
}

protected function mergeSuperclasses(ClassMetadataInterface $classMetadata)
protected function mergeSuperclasses(ClassMetadataInterface $classMetadata): void
{
$reflectionClass = $classMetadata->getReflectionClass();

Expand All @@ -120,13 +120,13 @@ protected function mergeSuperclasses(ClassMetadataInterface $classMetadata)
}

/**
* Create a new instance of metadata object for this factory
* Create a new instance of metadata object for this factory.
*
* @param \ReflectionClass $class
*
* @return ClassMetadataInterface
*/
abstract protected function createMetadata(\ReflectionClass $class);
abstract protected function createMetadata(\ReflectionClass $class): ClassMetadataInterface;

/**
* Validate loaded metadata
Expand All @@ -136,12 +136,12 @@ abstract protected function createMetadata(\ReflectionClass $class);
*
* @throws InvalidMetadataException
*/
protected function validate(ClassMetadataInterface $classMetadata)
protected function validate(ClassMetadataInterface $classMetadata): void
{
}

/**
* Get the class name from a string or an object
* Get the class name from a string or an object.
*
* @param string|object $value
*
Expand Down
16 changes: 9 additions & 7 deletions lib/Factory/MetadataFactory.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<?php
<?php declare(strict_types=1);

namespace Kcs\Metadata\Factory;

use Kcs\Metadata\ClassMetadata;
use Kcs\Metadata\ClassMetadataInterface;
use Kcs\Metadata\Exception\InvalidArgumentException;

class MetadataFactory extends AbstractMetadataFactory
{
/**
* Metadata object to be created
* Metadata object to be created.
*
* @var string
*/
private $metadataClass = 'Kcs\Metadata\ClassMetadata';
private $metadataClass = ClassMetadata::class;

/**
* Set the metadata class to be created by this factory
* Set the metadata class to be created by this factory.
*
* @param string $metadataClass
*/
public function setMetadataClass($metadataClass)
public function setMetadataClass($metadataClass): void
{
if (! class_exists($metadataClass) || ! is_subclass_of($metadataClass, 'Kcs\Metadata\ClassMetadataInterface', true)) {
if (! class_exists($metadataClass) || ! is_subclass_of($metadataClass, ClassMetadataInterface::class, true)) {
throw InvalidArgumentException::create(InvalidArgumentException::INVALID_METADATA_CLASS, $metadataClass);
}

Expand All @@ -30,7 +32,7 @@ public function setMetadataClass($metadataClass)
/**
* {@inheritdoc}
*/
protected function createMetadata(\ReflectionClass $class)
protected function createMetadata(\ReflectionClass $class): ClassMetadataInterface
{
return new $this->metadataClass($class);
}
Expand Down
Loading

0 comments on commit 43a00a4

Please sign in to comment.