Skip to content

Commit 702a5e7

Browse files
committed
fix: corrected PHP 8.5 notices
1 parent 112089c commit 702a5e7

File tree

78 files changed

+132
-129
lines changed

Some content is hidden

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

78 files changed

+132
-129
lines changed

phpmyfaq/admin/assets/scss/_global.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ body {
2424
.main-content,
2525
#content,
2626
.content-wrapper {
27-
background-color: var(--bs-dark) !important;
27+
//background-color: var(--bs-dark) !important;
2828
color: var(--bs-light) !important;
2929
}
3030

phpmyfaq/admin/assets/src/configuration/upgrade.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { handleStreamingProgress } from './upgrade';
44
/**
55
* Helper to create a mock readable stream with progress updates
66
*/
7-
function createMockStream(progressValues: string[]): ReadableStream<Uint8Array> {
7+
function createStubStream(progressValues: string[]): ReadableStream<Uint8Array> {
88
const encoder = new TextEncoder();
99
let index = 0;
1010

@@ -24,8 +24,8 @@ function createMockStream(progressValues: string[]): ReadableStream<Uint8Array>
2424
/**
2525
* Helper to create a mock Response with a readable stream
2626
*/
27-
function createMockResponse(progressValues: string[]): Response {
28-
const stream = createMockStream(progressValues);
27+
function createStubResponse(progressValues: string[]): Response {
28+
const stream = createStubStream(progressValues);
2929
return new Response(stream);
3030
}
3131

@@ -50,7 +50,7 @@ describe('handleStreamingProgress', () => {
5050
});
5151

5252
it('should update progress bar with streaming values', async () => {
53-
const response = createMockResponse(['10%', '25%', '50%', '75%', '90%']);
53+
const response = createStubResponse(['10%', '25%', '50%', '75%', '90%']);
5454

5555
await handleStreamingProgress(response, progressBarId);
5656

@@ -63,7 +63,7 @@ describe('handleStreamingProgress', () => {
6363
});
6464

6565
it('should handle empty stream and complete with 100%', async () => {
66-
const response = createMockResponse([]);
66+
const response = createStubResponse([]);
6767

6868
await handleStreamingProgress(response, progressBarId);
6969

@@ -96,7 +96,7 @@ describe('handleStreamingProgress', () => {
9696
});
9797

9898
it('should handle missing progress bar element', async () => {
99-
const response = createMockResponse(['50%']);
99+
const response = createStubResponse(['50%']);
100100
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
101101

102102
await handleStreamingProgress(response, 'non-existent-id');
@@ -119,7 +119,7 @@ describe('handleStreamingProgress', () => {
119119

120120
it('should update progress bar incrementally', async () => {
121121
const progressValues = ['25%', '50%', '75%'];
122-
const response = createMockResponse(progressValues);
122+
const response = createStubResponse(progressValues);
123123

124124
// We need to intercept the updates as they happen
125125
const updates: string[] = [];
@@ -170,7 +170,7 @@ describe('handleStreamingProgress', () => {
170170
});
171171

172172
it('should remove animation classes when complete', async () => {
173-
const response = createMockResponse(['50%']);
173+
const response = createStubResponse(['50%']);
174174

175175
// Verify initial state has animation classes
176176
expect(progressBar.classList.contains('progress-bar-animated')).toBe(true);
@@ -187,7 +187,7 @@ describe('handleStreamingProgress', () => {
187187
it('should handle rapid progress updates', async () => {
188188
// Create many rapid updates
189189
const progressValues = Array.from({ length: 20 }, (_, i) => `${(i + 1) * 5}%`);
190-
const response = createMockResponse(progressValues);
190+
const response = createStubResponse(progressValues);
191191

192192
await handleStreamingProgress(response, progressBarId);
193193

@@ -255,7 +255,7 @@ describe('Progress bar integration scenarios', () => {
255255
</div>
256256
`;
257257

258-
const response = createMockResponse(['33%', '66%', '99%']);
258+
const response = createStubResponse(['33%', '66%', '99%']);
259259
await handleStreamingProgress(response, 'integration-test-bar');
260260

261261
const progressBar = document.getElementById('integration-test-bar') as HTMLElement;

phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/ConfigurationTabController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ final class ConfigurationTabController extends AbstractController
4242
/**
4343
* @throws TemplateException
4444
* @throws Exception
45-
* @throws LoaderError*@throws \Exception
46-
*
45+
* @throws LoaderError
46+
* @throws \Exception
4747
*/
4848
#[Route(path: 'admin/api/configuration/list/{mode}')]
4949
public function list(Request $request): Response
@@ -84,7 +84,7 @@ public function list(Request $request): Response
8484
}
8585

8686
/**
87-
* @throws Exception|\Exception
87+
* @throws \Exception
8888
*/
8989
#[Route(path: 'admin/api/configuration')]
9090
public function save(Request $request): JsonResponse

phpmyfaq/src/phpMyFAQ/Controller/Administration/AuthenticationController.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public function authenticate(Request $request): Response
4141

4242
$logging = $this->container->get(id: 'phpmyfaq.admin.admin-log');
4343

44-
$username = Filter::filterVar($request->attributes->get(key: 'faqusername'), FILTER_SANITIZE_SPECIAL_CHARS);
44+
$username = Filter::filterVar($request->request->get(key: 'faqusername'), FILTER_SANITIZE_SPECIAL_CHARS);
4545
$password = Filter::filterVar(
46-
$request->attributes->get(key: 'faqpassword'),
46+
$request->request->get(key: 'faqpassword'),
4747
FILTER_SANITIZE_SPECIAL_CHARS,
4848
FILTER_FLAG_NO_ENCODE_QUOTES,
4949
);
50-
$rememberMe = Filter::filterVar($request->attributes->get(key: 'faqrememberme'), FILTER_VALIDATE_BOOLEAN);
50+
$rememberMe = Filter::filterVar($request->request->get(key: 'faqrememberme'), FILTER_VALIDATE_BOOLEAN);
5151

5252
// Set username via SSO
5353
if (
@@ -144,7 +144,8 @@ public function logout(Request $request): Response
144144

145145
$redirectResponse = new RedirectResponse(url: $this->configuration->getDefaultUrl() . 'admin/login');
146146

147-
$csrfToken = Filter::filterVar($request->attributes->get(key: 'csrf'), FILTER_SANITIZE_SPECIAL_CHARS);
147+
$csrfToken = Filter::filterVar($request->query->get(key: 'csrf'), FILTER_SANITIZE_SPECIAL_CHARS);
148+
148149
if (!Token::getInstance($this->container->get(id: 'session'))->verifyToken(
149150
page: 'admin-logout',
150151
requestToken: $csrfToken,
@@ -173,7 +174,7 @@ public function token(Request $request): Response
173174
return new RedirectResponse(url: './');
174175
}
175176

176-
$userId = (int) Filter::filterVar($request->attributes->get(key: 'user-id'), FILTER_VALIDATE_INT);
177+
$userId = (int) Filter::filterVar($request->request->get(key: 'user-id'), FILTER_VALIDATE_INT);
177178

178179
return $this->render(
179180
file: '@admin/user/twofactor.twig',
@@ -204,8 +205,8 @@ public function check(Request $request): Response
204205
return new RedirectResponse(url: './');
205206
}
206207

207-
$token = Filter::filterVar($request->attributes->get(key: 'token'), FILTER_SANITIZE_SPECIAL_CHARS);
208-
$userId = (int) Filter::filterVar($request->attributes->get(key: 'user-id'), FILTER_VALIDATE_INT);
208+
$token = Filter::filterVar($request->request->get(key: 'token'), FILTER_SANITIZE_SPECIAL_CHARS);
209+
$userId = (int) Filter::filterVar($request->request->get(key: 'user-id'), FILTER_VALIDATE_INT);
209210

210211
$user = $this->container->get(id: 'phpmyfaq.user.current_user');
211212
$user->getUserById($userId);

phpunit.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
beStrictAboutOutputDuringTests="true"
66
failOnRisky="true"
77
failOnWarning="true"
8+
failOnNotice="true"
9+
colors="true"
810
testdox="false"
911
cacheDirectory=".phpunit.cache"
1012
requireCoverageMetadata="false"

tests/phpMyFAQ/Administration/ApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ApiTest extends TestCase
2828
*/
2929
protected function setUp(): void
3030
{
31-
$this->configuration = $this->createMock(Configuration::class);
31+
$this->configuration = $this->createStub(Configuration::class);
3232
$this->system = $this->createMock(System::class);
3333
$this->httpClient = $this->createMock(HttpClientInterface::class);
3434

@@ -125,7 +125,7 @@ public function testIsVerifiedTransportException(): void
125125
*/
126126
public function testGetVerificationIssues(): void
127127
{
128-
$this->configuration = $this->createMock(Configuration::class);
128+
$this->configuration = $this->createStub(Configuration::class);
129129
$mockSystem = $this->getMockBuilder(System::class)
130130
->onlyMethods(['createHashes'])
131131
->getMock();

tests/phpMyFAQ/Administration/BackupTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function setUp(): void
5252
$this->backup = new Backup($this->configuration, $this->databaseHelper);
5353

5454
// Mock Configuration class
55-
$this->mockConfiguration = $this->createMock(Configuration::class);
55+
$this->mockConfiguration = $this->createStub(Configuration::class);
5656

5757
// Mock DatabaseHelper class
5858
$this->mockDatabaseHelper = $this->createMock(DatabaseHelper::class);

tests/phpMyFAQ/Administration/CategoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function setUp(): void
3939
parent::setUp();
4040

4141
$this->databaseMock = $this->createMock(DatabaseDriver::class);
42-
$this->configurationMock = $this->createMock(Configuration::class);
42+
$this->configurationMock = $this->createStub(Configuration::class);
4343
$this->configurationMock
4444
->method('getDb')
4545
->willReturn($this->databaseMock);

tests/phpMyFAQ/Administration/LatestUsersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function setUp(): void
2020
parent::setUp();
2121

2222
$this->databaseMock = $this->createMock(DatabaseDriver::class);
23-
$this->configurationMock = $this->createMock(Configuration::class);
23+
$this->configurationMock = $this->createStub(Configuration::class);
2424
$this->configurationMock
2525
->method('getDb')
2626
->willReturn($this->databaseMock);

tests/phpMyFAQ/Administration/SessionRepositoryTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SessionRepositoryTest extends TestCase
1515

1616
protected function setUp(): void
1717
{
18-
$this->mockConfiguration = $this->createMock(Configuration::class);
18+
$this->mockConfiguration = $this->createStub(Configuration::class);
1919
$this->mockDb = $this->createMock(DatabaseDriver::class);
2020
$this->mockConfiguration->method('getDb')->willReturn($this->mockDb);
2121

@@ -27,7 +27,7 @@ public function testCountOnlineUsersFromSessionsReturnsCount(): void
2727
$minTimestamp = 1609459200;
2828
$expectedCount = 5;
2929

30-
$resultMock = $this->createMock(stdClass::class);
30+
$resultMock = $this->createStub(stdClass::class);
3131
$resultMock->cnt = $expectedCount;
3232

3333
$this->mockDb->method('query')->willReturn(true);
@@ -54,7 +54,7 @@ public function testCountOnlineUsersFromFaqUserReturnsCount(): void
5454
$minTimestamp = 1609459200;
5555
$expectedCount = 3;
5656

57-
$resultMock = $this->createMock(stdClass::class);
57+
$resultMock = $this->createStub(stdClass::class);
5858
$resultMock->cnt = $expectedCount;
5959

6060
$this->mockDb->method('query')->willReturn(true);
@@ -70,7 +70,7 @@ public function testGetTimeBySessionIdReturnsTimestamp(): void
7070
$sessionId = 123;
7171
$expectedTime = 1609459200;
7272

73-
$resultMock = $this->createMock(stdClass::class);
73+
$resultMock = $this->createStub(stdClass::class);
7474
$resultMock->time = $expectedTime;
7575

7676
$this->mockDb->method('query')->willReturn(true);
@@ -97,7 +97,7 @@ public function testGetSessionsByDateRangeReturnsArray(): void
9797
$firstHour = 1609459200;
9898
$lastHour = 1609545600;
9999

100-
$resultMock = $this->createMock(stdClass::class);
100+
$resultMock = $this->createStub(stdClass::class);
101101
$resultMock->sid = 1;
102102
$resultMock->ip = '127.0.0.1';
103103
$resultMock->time = 1609462800;
@@ -130,7 +130,7 @@ public function testCountTotalSessionsReturnsCount(): void
130130
{
131131
$expectedCount = 42;
132132

133-
$resultMock = $this->createMock(stdClass::class);
133+
$resultMock = $this->createStub(stdClass::class);
134134
$resultMock->num_sessions = $expectedCount;
135135

136136
$this->mockDb->method('query')->willReturn(true);
@@ -203,10 +203,10 @@ public function testGetSessionTimestampsReturnsArray(): void
203203
$startDate = 1609459200;
204204
$endDate = 1609545600;
205205

206-
$resultMock1 = $this->createMock(stdClass::class);
206+
$resultMock1 = $this->createStub(stdClass::class);
207207
$resultMock1->time = 1609462800;
208208

209-
$resultMock2 = $this->createMock(stdClass::class);
209+
$resultMock2 = $this->createStub(stdClass::class);
210210
$resultMock2->time = 1609476000;
211211

212212
$this->mockDb->method('query')->willReturn(true);
@@ -247,7 +247,7 @@ public function testCountOnlineUsersFromSessionsVerifiesQuery(): void
247247
return true;
248248
});
249249

250-
$resultMock = $this->createMock(stdClass::class);
250+
$resultMock = $this->createStub(stdClass::class);
251251
$resultMock->cnt = 5;
252252
$this->mockDb->method('fetchObject')->willReturn($resultMock);
253253

@@ -269,7 +269,7 @@ public function testCountOnlineUsersFromFaqUserVerifiesQuery(): void
269269
return true;
270270
});
271271

272-
$resultMock = $this->createMock(stdClass::class);
272+
$resultMock = $this->createStub(stdClass::class);
273273
$resultMock->cnt = 3;
274274
$this->mockDb->method('fetchObject')->willReturn($resultMock);
275275

0 commit comments

Comments
 (0)