Skip to content

Commit 98dcac7

Browse files
committed
minor #170 Update coding standard rules (phansys)
This PR was merged into the 3.x branch. Discussion ---------- |Q |A | |--- |---| |Branch |3.x| |Bug fix? |no | |New feature? |no | |BC breaks? |no | |Deprecations?|no | |Tests pass? |yes| |Fixed tickets|n/a| |License |MIT| |Doc PR |n/a| Commits ------- ba78ffe Update coding standard rules
2 parents 4936d99 + ba78ffe commit 98dcac7

File tree

61 files changed

+692
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+692
-175
lines changed

.php_cs.dist

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
<?php
22

3+
$header = <<<'HEADER'
4+
This file is part of HackzillaTicketBundle package.
5+
6+
(c) Daniel Platt <[email protected]>
7+
8+
For the full copyright and license information, please view the LICENSE
9+
file that was distributed with this source code.
10+
HEADER;
11+
312
// Use PHP-CS-Fixer 2+ if it is available
413
if (\class_exists(PhpCsFixer\Config::class, false)) {
514
return PhpCsFixer\Config::create()
615
->setUsingCache(true)
716
->setRiskyAllowed(true)
817
->setRules([
918
'@Symfony' => true,
19+
'@Symfony:risky' => true,
1020
'array_syntax' => ['syntax' => 'short'],
11-
'binary_operator_spaces' => [
12-
'align_double_arrow' => true,
13-
'align_equals' => true,
14-
],
1521
'blank_line_after_opening_tag' => true,
1622
'combine_consecutive_issets' => true,
1723
'combine_consecutive_unsets' => true,
24+
'explicit_string_variable' => true,
25+
'global_namespace_import' => ['import_classes' => false],
26+
'header_comment' => [
27+
'header' => $header,
28+
],
1829
'logical_operators' => true,
1930
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
31+
'multiline_whitespace_before_semicolons' => true,
32+
'no_alternative_syntax' => true,
2033
'no_extra_blank_lines' => true,
34+
'no_null_property_initialization' => true,
2135
'no_php4_constructor' => true,
36+
'no_short_echo_tag' => true,
37+
'no_superfluous_elseif' => true,
2238
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
39+
'no_unset_on_property' => true,
2340
'no_useless_else' => true,
2441
'no_useless_return' => true,
2542
'ordered_class_elements' => true,
@@ -28,6 +45,8 @@ if (\class_exists(PhpCsFixer\Config::class, false)) {
2845
'php_unit_set_up_tear_down_visibility' => true,
2946
'php_unit_strict' => true,
3047
'phpdoc_order' => true,
48+
'single_line_throw' => false,
49+
'static_lambda' => true,
3150
])
3251
->setFinder(
3352
PhpCsFixer\Finder::create()->exclude(['Tests/Functional/cache'])->in(__DIR__)
@@ -38,13 +57,11 @@ if (\class_exists(PhpCsFixer\Config::class, false)) {
3857
return Symfony\CS\Config\Config::create()
3958
->setUsingCache(true)
4059
->fixers([
41-
'align_double_arrow',
60+
'header_comment' => $header,
4261
'newline_after_open_tag',
4362
'ordered_use',
4463
'php_unit_construct',
4564
'short_array_syntax',
46-
'-unalign_double_arrow',
47-
'-unalign_equals',
4865
])
4966
->finder(
5067
Symfony\CS\Finder\DefaultFinder::create()

.styleci.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Command/AutoClosingCommand.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\Command;
413

514
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessage;
@@ -35,8 +44,7 @@ protected function configure()
3544
InputOption::VALUE_OPTIONAL,
3645
'How many days since the ticket was resolved?',
3746
'10'
38-
)
39-
;
47+
);
4048
}
4149

4250
/**
@@ -48,11 +56,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
4856
throw new \RuntimeException(sprintf('Command "%s" requires the service "fos_user.user_manager". Is "friendsofsymfony/user-bundle" installed and enabled?', $this->getName()));
4957
}
5058

51-
$ticketManager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
52-
$userManager = $this->getContainer()->get('fos_user.user_manager');
59+
$ticketManager = $this->getContainer()->get('hackzilla_ticket.ticket_manager');
60+
$userManager = $this->getContainer()->get('fos_user.user_manager');
5361
$ticketRepository = $this->getContainer()->get('doctrine')->getRepository('HackzillaTicketBundle:Ticket');
5462

55-
$locale = $this->getContainer()->getParameter('locale') ? $this->getContainer()->getParameter('locale') : 'en';
63+
$locale = $this->getContainer()->getParameter('locale') ? $this->getContainer()->getParameter('locale') : 'en';
5664
$translator = $this->getContainer()->get('translator');
5765
$translator->setLocale($locale);
5866

Command/TicketManagerCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\Command;
413

514
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessage;
@@ -40,8 +49,7 @@ protected function configure()
4049
InputOption::VALUE_OPTIONAL,
4150
'What priority would it be?',
4251
'21'
43-
)
44-
;
52+
);
4553
}
4654

4755
/**

Component/TicketFeatures.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\Component;
413

514
use Hackzilla\Bundle\TicketBundle\Model\TicketFeature\MessageAttachmentInterface;

Controller/TicketAttachmentController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\Controller;
413

514
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessageWithAttachment;

Controller/TicketController.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\Controller;
413

514
use Hackzilla\Bundle\TicketBundle\Event\TicketEvent;
@@ -27,12 +36,12 @@ class TicketController extends Controller
2736
*/
2837
public function indexAction(Request $request)
2938
{
30-
$userManager = $this->getUserManager();
39+
$userManager = $this->getUserManager();
3140
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
3241

3342
$translationDomain = $this->getParameter('hackzilla_ticket.translation_domain');
3443

35-
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN', [], $translationDomain));
44+
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN', [], $translationDomain));
3645
$ticketPriority = $request->get('priority', null);
3746

3847
$query = $ticketManager->getTicketListQuery(
@@ -50,9 +59,9 @@ public function indexAction(Request $request)
5059
return $this->render(
5160
$this->container->getParameter('hackzilla_ticket.templates')['index'],
5261
[
53-
'pagination' => $pagination,
54-
'ticketState' => $ticketState,
55-
'ticketPriority' => $ticketPriority,
62+
'pagination' => $pagination,
63+
'ticketState' => $ticketState,
64+
'ticketPriority' => $ticketPriority,
5665
'translationDomain' => $translationDomain,
5766
]
5867
);
@@ -68,7 +77,7 @@ public function createAction(Request $request)
6877
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
6978

7079
$ticket = $ticketManager->createTicket();
71-
$form = $this->createForm(TicketType::class, $ticket);
80+
$form = $this->createForm(TicketType::class, $ticket);
7281
$form->handleRequest($request);
7382

7483
if ($form->isValid()) {
@@ -87,8 +96,8 @@ public function createAction(Request $request)
8796
return $this->render(
8897
$this->container->getParameter('hackzilla_ticket.templates')['new'],
8998
[
90-
'entity' => $ticket,
91-
'form' => $form->createView(),
99+
'entity' => $ticket,
100+
'form' => $form->createView(),
92101
'translationDomain' => $translationDomain,
93102
]
94103
);
@@ -100,7 +109,7 @@ public function createAction(Request $request)
100109
public function newAction()
101110
{
102111
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
103-
$entity = $ticketManager->createTicket();
112+
$entity = $ticketManager->createTicket();
104113

105114
$form = $this->createForm(TicketType::class, $entity);
106115

@@ -109,8 +118,8 @@ public function newAction()
109118
return $this->render(
110119
$this->container->getParameter('hackzilla_ticket.templates')['new'],
111120
[
112-
'entity' => $entity,
113-
'form' => $form->createView(),
121+
'entity' => $entity,
122+
'form' => $form->createView(),
114123
'translationDomain' => $translationDomain,
115124
]
116125
);
@@ -126,7 +135,7 @@ public function newAction()
126135
public function showAction($ticketId)
127136
{
128137
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
129-
$ticket = $ticketManager->getTicketById($ticketId);
138+
$ticket = $ticketManager->getTicketById($ticketId);
130139

131140
if (!$ticket) {
132141
return $this->redirect($this->generateUrl('hackzilla_ticket'));
@@ -162,7 +171,7 @@ public function showAction($ticketId)
162171
public function replyAction(Request $request, $ticketId)
163172
{
164173
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
165-
$ticket = $ticketManager->getTicketById($ticketId);
174+
$ticket = $ticketManager->getTicketById($ticketId);
166175

167176
$translationDomain = $this->getParameter('hackzilla_ticket.translation_domain');
168177

@@ -205,7 +214,7 @@ public function replyAction(Request $request, $ticketId)
205214
public function deleteAction(Request $request, $ticketId)
206215
{
207216
$userManager = $this->getUserManager();
208-
$user = $userManager->getCurrentUser();
217+
$user = $userManager->getCurrentUser();
209218

210219
if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) {
211220
throw new \Symfony\Component\HttpKernel\Exception\HttpException(403);
@@ -218,7 +227,7 @@ public function deleteAction(Request $request, $ticketId)
218227

219228
if ($form->isValid()) {
220229
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
221-
$ticket = $ticketManager->getTicketById($ticketId);
230+
$ticket = $ticketManager->getTicketById($ticketId);
222231

223232
if (!$ticket) {
224233
$translationDomain = $this->getParameter('hackzilla_ticket.translation_domain');

DependencyInjection/Compiler/DoctrineOrmMappingsPass.php

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\DependencyInjection\Compiler;
413

14+
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
15+
use Doctrine\ORM\Mapping\Driver\XmlDriver;
516
use Hackzilla\Bundle\TicketBundle\DependencyInjection\HackzillaTicketExtension;
17+
use Hackzilla\Bundle\TicketBundle\Entity\Ticket;
18+
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessage;
19+
use Hackzilla\Bundle\TicketBundle\Entity\TicketMessageWithAttachment;
20+
use Hackzilla\Bundle\TicketBundle\Entity\TicketWithAttachment;
621
use Symfony\Component\DependencyInjection\ContainerBuilder;
722
use Symfony\Component\DependencyInjection\Definition;
823

@@ -19,25 +34,23 @@ public function __construct($driver = null, array $namespaces = [], $managerPara
1934
public function process(ContainerBuilder $container)
2035
{
2136
$bundleDirectory = HackzillaTicketExtension::bundleDirectory();
22-
$namespaces = [];
37+
$namespaces = [];
2338

2439
if (
25-
'Hackzilla\Bundle\TicketBundle\Entity\TicketWithAttachment' === $container->getParameter('hackzilla_ticket.model.ticket.class')
26-
||
27-
'Hackzilla\Bundle\TicketBundle\Entity\TicketMessageWithAttachment' === $container->getParameter('hackzilla_ticket.model.message.class')
40+
TicketWithAttachment::class === $container->getParameter('hackzilla_ticket.model.ticket.class') ||
41+
TicketMessageWithAttachment::class === $container->getParameter('hackzilla_ticket.model.message.class')
2842
) {
2943
$namespaces[realpath($bundleDirectory.'/Resources/config/doctrine/model/attachment')] = 'Hackzilla\Bundle\TicketBundle\Entity';
3044
} elseif (
31-
'Hackzilla\Bundle\TicketBundle\Entity\Ticket' === $container->getParameter('hackzilla_ticket.model.ticket.class')
32-
||
33-
'Hackzilla\Bundle\TicketBundle\Entity\TicketMessage' === $container->getParameter('hackzilla_ticket.model.message.class')
45+
Ticket::class === $container->getParameter('hackzilla_ticket.model.ticket.class') ||
46+
TicketMessage::class === $container->getParameter('hackzilla_ticket.model.message.class')
3447
) {
3548
$namespaces[realpath($bundleDirectory.'/Resources/config/doctrine/model/plain')] = 'Hackzilla\Bundle\TicketBundle\Entity';
3649
}
3750

38-
$arguments = [$namespaces, '.orm.xml'];
39-
$locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments);
40-
$this->driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', [$locator]);
51+
$arguments = [$namespaces, '.orm.xml'];
52+
$locator = new Definition(SymfonyFileLocator::class, $arguments);
53+
$this->driver = new Definition(XmlDriver::class, [$locator]);
4154
$this->namespaces = $namespaces;
4255

4356
parent::process($container);

DependencyInjection/Configuration.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of HackzillaTicketBundle package.
5+
*
6+
* (c) Daniel Platt <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Hackzilla\Bundle\TicketBundle\DependencyInjection;
413

514
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
@@ -54,8 +63,7 @@ public function getConfigTreeBuilder()
5463
->scalarNode('macros')->defaultValue('@HackzillaTicket/Macros/macros.html.twig')->end()
5564
->end()
5665
->end()
57-
->end()
58-
;
66+
->end();
5967

6068
return $treeBuilder;
6169
}

0 commit comments

Comments
 (0)