Skip to content

Commit

Permalink
Add suport symfony 4 drop php 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Bukashk0zzz committed Dec 8, 2017
1 parent a8e0344 commit a73b365
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 55 deletions.
46 changes: 46 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php declare(strict_types = 1);

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'@PHP71Migration' => true,
'phpdoc_summary' => false,
'yoda_style' => false,
'self_accessor' => false,
'combine_consecutive_unsets' => true,
'blank_line_after_opening_tag' => false,
'phpdoc_to_comment' => false,
'phpdoc_no_empty_return' => false,
'strict_param' => true,
'doctrine_annotation_indentation' => true,
'mb_str_functions' => true,
'native_function_invocation' => true,
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'simplified_null_return' => false,
'strict_comparison' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'declare_equal_normalize' => ['space' => 'single'],
'array_syntax' => ['syntax' => 'short'],
'list_syntax' => ['syntax' => 'short'],
'doctrine_annotation_braces' => ['syntax' => 'with_braces'],
'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'created', 'version', 'package', 'copyright', 'license', 'throws']],
])
->setFinder($finder)
;
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"7.2.0","version":"2.8.3:v2.8.3#d9ec9b848cbf930c31dea3693d34dbd8b9c95295","rules":{"encoding":true,"full_opening_tag":true,"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"singleLine":true},"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["const","method","property"]},"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"concat_space":{"spacing":"none"},"declare_equal_normalize":{"space":"single"},"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"magic_constant_casing":true,"method_separation":true,"native_function_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_consecutive_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_var_without_name":true,"protected_to_private":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"dir_constant":true,"ereg_to_preg":true,"function_to_constant":true,"is_null":true,"modernize_types_casting":true,"no_alias_functions":true,"no_homoglyph_names":true,"non_printable_character":{"use_escape_sequences_in_strings":true},"php_unit_construct":true,"php_unit_dedicate_assert":true,"psr4":true,"silenced_deprecation_error":true,"ternary_to_null_coalescing":true,"declare_strict_types":true,"random_api_migration":{"replacements":{"mt_rand":"random_int","rand":"random_int"}},"pow_to_exponentiation":true,"combine_consecutive_unsets":true,"strict_param":true,"doctrine_annotation_indentation":true,"mb_str_functions":true,"native_function_invocation":true,"no_short_echo_tag":true,"no_unreachable_default_argument_value":true,"no_useless_else":true,"no_useless_return":true,"ordered_class_elements":true,"phpdoc_add_missing_param_annotation":true,"phpdoc_order":true,"strict_comparison":true,"ordered_imports":{"sortAlgorithm":"alpha"},"array_syntax":{"syntax":"short"},"list_syntax":{"syntax":"short"},"doctrine_annotation_braces":{"syntax":"with_braces"},"general_phpdoc_annotation_remove":{"annotations":["author","created","version","package","copyright","license","throws"]}},"hashes":{"Form\/DataTransformer\/TimestampToDateTimeTransformer.php":2278613954,"Form\/Type\/TimestampType.php":2326751630,"Tests\/TimestampTypeTest.php":4166878559,"Tests\/DependencyInjection\/Bukashk0zzzTimestampTypeExtensionTest.php":3307403684,"Bukashk0zzzTimestampTypeBundle.php":551629921,"DependencyInjection\/Bukashk0zzzTimestampTypeExtension.php":1716105970}}
12 changes: 1 addition & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@ language: php
sudo: false

php:
- 5.6
- 7.0
- hhvm

env:
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.0.*

allow_failures:
- php: hhvm
- 7.1

before_script:
- composer self-update
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- composer install --dev --prefer-dist --no-interaction

