Skip to content

Commit ce7de2d

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
2 parents 323dee6 + 8255215 commit ce7de2d

File tree

14 files changed

+92
-1364
lines changed

14 files changed

+92
-1364
lines changed

system/Validation/StrictRules/CreditCardRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct()
4141
* 'cc_num' => 'valid_cc_number[visa]'
4242
* ];
4343
*
44-
* @param mixed $ccNumber
44+
* @param array|bool|float|int|object|string|null $ccNumber
4545
*/
4646
public function valid_cc_number($ccNumber, string $type): bool
4747
{

system/Validation/StrictRules/FormatRules.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct()
3030
/**
3131
* Alpha
3232
*
33-
* @param mixed $str
33+
* @param array|bool|float|int|object|string|null $str
3434
*/
3535
public function alpha($str = null): bool
3636
{
@@ -44,7 +44,7 @@ public function alpha($str = null): bool
4444
/**
4545
* Alpha with spaces.
4646
*
47-
* @param mixed $value Value.
47+
* @param array|bool|float|int|object|string|null $value Value.
4848
*
4949
* @return bool True if alpha with spaces, else false.
5050
*/
@@ -60,7 +60,7 @@ public function alpha_space($value = null): bool
6060
/**
6161
* Alphanumeric with underscores and dashes
6262
*
63-
* @param mixed $str
63+
* @param array|bool|float|int|object|string|null $str
6464
*/
6565
public function alpha_dash($str = null): bool
6666
{
@@ -82,7 +82,7 @@ public function alpha_dash($str = null): bool
8282
* _ underscore, + plus, = equals, | vertical bar, : colon, . period
8383
* ~ ! # $ % & * - _ + = | : .
8484
*
85-
* @param mixed $str
85+
* @param array|bool|float|int|object|string|null $str
8686
*
8787
* @return bool
8888
*/
@@ -102,7 +102,7 @@ public function alpha_numeric_punct($str)
102102
/**
103103
* Alphanumeric
104104
*
105-
* @param mixed $str
105+
* @param array|bool|float|int|object|string|null $str
106106
*/
107107
public function alpha_numeric($str = null): bool
108108
{
@@ -120,7 +120,7 @@ public function alpha_numeric($str = null): bool
120120
/**
121121
* Alphanumeric w/ spaces
122122
*
123-
* @param mixed $str
123+
* @param array|bool|float|int|object|string|null $str
124124
*/
125125
public function alpha_numeric_space($str = null): bool
126126
{
@@ -138,7 +138,7 @@ public function alpha_numeric_space($str = null): bool
138138
/**
139139
* Any type of string
140140
*
141-
* @param mixed $str
141+
* @param array|bool|float|int|object|string|null $str
142142
*/
143143
public function string($str = null): bool
144144
{
@@ -148,7 +148,7 @@ public function string($str = null): bool
148148
/**
149149
* Decimal number
150150
*
151-
* @param mixed $str
151+
* @param array|bool|float|int|object|string|null $str
152152
*/
153153
public function decimal($str = null): bool
154154
{
@@ -166,7 +166,7 @@ public function decimal($str = null): bool
166166
/**
167167
* String of hexidecimal characters
168168
*
169-
* @param mixed $str
169+
* @param array|bool|float|int|object|string|null $str
170170
*/
171171
public function hex($str = null): bool
172172
{
@@ -184,7 +184,7 @@ public function hex($str = null): bool
184184
/**
185185
* Integer
186186
*
187-
* @param mixed $str
187+
* @param array|bool|float|int|object|string|null $str
188188
*/
189189
public function integer($str = null): bool
190190
{
@@ -202,7 +202,7 @@ public function integer($str = null): bool
202202
/**
203203
* Is a Natural number (0,1,2,3, etc.)
204204
*
205-
* @param mixed $str
205+
* @param array|bool|float|int|object|string|null $str
206206
*/
207207
public function is_natural($str = null): bool
208208
{
@@ -220,7 +220,7 @@ public function is_natural($str = null): bool
220220
/**
221221
* Is a Natural number, but not a zero (1,2,3, etc.)
222222
*
223-
* @param mixed $str
223+
* @param array|bool|float|int|object|string|null $str
224224
*/
225225
public function is_natural_no_zero($str = null): bool
226226
{
@@ -238,7 +238,7 @@ public function is_natural_no_zero($str = null): bool
238238
/**
239239
* Numeric
240240
*
241-
* @param mixed $str
241+
* @param array|bool|float|int|object|string|null $str
242242
*/
243243
public function numeric($str = null): bool
244244
{
@@ -256,7 +256,7 @@ public function numeric($str = null): bool
256256
/**
257257
* Compares value against a regular expression pattern.
258258
*
259-
* @param mixed $str
259+
* @param array|bool|float|int|object|string|null $str
260260
*/
261261
public function regex_match($str, string $pattern): bool
262262
{
@@ -273,7 +273,7 @@ public function regex_match($str, string $pattern): bool
273273
*
274274
* @see http://php.net/manual/en/datetimezone.listidentifiers.php
275275
*
276-
* @param mixed $str
276+
* @param array|bool|float|int|object|string|null $str
277277
*/
278278
public function timezone($str = null): bool
279279
{
@@ -290,7 +290,7 @@ public function timezone($str = null): bool
290290
* Tests a string for characters outside of the Base64 alphabet
291291
* as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045
292292
*
293-
* @param mixed $str
293+
* @param array|bool|float|int|object|string|null $str
294294
*/
295295
public function valid_base64($str = null): bool
296296
{
@@ -304,7 +304,7 @@ public function valid_base64($str = null): bool
304304
/**
305305
* Valid JSON
306306
*
307-
* @param mixed $str
307+
* @param array|bool|float|int|object|string|null $str
308308
*/
309309
public function valid_json($str = null): bool
310310
{
@@ -318,7 +318,7 @@ public function valid_json($str = null): bool
318318
/**
319319
* Checks for a correctly formatted email address
320320
*
321-
* @param mixed $str
321+
* @param array|bool|float|int|object|string|null $str
322322
*/
323323
public function valid_email($str = null): bool
324324
{
@@ -335,7 +335,7 @@ public function valid_email($str = null): bool
335335
* Example:
336336
337337
*
338-
* @param mixed $str
338+
* @param array|bool|float|int|object|string|null $str
339339
*/
340340
public function valid_emails($str = null): bool
341341
{
@@ -349,8 +349,8 @@ public function valid_emails($str = null): bool
349349
/**
350350
* Validate an IP address (human readable format or binary string - inet_pton)
351351
*
352-
* @param mixed $ip
353-
* @param string|null $which IP protocol: 'ipv4' or 'ipv6'
352+
* @param array|bool|float|int|object|string|null $ip
353+
* @param string|null $which IP protocol: 'ipv4' or 'ipv6'
354354
*/
355355
public function valid_ip($ip = null, ?string $which = null): bool
356356
{
@@ -367,7 +367,7 @@ public function valid_ip($ip = null, ?string $which = null): bool
367367
* Warning: this rule will pass basic strings like
368368
* "banana"; use valid_url_strict for a stricter rule.
369369
*
370-
* @param mixed $str
370+
* @param array|bool|float|int|object|string|null $str
371371
*/
372372
public function valid_url($str = null): bool
373373
{
@@ -381,8 +381,8 @@ public function valid_url($str = null): bool
381381
/**
382382
* Checks a URL to ensure it's formed correctly.
383383
*
384-
* @param mixed $str
385-
* @param string|null $validSchemes comma separated list of allowed schemes
384+
* @param array|bool|float|int|object|string|null $str
385+
* @param string|null $validSchemes comma separated list of allowed schemes
386386
*/
387387
public function valid_url_strict($str = null, ?string $validSchemes = null): bool
388388
{
@@ -396,7 +396,7 @@ public function valid_url_strict($str = null, ?string $validSchemes = null): boo
396396
/**
397397
* Checks for a valid date and matches a given date format
398398
*
399-
* @param mixed $str
399+
* @param array|bool|float|int|object|string|null $str
400400
*/
401401
public function valid_date($str = null, ?string $format = null): bool
402402
{

tests/_support/View/SampleClassWithInitController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class SampleClassWithInitController
2525
{
26+
private ResponseInterface $response;
27+
2628
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
2729
{
2830
$this->response = $response;

tests/system/Database/Migrations/MigrationRunnerTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,16 @@ public function testSetNamespaceStoresValue()
222222

223223
public function testFindMigrationsReturnsEmptyArrayWithNoneFound()
224224
{
225-
$config = $this->config;
226-
$config->type = 'timestamp';
227-
225+
$config = $this->config;
228226
$runner = new MigrationRunner($config);
227+
229228
$this->assertSame([], $runner->findMigrations());
230229
}
231230

232231
public function testFindMigrationsSuccessTimestamp()
233232
{
234-
$config = $this->config;
235-
$config->type = 'timestamp';
236-
$runner = new MigrationRunner($config);
233+
$config = $this->config;
234+
$runner = new MigrationRunner($config);
237235

238236
$runner = $runner->setNamespace('Tests\Support\MigrationTestMigrations');
239237

tests/system/Filters/FiltersTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ public function testRunDoesBefore()
499499
$uri = 'admin/foo/bar';
500500
$request = $filters->run($uri, 'before');
501501

502-
$this->assertSame('http://google.com', $request->url);
502+
$this->assertSame('http://google.com', $request->getBody());
503503
}
504504

505505
public function testRunDoesAfter()
@@ -519,7 +519,7 @@ public function testRunDoesAfter()
519519
$uri = 'admin/foo/bar';
520520
$response = $filters->run($uri, 'after');
521521

522-
$this->assertSame('http://google.com', $response->csp);
522+
$this->assertSame('http://google.com', $response->getBody());
523523
}
524524

525525
public function testShortCircuit()
@@ -540,7 +540,7 @@ public function testShortCircuit()
540540
$response = $filters->run($uri, 'before');
541541

542542
$this->assertInstanceOf(ResponseInterface::class, $response);
543-
$this->assertSame('http://google.com', $response->csp);
543+
$this->assertSame('http://google.com', $response->getBody());
544544
}
545545

546546
public function testOtherResult()
@@ -1103,8 +1103,8 @@ public function testFilterAliasMultiple()
11031103
$uri = 'admin/foo/bar';
11041104
$request = $filters->run($uri, 'before');
11051105

1106-
$this->assertSame('http://exampleMultipleURL.com', $request->url);
1107-
$this->assertSame('http://exampleMultipleCSP.com', $request->csp);
1106+
$this->assertSame('http://exampleMultipleURL.com', $request->header('x-url')->getValue());
1107+
$this->assertSame('http://exampleMultipleCSP.com', $request->header('x-csp')->getValue());
11081108
}
11091109

11101110
public function testFilterClass()

tests/system/Filters/fixtures/GoogleMe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ class GoogleMe implements FilterInterface
1919
{
2020
public function before(RequestInterface $request, $arguments = null)
2121
{
22-
$request->url = 'http://google.com';
22+
$request->setBody('http://google.com');
2323

2424
return $request;
2525
}
2626

2727
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
2828
{
29-
$response->csp = 'http://google.com';
29+
$response->setBody('http://google.com');
3030

3131
return $response;
3232
}

tests/system/Filters/fixtures/GoogleYou.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class GoogleYou implements FilterInterface
2020
{
2121
public function before(RequestInterface $request, $arguments = null)
2222
{
23-
$response = Services::response();
24-
$response->csp = 'http://google.com';
23+
$response = Services::response();
24+
$response->setBody('http://google.com');
2525

2626
return $response;
2727
}

tests/system/Filters/fixtures/Multiple1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Multiple1 implements FilterInterface
1919
{
2020
public function before(RequestInterface $request, $arguments = null)
2121
{
22-
$request->csp = 'http://exampleMultipleCSP.com';
22+
$request->setHeader('x-csp', 'http://exampleMultipleCSP.com');
2323

2424
return $request;
2525
}

tests/system/Filters/fixtures/Multiple2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Multiple2 implements FilterInterface
1919
{
2020
public function before(RequestInterface $request, $arguments = null)
2121
{
22-
$request->url = 'http://exampleMultipleURL.com';
22+
$request->setHeader('x-url', 'http://exampleMultipleURL.com');
2323

2424
return $request;
2525
}

tests/system/Models/GeneralModelTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ public function testMagicGetters(): void
7171
$this->assertFalse(isset($this->model->foobar));
7272
$this->assertNull($this->model->foobar);
7373

74-
$this->model->flavor = 'chocolate';
75-
$this->assertTrue(isset($this->model->flavor));
76-
$this->assertSame('chocolate', $this->model->flavor);
77-
7874
// from DB
7975
$this->assertTrue(isset($this->model->DBPrefix));
8076
$this->assertSame('utf8', $this->model->charset);

tests/system/Models/ValidationModelTest.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,26 +238,25 @@ public function testValidationPassesWithMissingFields(): void
238238

239239
public function testValidationWithGroupName(): void
240240
{
241-
$config = new Validation();
241+
$config = new class () extends Validation {
242+
public $grouptest = [
243+
'name' => [
244+
'required',
245+
'min_length[3]',
246+
],
247+
'token' => 'in_list[{id}]',
248+
];
249+
};
250+
Factories::injectMock('config', 'Validation', $config);
242251

243-
$config->grouptest = [
244-
'name' => [
245-
'required',
246-
'min_length[3]',
247-
],
248-
'token' => 'in_list[{id}]',
249-
];
252+
$this->createModel(ValidModel::class);
253+
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
250254

251255
$data = [
252256
'name' => 'abc',
253257
'id' => 13,
254258
'token' => 13,
255259
];
256-
257-
Factories::injectMock('config', 'Validation', $config);
258-
259-
$this->createModel(ValidModel::class);
260-
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
261260
$this->assertTrue($this->model->validate($data));
262261
}
263262

0 commit comments

Comments
 (0)