Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
42cff6a
Fix deprecation notices for Config.php
sander-bol Mar 29, 2025
5d158e5
Update composer.json
sander-bol Apr 6, 2025
213894f
Disable deprecation warnings temporarily
sander-bol Apr 6, 2025
976c93e
Rector: PHP7.0
sander-bol Apr 6, 2025
c65d998
Rector: PHP7.1
sander-bol Apr 6, 2025
74a3654
Rector: PHP7.3
sander-bol Apr 6, 2025
e0a0401
Rector: PHP7.4
sander-bol Apr 6, 2025
6dee877
Rector: Code Quality (10)
sander-bol Apr 6, 2025
009ba0c
Rector: Code Quality (15)
sander-bol Apr 6, 2025
8549493
Rector: Code Quality (100)
sander-bol Apr 6, 2025
66591e8
Rector: withTypeCoverageLevel(0)
sander-bol Apr 6, 2025
14f772e
Rector: withTypeCoverageLevel(5)
sander-bol Apr 6, 2025
a96f030
Rector: withTypeCoverageLevel(5)
sander-bol Apr 6, 2025
61088a8
Rector: withTypeCoverageLevel(10)
sander-bol Apr 6, 2025
d321f6a
Rector: withTypeCoverageLevel(15)
sander-bol Apr 6, 2025
5b422c0
Rector: withTypeCoverageLevel(17)
sander-bol Apr 6, 2025
5bd041f
Rector: withTypeCoverageLevel(18)
sander-bol Apr 6, 2025
dab1099
Rector: withTypeCoverageLevel(20)
sander-bol Apr 6, 2025
940c373
Rector: withTypeCoverageLevel(25)
sander-bol Apr 6, 2025
6a5be8d
Rector: withTypeCoverageLevel(999)
sander-bol Apr 6, 2025
09bbc50
Rector: codeQuality(true), typeDeclarations(true)
sander-bol Apr 6, 2025
697316b
Rector: naming(true)
sander-bol Apr 6, 2025
bdaebd9
Rector: deadCode(true)
sander-bol Apr 6, 2025
a280813
Bugfix: Last commit broke EventController, null is a magic value here.
sander-bol Apr 6, 2025
cbb3a95
rector: twig(true) added
sander-bol Apr 6, 2025
77cd841
rector: codingStyle(true), earlyReturn(true) added
sander-bol Apr 7, 2025
041cad5
manual: extract repeated http context building in BaseApi
sander-bol Apr 7, 2025
4ed80c3
manual: extract repeated http call in BaseAPI
sander-bol Apr 7, 2025
8af394d
manual: StyleCI changes
sander-bol Apr 9, 2025
67e4400
manual: Fix Login issues introduced by type safety
sander-bol Apr 11, 2025
b8d8291
rector: Applying rector after manual changes
sander-bol Apr 11, 2025
dbfee9e
manual: Apply return type void to defineRoutes
sander-bol Apr 11, 2025
62b393d
manual: Replace Slim::GetInstance with type safe way of getting refer…
sander-bol Apr 11, 2025
0c3a3ba
manual: Replace Slim::GetInstance with type safe way of getting refer…
sander-bol Apr 11, 2025
8cd2d7a
manual: Don't return the void call to redirect.
sander-bol Apr 11, 2025
b47f874
manual: Smaller cleanups to EventController
sander-bol Apr 11, 2025
6df9297
manual: Cleanup controllers a bit
sander-bol Apr 11, 2025
54c1bab
StyleCI: Fix spacing
sander-bol Apr 11, 2025
21082b6
BUGFIX: API returns HTTP 205 when removing a star, not HTTP 200.
sander-bol Apr 12, 2025
bc46073
BUGFIX: Throw an exception if API GET does not result in HTTP 2xx
sander-bol Apr 12, 2025
9eac577
Manual: Type safety for getName in form types
sander-bol Apr 18, 2025
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
14 changes: 4 additions & 10 deletions app/src/Apikey/ApikeyApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ class ApikeyApi extends BaseApi
{
/**
* Get all tokens associated with the current user
*
* @return array
*/
public function getCollection($queryParams)
public function getCollection($queryParams): array
{
$token_uri = $this->baseApiUrl . '/v2.1/token';

Expand All @@ -33,10 +31,8 @@ public function getCollection($queryParams)

/**
* Get a specified API-key associated with the current user
*
* @return ApikeyEntity
*/
public function getById($id, $queryParams = ['verbose' => 'yes'])
public function getById($id, $queryParams = ['verbose' => 'yes']): \Apikey\ApikeyEntity
{
$tokens_uri = $this->baseApiUrl . '/v2.1/token/' . urlencode($id);

Expand All @@ -53,12 +49,9 @@ public function getById($id, $queryParams = ['verbose' => 'yes'])
}

/**
* @param string $tokenUri
*
* @throws \Exception
* @return bool
*/
public function deleteClient($tokenUri)
public function deleteClient(string $tokenUri): bool
{
[$status, $result, $headers] = $this->apiDelete($tokenUri);

Expand All @@ -67,6 +60,7 @@ public function deleteClient($tokenUri)
if (is_array($decoded)) {
$result = current($decoded);
}

throw new \Exception($result);
}

Expand Down
27 changes: 12 additions & 15 deletions app/src/Apikey/ApikeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class ApikeyController extends BaseController
/**
* @var int number of results per pagination page
*/
private $resultsPerPage = 10;
private int $resultsPerPage = 10;

protected function defineRoutes(Slim $app)
protected function defineRoutes(Slim $slim): void
{
$app->get('/user/:username/apikey', [$this, 'index'])->name('apikey-show');
$app->get('/user/:username/apikey/:apikey/delete', [$this, 'deleteApiKey'])->via('GET', 'POST')
$slim->get('/user/:username/apikey', [$this, 'index'])->name('apikey-show');
$slim->get('/user/:username/apikey/:apikey/delete', [$this, 'deleteApiKey'])->via('GET', 'POST')
->name('apikey-delete');
}

public function index($username)
public function index($username): void
{
$thisUrl = $this->application->urlFor('apikey-show', ['username' => $username]);

Expand Down Expand Up @@ -65,8 +65,8 @@ public function index($username)
// save page position in case user returns
$_SESSION['api_key_page'] = $page;

$tokenApi = $this->getApikeyApi();
$tokens = $tokenApi->getCollection($queryParams);
$apikeyApi = $this->getApikeyApi();
$tokens = $apikeyApi->getCollection($queryParams);

// reset session state if oauth_access_tokens are removed while user is logged in (found during testing)
if (!isset($tokens['tokens'])) {
Expand Down Expand Up @@ -105,7 +105,7 @@ public function index($username)
);
}

public function deleteApiKey($username, $apikey)
public function deleteApiKey($username, $apikey): void
{
$thisUrl = $this->application->urlFor('apikey-delete', ['apikey' => $apikey, 'username' => $username]);

Expand All @@ -124,7 +124,7 @@ public function deleteApiKey($username, $apikey)
$apikeyApi = $this->getApikeyApi();
try {
$apikey = $apikeyApi->getById($apikey);
} catch (Exception $e) {
} catch (Exception $exception) {
$this->application->notFound();
return;
}
Expand Down Expand Up @@ -156,9 +156,9 @@ public function deleteApiKey($username, $apikey)
$this->application->urlFor('apikey-show', ['username' => $username])
);
return;
} catch (\RuntimeException $e) {
} catch (\RuntimeException $exception) {
$form->adderror(
new FormError('An error occurred while removing this API-Key: ' . $e->getmessage())
new FormError('An error occurred while removing this API-Key: ' . $exception->getmessage())
);
}
}
Expand All @@ -175,10 +175,7 @@ public function deleteApiKey($username, $apikey)
);
}

