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

PHP-CS-Fixer設定ファイル追加。プロパティ、メソッドに型指定 #12

Merged
merged 1 commit into from
Apr 23, 2024
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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.tar.gz
!.gitkeep
.idea
.php-cs-fixer.cache
51 changes: 51 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (php_sapi_name() !== 'cli') {
throw new LogicException();
}

$header = <<<EOL
This file is part of CustomerGroupRank

Copyright(c) Akira Kurozumi <info@a-zumi.net>

https://a-zumi.net

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOL;

$rules = [
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'phpdoc_align' => false,
'phpdoc_summary' => false,
'phpdoc_scalar' => false,
'phpdoc_annotation_without_dot' => false,
'no_superfluous_phpdoc_tags' => false,
'increment_style' => false,
'yoda_style' => false,
'header_comment' => ['header' => $header],
];

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->name('*.php')
;
$config = new PhpCsFixer\Config();

return $config
->setRules($rules)
->setFinder($finder)
;
9 changes: 7 additions & 2 deletions Bundle/CustomerGroupRankBundle.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -20,7 +20,12 @@

class CustomerGroupRankBundle extends Bundle
{
public function build(ContainerBuilder $container)
/**
* @param ContainerBuilder $container
*
* @return void
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);

Expand Down
14 changes: 9 additions & 5 deletions DependencyInjection/Compiler/RankPass.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

/*
* This file is part of EC-CUBE
* This file is part of CustomerGroupRank
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* http://www.ec-cube.co.jp/
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -17,15 +17,19 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class RankPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;

public const TAG = 'plugin.customer.group.rank';

public function process(ContainerBuilder $container)
/**
* @param ContainerBuilder $container
*
* @return void
*/
public function process(ContainerBuilder $container): void
{
$context = $container->findDefinition(Context::class);

Expand Down
4 changes: 1 addition & 3 deletions Entity/GroupTrait.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -17,8 +17,6 @@
use Eccube\Annotation\EntityExtension;

/**
* Trait GroupTrait
*
* @EntityExtension("Plugin\CustomerGroup42\Entity\Group")
*/
trait GroupTrait
Expand Down
12 changes: 10 additions & 2 deletions Event.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -18,13 +18,21 @@

class Event implements EventSubscriberInterface
{
public static function getSubscribedEvents()
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
'@CustomerGroup42/admin/Customer/Group/edit.twig' => 'onTemplateAdminCustomerGroupEdit',
];
}

/**
* @param TemplateEvent $event
*
* @return void
*/
public function onTemplateAdminCustomerGroupEdit(TemplateEvent $event): void
{
$event->addSnippet('@CustomerGroupRank42/admin/Customer/Group/edit.twig');
Expand Down
10 changes: 8 additions & 2 deletions Form/Extension/Admin/GroupTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -23,7 +23,13 @@

class GroupTypeExtension extends AbstractTypeExtension
{
public function buildForm(FormBuilderInterface $builder, array $options)
/**
* @param FormBuilderInterface $builder
* @param array $options
*
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('buyTimes', NumberType::class, [
Expand Down
13 changes: 11 additions & 2 deletions PluginManager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -21,7 +21,16 @@

class PluginManager extends AbstractPluginManager
{
public function enable(array $meta, ContainerInterface $container)
/**
* @param array $meta
* @param ContainerInterface $container
*
* @return void
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function enable(array $meta, ContainerInterface $container): void
{
/** @var EntityManagerInterface $entityManager */
$entityManager = $container->get('doctrine.orm.entity_manager');
Expand Down
16 changes: 13 additions & 3 deletions Repository/QueryCustomizer/GroupSearchCustomizer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -20,7 +20,14 @@

class GroupSearchCustomizer implements QueryCustomizer
{
public function customize(QueryBuilder $builder, $params, $queryKey)
/**
* @param QueryBuilder $builder
* @param $params
* @param $queryKey
*
* @return void
*/
public function customize(QueryBuilder $builder, $params, $queryKey): void
{
if (
isset($params['buyTimes']) && isset($params['buyTotal'])
Expand All @@ -34,7 +41,10 @@ public function customize(QueryBuilder $builder, $params, $queryKey)
}
}

public function getQueryKey()
/**
* @return string
*/
public function getQueryKey(): string
{
return QueryKey::GROUP_SEARCH;
}
Expand Down
8 changes: 4 additions & 4 deletions Resource/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

/*
* This file is part of EC-CUBE
* This file is part of CustomerGroupRank
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* http://www.ec-cube.co.jp/
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return [
\Plugin\CustomerGroupRank42\Bundle\CustomerGroupRankBundle::class => ['all' => true],
Plugin\CustomerGroupRank42\Bundle\CustomerGroupRankBundle::class => ['all' => true],
];
13 changes: 9 additions & 4 deletions Security/EventListener/LoginListener.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -23,20 +23,25 @@ class LoginListener
/**
* @var Context
*/
private $context;
private Context $context;

/**
* @var EntityManagerInterface
*/
private $entityManager;
private EntityManagerInterface $entityManager;

public function __construct(Context $context, EntityManagerInterface $entityManager)
{
$this->context = $context;
$this->entityManager = $entityManager;
}

public function onInteractiveLogin(InteractiveLoginEvent $event)
/**
* @param InteractiveLoginEvent $event
*
* @return void
*/
public function onInteractiveLogin(InteractiveLoginEvent $event): void
{
$user = $event->getAuthenticationToken()->getUser();
if (!$user instanceof Customer) {
Expand Down
19 changes: 16 additions & 3 deletions Service/Rank/Context.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -17,13 +17,26 @@

class Context
{
private $ranks = [];
/**
* @var array
*/
private array $ranks = [];

public function addRank(RankInterface $rank)
/**
* @param RankInterface $rank
*
* @return void
*/
public function addRank(RankInterface $rank): void
{
$this->ranks[] = $rank;
}

/**
* @param Customer $customer
*
* @return void
*/
public function decide(Customer $customer): void
{
/** @var Rank $rank */
Expand Down
4 changes: 2 additions & 2 deletions Service/Rank/Rank.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -23,7 +23,7 @@ class Rank implements RankInterface
/**
* @var EntityManagerInterface
*/
protected $entityManager;
protected EntityManagerInterface $entityManager;

public function __construct(EntityManagerInterface $entityManager)
{
Expand Down
2 changes: 1 addition & 1 deletion Service/Rank/RankInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand Down
4 changes: 2 additions & 2 deletions Tests/DependencyInjection/Compiler/RankPassTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of CustomerGroupRank42
* This file is part of CustomerGroupRank
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
Expand All @@ -22,7 +22,7 @@

class RankPassTest extends TestCase
{
public function testTestRankが追加されるか()
public function testTestRankが追加されるか(): void
{
$container = new ContainerBuilder();
$container->register(Context::class)
Expand Down
Loading
Loading