Skip to content

Commit a35a7d5

Browse files
committed
ISSUE-337: add pipeline
1 parent 86b26f6 commit a35a7d5

File tree

7 files changed

+29
-21
lines changed

7 files changed

+29
-21
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
25+
php-versions: ['8.1']
2626
dependencies: ['latest', 'oldest']
2727
steps:
2828
- name: Checkout
@@ -63,10 +63,10 @@ jobs:
6363
- name: Run integration tests with phpunit
6464
run: vendor/bin/phpunit tests/Integration/
6565
- name: Running the system tests
66-
run: vendor/bin/phpunit tests/Integration/;
66+
run: vendor/bin/phpunit tests/System/;
6767
- name: Running static analysis
6868
run: vendor/bin/phpstan analyse -l 5 src/ tests/;
6969
- name: Running PHPMD
7070
run: vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml;
7171
- name: Running PHP_CodeSniffer
72-
run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/;
72+
run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/;

.travis.yml

Whitespace-only changes.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"phpunit/phpunit": "^10.0",
3636
"guzzlehttp/guzzle": "^6.3.0",
3737
"squizlabs/php_codesniffer": "^3.2.0",
38-
"phpstan/phpstan": "^0.12.57",
38+
"phpstan/phpstan": "^1.10",
3939
"nette/caching": "^3.0.0",
4040
"nikic/php-parser": "^4.19.1",
4141
"phpmd/phpmd": "^2.6.0",
@@ -86,7 +86,7 @@
8686
},
8787
"extra": {
8888
"branch-alias": {
89-
"dev-master": "5.0.x-dev"
89+
"dev-ISSUE-337": "5.0.x-dev"
9090
},
9191
"symfony-app-dir": "bin",
9292
"symfony-bin-dir": "bin",

src/Controller/ListController.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpList\Core\Domain\Model\Messaging\SubscriberList;
88
use PhpList\Core\Domain\Repository\Subscription\SubscriberRepository;
9+
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
910
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1011
use PhpList\Core\Domain\Repository\Messaging\SubscriberListRepository;
1112
use PhpList\Core\Security\Authentication;
@@ -62,7 +63,7 @@ public function getLists(Request $request): JsonResponse
6263
}
6364

6465
#[Route('/lists/{id}', name: 'get_list', methods: ['GET'])]
65-
public function getList(Request $request, SubscriberList $list): JsonResponse
66+
public function getList(Request $request, #[MapEntity(mapping: ['id' => 'id'])] SubscriberList $list): JsonResponse
6667
{
6768
$this->requireAuthentication($request);
6869
$json = $this->serializer->serialize($list, 'json', [
@@ -73,8 +74,10 @@ public function getList(Request $request, SubscriberList $list): JsonResponse
7374
}
7475

7576
#[Route('/lists/{id}', name: 'delete_list', methods: ['DELETE'])]
76-
public function deleteList(Request $request, SubscriberList $list): JsonResponse
77-
{
77+
public function deleteList(
78+
Request $request,
79+
#[MapEntity(mapping: ['id' => 'id'])] SubscriberList $list
80+
): JsonResponse {
7881
$this->requireAuthentication($request);
7982

8083
$this->subscriberListRepository->remove($list);
@@ -83,8 +86,10 @@ public function deleteList(Request $request, SubscriberList $list): JsonResponse
8386
}
8487

8588
#[Route('/lists/{id}/members', name: 'get_subscriber_from_list', methods: ['GET'])]
86-
public function getListMembers(Request $request, SubscriberList $list): JsonResponse
87-
{
89+
public function getListMembers(
90+
Request $request,
91+
#[MapEntity(mapping: ['id' => 'id'])] SubscriberList $list
92+
): JsonResponse {
8893
$this->requireAuthentication($request);
8994

9095
$subscribers = $this->subscriberRepository->getSubscribersBySubscribedListId($list->getId());
@@ -97,8 +102,10 @@ public function getListMembers(Request $request, SubscriberList $list): JsonResp
97102
}
98103

99104
#[Route('/lists/{id}/subscribers/count', name: 'get_subscribers_count_from_list', methods: ['GET'])]
100-
public function getSubscribersCount(Request $request, SubscriberList $list): JsonResponse
101-
{
105+
public function getSubscribersCount(
106+
Request $request,
107+
#[MapEntity(mapping: ['id' => 'id'])] SubscriberList $list
108+
): JsonResponse {
102109
$this->requireAuthentication($request);
103110
$json = $this->serializer->serialize(count($list->getSubscribers()), 'json');
104111

src/Controller/SessionController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Controller;
66

7+
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
78
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
89
use PhpList\Core\Domain\Model\Identity\Administrator;
910
use PhpList\Core\Domain\Model\Identity\AdministratorToken;
@@ -24,7 +25,6 @@
2425
* This controller provides methods to create and destroy REST API sessions.
2526
*
2627
* @author Oliver Klee <[email protected]>
27-
* @author Tatevik Grigoryan <[email protected]>
2828
*/
2929
class SessionController extends AbstractController
3030
{
@@ -83,8 +83,10 @@ public function createSession(Request $request): JsonResponse
8383
* @throws AccessDeniedHttpException
8484
*/
8585
#[Route('/sessions/{id}', name: 'delete_session', methods: ['DELETE'])]
86-
public function deleteAction(Request $request, AdministratorToken $token): JsonResponse
87-
{
86+
public function deleteAction(
87+
Request $request,
88+
#[MapEntity(mapping: ['id' => 'id'])] AdministratorToken $token
89+
): JsonResponse {
8890
$administrator = $this->requireAuthentication($request);
8991
if ($token->getAdministrator() !== $administrator) {
9092
throw new AccessDeniedHttpException('You do not have access to this session.', null, 1519831644);

src/Controller/SubscriberController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ public function postAction(Request $request): JsonResponse
6868
$subscriber->setDisabled((bool)$data->get('disabled'));
6969
$this->subscriberRepository->save($subscriber);
7070

71-
$json = $this->serializer->serialize($subscriber, 'json');
72-
73-
return new JsonResponse($json, Response::HTTP_CREATED, [], true);
71+
return new JsonResponse(
72+
$this->serializer->serialize($subscriber, 'json'),
73+
Response::HTTP_CREATED, [],
74+
true
75+
);
7476
}
7577

7678
/**

src/DependencyInjection/PhpListRestExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ class PhpListRestExtension extends Extension
3030
*/
3131
public function load(array $configs, ContainerBuilder $container): void
3232
{
33-
// This parameter is unused, but not optional. This line will avoid a static analysis warning this.
34-
$configs;
35-
3633
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
3734
$loader->load('services.yml');
3835
}

0 commit comments

Comments
 (0)