diff --git a/.gitignore b/.gitignore index 4bb69f7..a7b0f43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.tar.gz !.gitkeep .idea +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..32e24f4 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,51 @@ + + * + * 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 = << + +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) +; diff --git a/Bundle/CustomerGroupRankBundle.php b/Bundle/CustomerGroupRankBundle.php index 12598a2..2f4b92f 100644 --- a/Bundle/CustomerGroupRankBundle.php +++ b/Bundle/CustomerGroupRankBundle.php @@ -1,7 +1,7 @@ * @@ -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); diff --git a/DependencyInjection/Compiler/RankPass.php b/DependencyInjection/Compiler/RankPass.php index 4687900..679350f 100644 --- a/DependencyInjection/Compiler/RankPass.php +++ b/DependencyInjection/Compiler/RankPass.php @@ -1,11 +1,11 @@ * - * 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. @@ -17,7 +17,6 @@ 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 { @@ -25,7 +24,12 @@ class RankPass implements CompilerPassInterface 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); diff --git a/Entity/GroupTrait.php b/Entity/GroupTrait.php index 1c83138..ace101e 100644 --- a/Entity/GroupTrait.php +++ b/Entity/GroupTrait.php @@ -1,7 +1,7 @@ * @@ -17,8 +17,6 @@ use Eccube\Annotation\EntityExtension; /** - * Trait GroupTrait - * * @EntityExtension("Plugin\CustomerGroup42\Entity\Group") */ trait GroupTrait diff --git a/Event.php b/Event.php index e4f6167..f17a5b4 100644 --- a/Event.php +++ b/Event.php @@ -1,7 +1,7 @@ * @@ -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'); diff --git a/Form/Extension/Admin/GroupTypeExtension.php b/Form/Extension/Admin/GroupTypeExtension.php index de5fc77..9b36462 100644 --- a/Form/Extension/Admin/GroupTypeExtension.php +++ b/Form/Extension/Admin/GroupTypeExtension.php @@ -1,7 +1,7 @@ * @@ -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, [ diff --git a/PluginManager.php b/PluginManager.php index 7958c30..e54741c 100644 --- a/PluginManager.php +++ b/PluginManager.php @@ -1,7 +1,7 @@ * @@ -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'); diff --git a/Repository/QueryCustomizer/GroupSearchCustomizer.php b/Repository/QueryCustomizer/GroupSearchCustomizer.php index 7b1e933..c9b06b5 100644 --- a/Repository/QueryCustomizer/GroupSearchCustomizer.php +++ b/Repository/QueryCustomizer/GroupSearchCustomizer.php @@ -1,7 +1,7 @@ * @@ -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']) @@ -34,7 +41,10 @@ public function customize(QueryBuilder $builder, $params, $queryKey) } } - public function getQueryKey() + /** + * @return string + */ + public function getQueryKey(): string { return QueryKey::GROUP_SEARCH; } diff --git a/Resource/config/bundles.php b/Resource/config/bundles.php index da278a1..7d2d474 100644 --- a/Resource/config/bundles.php +++ b/Resource/config/bundles.php @@ -1,16 +1,16 @@ * - * 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], ]; diff --git a/Security/EventListener/LoginListener.php b/Security/EventListener/LoginListener.php index 166c65d..af18dc1 100644 --- a/Security/EventListener/LoginListener.php +++ b/Security/EventListener/LoginListener.php @@ -1,7 +1,7 @@ * @@ -23,12 +23,12 @@ class LoginListener /** * @var Context */ - private $context; + private Context $context; /** * @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; public function __construct(Context $context, EntityManagerInterface $entityManager) { @@ -36,7 +36,12 @@ public function __construct(Context $context, EntityManagerInterface $entityMana $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) { diff --git a/Service/Rank/Context.php b/Service/Rank/Context.php index 4073f64..206d5a7 100644 --- a/Service/Rank/Context.php +++ b/Service/Rank/Context.php @@ -1,7 +1,7 @@ * @@ -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 */ diff --git a/Service/Rank/Rank.php b/Service/Rank/Rank.php index 7ca2610..b55aef4 100644 --- a/Service/Rank/Rank.php +++ b/Service/Rank/Rank.php @@ -1,7 +1,7 @@ * @@ -23,7 +23,7 @@ class Rank implements RankInterface /** * @var EntityManagerInterface */ - protected $entityManager; + protected EntityManagerInterface $entityManager; public function __construct(EntityManagerInterface $entityManager) { diff --git a/Service/Rank/RankInterface.php b/Service/Rank/RankInterface.php index 3927cf7..f0a65a4 100644 --- a/Service/Rank/RankInterface.php +++ b/Service/Rank/RankInterface.php @@ -1,7 +1,7 @@ * diff --git a/Tests/DependencyInjection/Compiler/RankPassTest.php b/Tests/DependencyInjection/Compiler/RankPassTest.php index 62840af..c401021 100644 --- a/Tests/DependencyInjection/Compiler/RankPassTest.php +++ b/Tests/DependencyInjection/Compiler/RankPassTest.php @@ -1,7 +1,7 @@ * @@ -22,7 +22,7 @@ class RankPassTest extends TestCase { - public function testTestRankが追加されるか() + public function testTestRankが追加されるか(): void { $container = new ContainerBuilder(); $container->register(Context::class) diff --git a/Tests/Repository/GroupRepositoryTest.php b/Tests/Repository/GroupRepositoryTest.php index 7d58333..1021ecf 100644 --- a/Tests/Repository/GroupRepositoryTest.php +++ b/Tests/Repository/GroupRepositoryTest.php @@ -1,7 +1,7 @@ * @@ -43,7 +43,10 @@ protected function setUp(): void $this->groupRepository = static::getContainer()->get(GroupRepository::class); } - public function scenario() + /** + * @return void + */ + public function scenario(): void { $this->Results = $this->groupRepository->getQueryBuilderBySearchData($this->searchData) ->getQuery() @@ -57,9 +60,11 @@ public function scenario() * @param $customer_total * @param $expected * + * @return void + * * @dataProvider conditionProvider */ - public function testランクアップ条件にマッチした会員グループが見つかるか($group_times, $group_total, $customer_times, $customer_total, $expected) + public function testランクアップ条件にマッチした会員グループが見つかるか($group_times, $group_total, $customer_times, $customer_total, $expected): void { $group = $this->createGroup(); $group->setBuyTimes($group_times); @@ -82,7 +87,10 @@ public function testランクアップ条件にマッチした会員グループ self::assertCount($expected, $this->Results); } - public function conditionProvider() + /** + * @return array[] + */ + public function conditionProvider(): array { return [ [1, 1, 0, 0, 0], diff --git a/Tests/Service/Rank/RankTest.php b/Tests/Service/Rank/RankTest.php index 6b66dd6..1f75e7d 100644 --- a/Tests/Service/Rank/RankTest.php +++ b/Tests/Service/Rank/RankTest.php @@ -1,7 +1,7 @@ * @@ -34,7 +34,7 @@ protected function setUp(): void $this->context = static::getContainer()->get(Context::class); } - public function testDecide() + public function testDecide(): void { $group1 = $this->createGroup(); $group1->setBuyTimes(1); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 77265a6..eaf5064 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -1,9 +1,21 @@ + * + * https://a-zumi.net + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $loader = require __DIR__.'/../../../../vendor/autoload.php'; $envFile = __DIR__.'/../../../../.env'; if (file_exists($envFile)) { - (new \Symfony\Component\Dotenv\Dotenv()) - ->usePutenv(true) + (new Symfony\Component\Dotenv\Dotenv()) + ->usePutenv() ->bootEnv($envFile); }