diff --git a/.gitattributes b/.gitattributes
index 667b29d7..dabb7332 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,4 @@
.* export-ignore
*.md export-ignore
-tests export-ignore
-docs export-ignore
+Tests export-ignore
+Resources/doc export-ignore
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
new file mode 100644
index 00000000..ee088834
--- /dev/null
+++ b/.github/workflows/lint.yaml
@@ -0,0 +1,65 @@
+on: [push, pull_request]
+
+name: Lint
+
+jobs:
+ php-cs-fixer:
+ name: PHP-CS-Fixer
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: "Checkout"
+ uses: actions/checkout@v2
+
+ - name: "Run PHP-CS-Fixer"
+ uses: docker://oskarstark/php-cs-fixer-ga:2.16.1
+ with:
+ args: --ansi --verbose --diff --dry-run
+
+ composer-normalize:
+ name: composer-normalize
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: "Checkout"
+ uses: actions/checkout@v2
+
+ - name: "Run composer-normalize"
+ uses: docker://localheinz/composer-normalize-action:0.5.2
+ with:
+ args: --dry-run
+
+ yaml-files:
+ name: YAML files
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: "Checkout"
+ uses: actions/checkout@v2
+
+ - name: "Install Ruby 2.6"
+ uses: actions/setup-ruby@v1
+ with:
+ ruby-version: '2.6'
+
+ - run: gem install yaml-lint
+
+ - name: "Linting..."
+ run: make lint-yaml
+
+ xml-files:
+ name: XML files
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: "Checkout"
+ uses: actions/checkout@v2
+
+ - run: sudo apt-get update && sudo apt-get install libxml2-utils
+
+ - name: "Linting..."
+ run: make lint-xml
diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml
new file mode 100644
index 00000000..a7963134
--- /dev/null
+++ b/.github/workflows/qa.yaml
@@ -0,0 +1,14 @@
+on: [push, pull_request]
+name: Quality assurance
+jobs:
+ phpstan:
+ name: PHPStan
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - name: PHPStan
+ uses: "docker://oskarstark/phpstan-ga"
+ env:
+ REQUIRE_DEV: true
+ with:
+ args: analyse
diff --git a/.travis.yml b/.travis.yml
index 8953d7bd..36635248 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -46,6 +46,7 @@ cache:
before_script:
- if [ -f xdebug.ini ]; then phpenv config-rm xdebug.ini; fi
- if [ "$GITHUB_OAUTH_TOKEN" != "" ]; then echo -e $GITHUB_OAUTH_TOKEN && composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN; fi;
+ - if [ 70100 -gt $(php -r 'echo PHP_VERSION_ID;') ]; then composer remove --dev "phpstan/phpstan" --no-update; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- if [ -n $INSTALL_VICH_UPLOADER_BUNDLE ]; then composer require "vich/uploader-bundle" --no-update; fi;
- COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
diff --git a/Component/TicketFeatures.php b/Component/TicketFeatures.php
index acef95ba..158d357b 100644
--- a/Component/TicketFeatures.php
+++ b/Component/TicketFeatures.php
@@ -9,7 +9,6 @@ class TicketFeatures
private $features;
/**
- * @param array $features
* @param string $messageClass TicketMessage class
*/
public function __construct(array $features, $messageClass)
diff --git a/Controller/TicketController.php b/Controller/TicketController.php
index fd5327c2..3a87ae7c 100644
--- a/Controller/TicketController.php
+++ b/Controller/TicketController.php
@@ -21,8 +21,6 @@ class TicketController extends Controller
/**
* Lists all Ticket entities.
*
- * @param Request $request
- *
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction(Request $request)
@@ -61,8 +59,6 @@ public function indexAction(Request $request)
/**
* Creates a new Ticket entity.
*
- * @param Request $request
- *
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function createAction(Request $request)
@@ -157,8 +153,7 @@ public function showAction($ticketId)
/**
* Finds and displays a TicketInterface entity.
*
- * @param Request $request
- * @param int $ticketId
+ * @param int $ticketId
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
@@ -201,8 +196,7 @@ public function replyAction(Request $request, $ticketId)
/**
* Deletes a Ticket entity.
*
- * @param Request $request
- * @param int $ticketId
+ * @param int $ticketId
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
@@ -259,8 +253,6 @@ private function createDeleteForm($id)
}
/**
- * @param TicketMessageInterface $message
- *
* @return \Symfony\Component\Form\Form
*/
private function createMessageForm(TicketMessageInterface $message)
diff --git a/Entity/Traits/TicketMessageTrait.php b/Entity/Traits/TicketMessageTrait.php
index 6f9426e7..ef76ffca 100644
--- a/Entity/Traits/TicketMessageTrait.php
+++ b/Entity/Traits/TicketMessageTrait.php
@@ -227,8 +227,6 @@ public function getMessage()
/**
* Set createdAt.
*
- * @param \DateTime $createdAt
- *
* @return $this
*/
public function setCreatedAt(\DateTime $createdAt)
diff --git a/Entity/Traits/TicketTrait.php b/Entity/Traits/TicketTrait.php
index fd8a5c54..5acaef03 100644
--- a/Entity/Traits/TicketTrait.php
+++ b/Entity/Traits/TicketTrait.php
@@ -334,8 +334,6 @@ public function getSubject()
/**
* Add message.
*
- * @param TicketMessageInterface $message
- *
* @return $this
*/
public function addMessage(TicketMessageInterface $message)
@@ -348,8 +346,6 @@ public function addMessage(TicketMessageInterface $message)
/**
* Remove message.
*
- * @param TicketMessageInterface $message
- *
* @return $this
*/
public function removeMessage(TicketMessageInterface $message)
diff --git a/EventListener/FileSubscriber.php b/EventListener/FileSubscriber.php
index dd0a61e0..62850f9a 100644
--- a/EventListener/FileSubscriber.php
+++ b/EventListener/FileSubscriber.php
@@ -23,9 +23,6 @@ public static function getSubscribedEvents()
];
}
- /**
- * @param VichEvent\Event $event
- */
public function postUpload(VichEvent\Event $event)
{
/** @var MessageAttachmentInterface $object */
diff --git a/Form/Type/TicketMessageType.php b/Form/Type/TicketMessageType.php
index c78c98b2..776bf194 100644
--- a/Form/Type/TicketMessageType.php
+++ b/Form/Type/TicketMessageType.php
@@ -28,10 +28,6 @@ public function __construct(UserManagerInterface $userManager, TicketFeatures $f
$this->messageClass = $messageClass;
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
diff --git a/Form/Type/TicketType.php b/Form/Type/TicketType.php
index ce8ef7c4..ce1c052b 100644
--- a/Form/Type/TicketType.php
+++ b/Form/Type/TicketType.php
@@ -17,10 +17,6 @@ public function __construct($ticketClass)
$this->ticketClass = $ticketClass;
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
diff --git a/HackzillaTicketBundle.php b/HackzillaTicketBundle.php
index ebb223e8..48ab8272 100644
--- a/HackzillaTicketBundle.php
+++ b/HackzillaTicketBundle.php
@@ -8,9 +8,6 @@
class HackzillaTicketBundle extends Bundle
{
- /**
- * @param ContainerBuilder $container
- */
public function build(ContainerBuilder $container)
{
parent::build($container);
diff --git a/Makefile b/Makefile
index 865e3b2b..50d75a13 100644
--- a/Makefile
+++ b/Makefile
@@ -9,3 +9,67 @@ test:
test_with_vichuploaderbundle:
vendor/bin/simple-phpunit -c phpunit.xml.dist
+
+all:
+ @echo "Please choose a task."
+.PHONY: all
+
+lint: lint-composer lint-yaml lint-xml lint-php
+.PHONY: lint
+
+lint-composer:
+ composer validate
+.PHONY: lint-composer
+
+lint-yaml:
+ yaml-lint --ignore-non-yaml-files --quiet --exclude vendor .
+
+.PHONY: lint-yaml
+
+lint-xml:
+ find . \( -name '*.xml' -or -name '*.xliff' \) \
+ -not -path './vendor/*' \
+ -not -path './src/Resources/public/vendor/*' \
+ | while read xmlFile; \
+ do \
+ XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile"|diff - "$$xmlFile"; \
+ if [ $$? -ne 0 ] ;then exit 1; fi; \
+ done
+
+.PHONY: lint-xml
+
+lint-php:
+ php-cs-fixer fix --ansi --verbose --diff --dry-run
+.PHONY: lint-php
+
+cs-fix: cs-fix-php cs-fix-xml
+.PHONY: cs-fix
+
+cs-fix-php:
+ php-cs-fixer fix --verbose
+.PHONY: cs-fix-php
+
+cs-fix-xml:
+ find . \( -name '*.xml' -or -name '*.xliff' \) \
+ -not -path './vendor/*' \
+ -not -path './src/Resources/public/vendor/*' \
+ | while read xmlFile; \
+ do \
+ XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile" --output "$$xmlFile"; \
+ done
+.PHONY: cs-fix-xml
+
+build:
+ mkdir $@
+
+test:
+ifeq ($(shell php --modules|grep --quiet pcov;echo $$?), 0)
+ vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
+else
+ vendor/bin/simple-phpunit -c phpunit.xml.dist
+endif
+.PHONY: test
+
+docs:
+ cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html
+.PHONY: docs
diff --git a/Manager/TicketManager.php b/Manager/TicketManager.php
index 6b296d7c..5c37dd94 100644
--- a/Manager/TicketManager.php
+++ b/Manager/TicketManager.php
@@ -43,8 +43,6 @@ public function __construct($ticketClass, $ticketMessageClass)
}
/**
- * @param ObjectManager $om
- *
* @return $this
*/
public function setEntityManager(ObjectManager $om)
@@ -57,8 +55,6 @@ public function setEntityManager(ObjectManager $om)
}
/**
- * @param TranslatorInterface $translator
- *
* @return $this
*/
public function setTranslator(TranslatorInterface $translator)
@@ -140,8 +136,6 @@ public function updateTicket(TicketInterface $ticket, TicketMessageInterface $me
/**
* Delete a ticket from the database.
- *
- * @param TicketInterface $ticket
*/
public function deleteTicket(TicketInterface $ticket)
{
@@ -186,8 +180,6 @@ public function getMessageById($ticketMessageId)
/**
* Find ticket by criteria.
*
- * @param array $criteria
- *
* @return array|TicketInterface[]
*/
public function findTicketsBy(array $criteria)
@@ -200,9 +192,8 @@ public function findTicketsBy(array $criteria)
*
* @deprecated since hackzilla/ticket-bundle 3.3, use `getTicketListQuery()` instead.
*
- * @param UserManagerInterface $userManager
- * @param int $ticketStatus
- * @param int $ticketPriority
+ * @param int $ticketStatus
+ * @param int $ticketPriority
*
* @return mixed
*/
diff --git a/Manager/TicketManagerInterface.php b/Manager/TicketManagerInterface.php
index 028408ff..bb42d480 100644
--- a/Manager/TicketManagerInterface.php
+++ b/Manager/TicketManagerInterface.php
@@ -2,8 +2,8 @@
namespace Hackzilla\Bundle\TicketBundle\Manager;
-use Doctrine\ORM\QueryBuilder;
use Doctrine\Common\Persistence\ObjectManager;
+use Doctrine\ORM\QueryBuilder;
use Hackzilla\Bundle\TicketBundle\Model\TicketInterface;
use Hackzilla\Bundle\TicketBundle\Model\TicketMessageInterface;
use Symfony\Component\Translation\TranslatorInterface;
@@ -22,7 +22,7 @@ public function createTicket();
public function createMessage(TicketInterface $ticket = null);
/**
- * @return void
+ * NEXT_MAJOR: Declare `void` as return type.
*/
public function updateTicket(TicketInterface $ticket, TicketMessageInterface $message = null);
@@ -41,9 +41,8 @@ public function findTicketsBy(array $criteria);
*
* @deprecated since hackzilla/ticket-bundle 3.3, use `getTicketListQuery()` instead.
*
- * @param UserManagerInterface $userManager
- * @param int $ticketStatus
- * @param int $ticketPriority
+ * @param int $ticketStatus
+ * @param int $ticketPriority
*
* @return QueryBuilder
*/
diff --git a/Manager/UserManager.php b/Manager/UserManager.php
index 06732691..43f4d559 100644
--- a/Manager/UserManager.php
+++ b/Manager/UserManager.php
@@ -27,11 +27,6 @@ class UserManager implements UserManagerInterface
*/
private $userRepository;
- /**
- * @param TokenStorageInterface $tokenStorage
- * @param ObjectRepository $userRepository
- * @param AuthorizationCheckerInterface $authorizationChecker
- */
public function __construct(
TokenStorageInterface $tokenStorage,
ObjectRepository $userRepository,
@@ -73,8 +68,7 @@ public function getUserById($userId)
/**
* Current user has permission.
*
- * @param UserInterface $user
- * @param string $role
+ * @param string $role
*
* @return bool
*/
@@ -85,14 +79,11 @@ public function hasRole(UserInterface $user, $role)
/**
* @param UserInterface|string $user
- * @param TicketInterface $ticket
*/
public function hasPermission($user, TicketInterface $ticket)
{
- if (!\is_object($user) || (!$this->hasRole(
- $user,
- TicketRole::ADMIN
- ) && $ticket->getUserCreated() != $user->getId())
+ if (!\is_object($user) || (!$this->hasRole($user, TicketRole::ADMIN) &&
+ $ticket->getUserCreated() != $user->getId())
) {
throw new AccessDeniedHttpException();
}
diff --git a/Manager/UserManagerInterface.php b/Manager/UserManagerInterface.php
index d27886fa..9fa3d2c3 100644
--- a/Manager/UserManagerInterface.php
+++ b/Manager/UserManagerInterface.php
@@ -15,7 +15,6 @@ public function hasRole(UserInterface $user, $role);
/**
* @param \Hackzilla\Bundle\TicketBundle\Model\UserInterface|string $user
- * @param TicketInterface $ticket
*/
public function hasPermission($user, TicketInterface $ticket);
}
diff --git a/Model/TicketInterface.php b/Model/TicketInterface.php
index 2140e2ce..1ff56995 100644
--- a/Model/TicketInterface.php
+++ b/Model/TicketInterface.php
@@ -170,16 +170,12 @@ public function getSubject();
/**
* Add message.
*
- * @param TicketMessageInterface $message
- *
* @return $this
*/
public function addMessage(TicketMessageInterface $message);
/**
* Remove message.
- *
- * @param TicketMessageInterface $message
*/
public function removeMessage(TicketMessageInterface $message);
diff --git a/Model/TicketMessageInterface.php b/Model/TicketMessageInterface.php
index 470a8556..2677f225 100644
--- a/Model/TicketMessageInterface.php
+++ b/Model/TicketMessageInterface.php
@@ -117,8 +117,6 @@ public function getMessage();
/**
* Set createdAt.
*
- * @param \DateTime $createdAt
- *
* @return $this
*/
public function setCreatedAt(\DateTime $createdAt);
diff --git a/Resources/config/doctrine/model/attachment/TicketMessageWithAttachment.orm.xml b/Resources/config/doctrine/model/attachment/TicketMessageWithAttachment.orm.xml
index e5cd4bfd..6f1ff95c 100644
--- a/Resources/config/doctrine/model/attachment/TicketMessageWithAttachment.orm.xml
+++ b/Resources/config/doctrine/model/attachment/TicketMessageWithAttachment.orm.xml
@@ -1,21 +1,21 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/model/attachment/TicketWithAttachment.orm.xml b/Resources/config/doctrine/model/attachment/TicketWithAttachment.orm.xml
index 0b86c984..f0e1aada 100644
--- a/Resources/config/doctrine/model/attachment/TicketWithAttachment.orm.xml
+++ b/Resources/config/doctrine/model/attachment/TicketWithAttachment.orm.xml
@@ -1,16 +1,16 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/model/plain/Ticket.orm.xml b/Resources/config/doctrine/model/plain/Ticket.orm.xml
index c2d40140..9b66464b 100644
--- a/Resources/config/doctrine/model/plain/Ticket.orm.xml
+++ b/Resources/config/doctrine/model/plain/Ticket.orm.xml
@@ -1,16 +1,16 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/doctrine/model/plain/TicketMessage.orm.xml b/Resources/config/doctrine/model/plain/TicketMessage.orm.xml
index f2412464..0b0b7cd5 100644
--- a/Resources/config/doctrine/model/plain/TicketMessage.orm.xml
+++ b/Resources/config/doctrine/model/plain/TicketMessage.orm.xml
@@ -1,18 +1,18 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/services.yml b/Resources/config/services.yml
index f2f53d06..39f1d461 100644
--- a/Resources/config/services.yml
+++ b/Resources/config/services.yml
@@ -74,9 +74,9 @@ services:
hackzilla_ticket.command.autoclosing:
class: Hackzilla\Bundle\TicketBundle\Command\AutoClosingCommand
tags:
- - { name: console.command, command: ticket:autoclosing }
+ - { name: console.command, command: 'ticket:autoclosing' }
hackzilla_ticket.command.create:
class: Hackzilla\Bundle\TicketBundle\Command\TicketManagerCommand
tags:
- - { name: console.command, command: ticket:create }
+ - { name: console.command, command: 'ticket:create' }
diff --git a/Resources/config/vich_uploader/TicketMessageWithAttachment.xml b/Resources/config/vich_uploader/TicketMessageWithAttachment.xml
index de09fafc..15d70f40 100644
--- a/Resources/config/vich_uploader/TicketMessageWithAttachment.xml
+++ b/Resources/config/vich_uploader/TicketMessageWithAttachment.xml
@@ -1,3 +1,4 @@
+
-
+
diff --git a/Tests/Manager/TicketManagerTest.php b/Tests/Manager/TicketManagerTest.php
index d68f3e42..722a5c89 100644
--- a/Tests/Manager/TicketManagerTest.php
+++ b/Tests/Manager/TicketManagerTest.php
@@ -35,7 +35,7 @@ protected function tearDown()
public function testGetTicketListQuery()
{
- $ticketClass = 'App\Ticket';
+ $ticketClass = 'App\Ticket';
$ticketMessageClass = 'App\TicketMessage';
$qb = $this->createMock(QueryBuilder::class);
@@ -70,7 +70,7 @@ public function testGetTicketListQuery()
*/
public function testGetTicketList()
{
- $ticketClass = 'App\Ticket';
+ $ticketClass = 'App\Ticket';
$ticketMessageClass = 'App\TicketMessage';
$qb = $this->createMock(QueryBuilder::class);
diff --git a/TwigExtension/TicketFeatureExtension.php b/TwigExtension/TicketFeatureExtension.php
index 32583621..ceddbc47 100644
--- a/TwigExtension/TicketFeatureExtension.php
+++ b/TwigExtension/TicketFeatureExtension.php
@@ -10,9 +10,6 @@ class TicketFeatureExtension extends AbstractExtension
{
private $ticketFeatures;
- /**
- * @param TicketFeatures $ticketFeatures
- */
public function __construct(TicketFeatures $ticketFeatures)
{
$this->ticketFeatures = $ticketFeatures;
diff --git a/composer.json b/composer.json
index 66dbb66c..0a08d1b6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,6 @@
{
"name": "hackzilla/ticket-bundle",
+ "type": "symfony-bundle",
"description": "This Bundle provides multilingual ticketing functionality for Symfony applications.",
"keywords": [
"ticket",
@@ -14,7 +15,6 @@
"german",
"spanish"
],
- "type": "symfony-bundle",
"license": "MIT",
"authors": [
{
@@ -48,6 +48,7 @@
"require-dev": {
"ext-pdo_sqlite": "*",
"friendsofphp/php-cs-fixer": "^1.4 || ^2.0",
+ "phpstan/phpstan": "^0.12.32",
"phpunit/phpunit": ">=5.4.3,<8.0",
"symfony/phpunit-bridge": "^3.2 || ^4.0",
"symfony/security": "^2.8 || ^3.0 || ^4.0"
@@ -56,23 +57,25 @@
"friendsofsymfony/user-bundle": "In order to ease user management",
"vich/uploader-bundle": "Allow attaching files to ticket messages"
},
+ "config": {
+ "sort-packages": true
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
"autoload": {
"psr-4": {
"Hackzilla\\Bundle\\TicketBundle\\": ""
},
- "exclude-from-classmap": ["Tests/"]
+ "exclude-from-classmap": [
+ "Tests/"
+ ]
},
"autoload-dev": {
"psr-4": {
"Hackzilla\\Bundle\\TicketBundle\\Tests\\": "Tests/"
}
- },
- "config": {
- "sort-packages": true
- },
- "extra": {
- "branch-alias": {
- "dev-master": "3.x-dev"
- }
}
}
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
new file mode 100644
index 00000000..48d0a080
--- /dev/null
+++ b/phpstan.neon.dist
@@ -0,0 +1,8 @@
+parameters:
+ level: 0
+ paths:
+ - .
+ excludes_analyse:
+ - vendor/
+ ignoreErrors:
+ - '#.* (class|type) Vich\\UploaderBundle\\.*#'