script:
Expand Down
4 changes: 1 addition & 3 deletions Bukashk0zzzTimestampTypeBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);
/*
* This file is part of the Bukashk0zzzTimestampTypeBundle
*
Expand All @@ -14,8 +14,6 @@

/**
* Bukashk0zzzTimestampTypeBundle
*
* @author Denis Golubovskiy <bukashk0zzz@gmail.com>
*/
class Bukashk0zzzTimestampTypeBundle extends Bundle
{
Expand Down
6 changes: 1 addition & 5 deletions DependencyInjection/Bukashk0zzzTimestampTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

<?php declare(strict_types = 1);
/*
* This file is part of the Bukashk0zzzTimestampTypeBundle
*
Expand All @@ -18,14 +17,11 @@

/**
* This is the class that loads and manages Bukashk0zzzTimestampTypeBundle configuration
*
* @author Denis Golubovskiy <bukashk0zzz@gmail.com>
*/
class Bukashk0zzzTimestampTypeExtension extends Extension
{
/**
* {@inheritdoc}
* @throws \Exception
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand Down
8 changes: 4 additions & 4 deletions Form/DataTransformer/TimestampToDateTimeTransformer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

<?php declare(strict_types = 1);
/*
* This file is part of the Bukashk0zzzTimestampTypeBundle
*
Expand All @@ -15,12 +14,12 @@

/**
* Class TimestampToDateTimeTransformer
* @author Denis Golubovskiy <bukashk0zzz@gmail.com>
*/
class TimestampToDateTimeTransformer implements DataTransformerInterface
{
/**
* @param mixed $value
*
* @return int|mixed
*/
public function transform($value)
Expand All @@ -34,9 +33,10 @@ public function transform($value)

/**
* @param mixed $value
*
* @return \DateTime|null
*/
public function reverseTransform($value)
public function reverseTransform($value): ?\DateTime
{
if ($value) {
$date = new \DateTime();
Expand Down
8 changes: 3 additions & 5 deletions Form/Type/TimestampType.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

<?php declare(strict_types = 1);
/*
* This file is part of the Bukashk0zzzTimestampTypeBundle
*
Expand All @@ -18,15 +17,14 @@

/**
* Class TimestampType
* @author Denis Golubovskiy <bukashk0zzz@gmail.com>
*/
class TimestampType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
* @param mixed[] $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addModelTransformer(new TimestampToDateTimeTransformer());
}
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ parameters:
timestamp.type.class: Bukashk0zzz\TimestampTypeBundle\Form\Type\TimestampType

services:
_defaults:
public: true

timestamp.type:
class: '%timestamp.type.class%'
arguments: []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

<?php declare(strict_types = 1);
/*
* This file is part of the Bukashk0zzzTimestampTypeBundle
*
Expand All @@ -12,22 +11,21 @@
namespace Bukashk0zzz\TimestampTypeBundle\Tests\DependencyInjection;

use Bukashk0zzz\TimestampTypeBundle\DependencyInjection\Bukashk0zzzTimestampTypeExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Bukashk0zzzTimestampTypeExtensionTest
*
* @author Denis Golubovskiy <bukashk0zzz@gmail.com>
*/
class Bukashk0zzzTimestampTypeExtensionTest extends \PHPUnit_Framework_TestCase
class Bukashk0zzzTimestampTypeExtensionTest extends TestCase
{
/**
* @var Bukashk0zzzTimestampTypeExtension $extension Bukashk0zzzTimestampTypeExtension
* @var Bukashk0zzzTimestampTypeExtension Bukashk0zzzTimestampTypeExtension
*/
private $extension;

/**
* @var ContainerBuilder $container Container builder
* @var ContainerBuilder Container builder
*/
private $container;

Expand All @@ -43,10 +41,8 @@ protected function setUp()

/**
* Test load extension
* @throws \LogicException
* @throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
*/
public function testLoadExtension()
public function testLoadExtension(): void
{
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
Expand Down
21 changes: 9 additions & 12 deletions Tests/TimestampTypeTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

<?php declare(strict_types = 1);
/*
* This file is part of the Bukashk0zzzTimestampTypeBundle
*
Expand All @@ -15,12 +14,8 @@
use Symfony\Component\Form\Form;
use Symfony\Component\Form\Test\TypeTestCase;

/** @noinspection LongInheritanceChainInspection
*
/**
* Test the TimestampTypeTest
*
* @author Denis Golubovskiy <bukashk0zzz@gmail.com>
*
*/
class TimestampTypeTest extends TypeTestCase
{
Expand All @@ -31,11 +26,8 @@ class TimestampTypeTest extends TypeTestCase

/**
* Test type
*
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
* @throws \Symfony\Component\Form\Exception\AlreadySubmittedException
*/
public function testType()
public function testType(): void
{
/** @var Form $form */
$form = $this->factory->create(TimestampType::class, new \DateTime(), ['data_class' => null]);
Expand All @@ -51,7 +43,12 @@ public function testType()
static::assertSame('', $form->getViewData());
}

private function assertForm(Form $form)
/**
* @param Form $form
*
* @return void
*/
private function assertForm(Form $form): void
{
static::assertTrue($form->isSynchronized());
static::assertSame((string) $this->time, $form->getViewData());
Expand Down
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
"issues": "https://github.com/bukashk0zzz/TimestampTypeBundle/issues"
},
"require": {
"php": ">=5.6.0",
"symfony/symfony": "^3.3|^4.0"
"php": ">=7.1.0",
"symfony/dependency-injection": "^3.3|^4.0",
"symfony/config": "^3.3|^4.0",
"symfony/yaml": "^3.3|^4.0",
"symfony/http-kernel": "^3.3|^4.0",
"symfony/form": "^3.3|^4.0"
},
"require-dev": {
"phpunit/phpunit": "~5.0",
"squizlabs/php_codesniffer": "^2.5",
"escapestudios/symfony2-coding-standard": "~2.9"
"escapestudios/symfony2-coding-standard": "^3.0",
"slevomat/coding-standard": "^4.0",
"friendsofphp/php-cs-fixer": "^2.8",
"phpunit/phpunit": "^6.4"
},
"autoload": {
"psr-4": {
Expand Down
70 changes: 70 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0"?>
<ruleset name="Bukashk0zzz">
<description>Bukashk0zzz coding standard.</description>

<rule ref="./vendor/escapestudios/symfony2-coding-standard/Symfony"/>
<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml" />

<rule ref="./vendor/escapestudios/symfony2-coding-standard/Symfony">
<exclude name="Symfony.Functions.Arguments.Invalid"/>
<exclude name="Symfony.Commenting.License.Warning"/>
<exclude name="Symfony.Commenting.Annotations.Invalid"/>
<exclude name="Symfony.ControlStructure.YodaConditions.Invalid"/>
<exclude name="Symfony.ControlStructure.UnaryOperators.Invalid"/>
<exclude name="Symfony.Functions.ReturnType.Invalid"/>
</rule>

<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml">
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.UselessDocComment"/>
<exclude name="SlevomatCodingStandard.ControlStructures.RequireYodaComparison.RequiredYodaComparison"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/>
</rule>

<rule ref="SlevomatCodingStandard.Types.EmptyLinesAroundTypeBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFullyQualifiedExceptions" value="true"/>
<property name="allowPartialUses" value="true"/>
<property name="allowFullyQualifiedGlobalClasses" value="true"/>
<property name="allowFullyQualifiedGlobalFunctions" value="true"/>
<property name="allowFullyQualifiedGlobalConstants" value="true"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array" value="@author, @created, @version, @package, @copyright, @license, @throws"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>

<rule ref="Squiz.Commenting.FunctionComment.MissingParamComment">
<severity>0</severity>
</rule>

<rule ref="Squiz.Commenting.FunctionComment.InvalidReturn">
<severity>0</severity>
</rule>

<arg name="colors"/>
<arg name="encoding" value="utf-8"/>
<arg name="extensions" value="php"/>

<exclude-pattern>vendor/</exclude-pattern>

<file>./</file>
</ruleset>

0 comments on commit a73b365

Please sign in to comment.