/**
* @return ApikeyApi
*/
private function getApikeyApi()
private function getApikeyApi(): \Apikey\ApikeyApi
{
return new ApikeyApi($this->cfg, $this->accessToken);
}
Expand Down
11 changes: 3 additions & 8 deletions app/src/Apikey/ApikeyDeleteFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,17 @@ class ApikeyDeleteFormType extends AbstractType
*
* @return string
*/
public function getName()
public function getName(): string
{
return 'apikeydelete';
}

/**
* Adds fields with their types and validation constraints to this definition.
*
* @param FormBuilderInterface $builder
* @param array $options
*
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $formBuilder, array $options): void
{
$builder
$formBuilder
->add(
'apikey_id',
'hidden',
Expand Down
6 changes: 3 additions & 3 deletions app/src/Apikey/ApikeyEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ApikeyEntity extends BaseEntity
{
public function getId()
public function getId(): string
{
return substr($this->data->token_uri, strrpos($this->data->token_uri, '/') + 1);
}
Expand All @@ -17,12 +17,12 @@ public function getApplicationName()
return $this->data->application;
}

public function getLastUsedDateTime()
public function getLastUsedDateTime(): \DateTimeImmutable
{
return new \DateTimeImmutable($this->data->last_used_date);
}

public function getCreationDateTime()
public function getCreationDateTime(): \DateTimeImmutable
{
return new \DateTimeImmutable($this->data->created_date);
}
Expand Down
50 changes: 21 additions & 29 deletions app/src/Application/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@

use Event\EventDb;
use Event\EventApi;
use Slim\Slim;
use Symfony\Component\Form\FormFactoryInterface;
use User\UserDb;
use User\UserApi;

class ApplicationController extends BaseController
{
protected function defineRoutes(\Slim\Slim $app)
protected function defineRoutes(Slim $slim): void
{
$app->get('/', [$this, 'index']);
$app->get('/about', [$this, 'about'])->name('about');
$app->map('/contact', [$this, 'contact'])->via('GET', 'POST')->name('contact');
$app->get('/not-allowed', [$this, 'notAllowed'])->name('not-allowed');
$app->get('/assets', [$this, 'assets'])->name('assets');
$slim->get('/', [$this, 'index']);
$slim->get('/about', [$this, 'about'])->name('about');
$slim->map('/contact', [$this, 'contact'])->via('GET', 'POST')->name('contact');
$slim->get('/not-allowed', [$this, 'notAllowed'])->name('not-allowed');
$slim->get('/assets', [$this, 'assets'])->name('assets');
}

public function index()
public function index(): void
{
$page = ((int)$this->application->request()->get('page') === 0)
? 1
: $this->application->request()->get('page');
$page = (int)$this->application->request()->get('page', 1);
if ($page === 0) {
$page = 1;
}

$perPage = 10;
$start = ($page -1) * $perPage;
Expand All @@ -42,21 +45,16 @@ public function index()

/**
* Get latest current events
*
* @param int $start
* @param int $perPage
* @return array
*/
public function getCurrentEvents($start, $perPage)
public function getCurrentEvents(int $start, int $perPage): array
{
$eventApi = $this->getEventApi();
return $eventApi->getEvents($perPage, $start, 'upcoming');
return $this->getEventApi()->getEvents($perPage, $start, 'upcoming');
}

/**
* Render the about page
*/
public function about()
public function about(): void
{
$this->render(
'Application/about.html.twig',
Expand All @@ -69,7 +67,7 @@ public function about()
/**
* Render the contact page
*/
public function contact()
public function contact(): void
{
$request = $this->application->request();

Expand Down Expand Up @@ -116,7 +114,7 @@ public function contact()
/**
* Render the assets page
*/
public function assets()
public function assets(): void
{
$this->render(
'Application/assets.html.twig',
Expand All @@ -130,25 +128,19 @@ public function assets()
/**
* Render the notAllowed page
*/
public function notAllowed()
public function notAllowed(): void
{
$this->render('Application/not-allowed.html.twig', [
'redirect' => $this->application->request->get('redirect')
]);
}

/**
* @return EventApi
*/
private function getEventApi()
private function getEventApi(): EventApi
{
return $this->application->container->get(EventApi::class);
}

/**
* @return ContactApi
*/
private function getContactApi()
private function getContactApi(): ContactApi
{
return $this->application->container->get(ContactApi::class);
}
Expand Down
Loading