Skip to content

Commit 5990062

Browse files
authored
Merge pull request #3296 from paulbalandan/phpdocs-filters
Fix PHPDocs for Filters
2 parents 249009a + be265fc commit 5990062

4 files changed

Lines changed: 82 additions & 15 deletions

File tree

system/Filters/CSRF.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class CSRF implements FilterInterface
7070
* @param RequestInterface|\CodeIgniter\HTTP\IncomingRequest $request
7171
*
7272
* @return mixed
73+
* @throws \CodeIgniter\Security\Exceptions\SecurityException
7374
*/
7475
public function before(RequestInterface $request)
7576
{

system/Filters/Exceptions/FilterException.php

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,72 @@
1-
<?php namespace CodeIgniter\Filters\Exceptions;
1+
<?php
2+
3+
/**
4+
* CodeIgniter
5+
*
6+
* An open source application development framework for PHP
7+
*
8+
* This content is released under the MIT License (MIT)
9+
*
10+
* Copyright (c) 2014-2019 British Columbia Institute of Technology
11+
* Copyright (c) 2019-2020 CodeIgniter Foundation
12+
*
13+
* Permission is hereby granted, free of charge, to any person obtaining a copy
14+
* of this software and associated documentation files (the "Software"), to deal
15+
* in the Software without restriction, including without limitation the rights
16+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
* copies of the Software, and to permit persons to whom the Software is
18+
* furnished to do so, subject to the following conditions:
19+
*
20+
* The above copyright notice and this permission notice shall be included in
21+
* all copies or substantial portions of the Software.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29+
* THE SOFTWARE.
30+
*
31+
* @package CodeIgniter
32+
* @author CodeIgniter Dev Team
33+
* @copyright 2019-2020 CodeIgniter Foundation
34+
* @license https://opensource.org/licenses/MIT MIT License
35+
* @link https://codeigniter.com
36+
* @since Version 4.0.0
37+
* @filesource
38+
*/
39+
40+
namespace CodeIgniter\Filters\Exceptions;
241

342
use CodeIgniter\Exceptions\ConfigException;
443
use CodeIgniter\Exceptions\ExceptionInterface;
544

45+
/**
46+
* FilterException
47+
*/
648
class FilterException extends ConfigException implements ExceptionInterface
749
{
50+
/**
51+
* Thrown when the provided alias is not within
52+
* the list of configured filter aliases.
53+
*
54+
* @param string $alias
55+
*
56+
* @return static
57+
*/
858
public static function forNoAlias(string $alias)
959
{
1060
return new static(lang('Filters.noFilter', [$alias]));
1161
}
1262

63+
/**
64+
* Thrown when the filter class does not implement FilterInterface.
65+
*
66+
* @param string $class
67+
*
68+
* @return static
69+
*/
1370
public static function forIncorrectInterface(string $class)
1471
{
1572
return new static(lang('Filters.incorrectInterface', [$class]));

system/Filters/Filters.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* CodeIgniter
45
*
@@ -38,7 +39,6 @@
3839

3940
namespace CodeIgniter\Filters;
4041

41-
use CodeIgniter\Config\BaseConfig;
4242
use CodeIgniter\Filters\Exceptions\FilterException;
4343
use CodeIgniter\HTTP\RequestInterface;
4444
use CodeIgniter\HTTP\ResponseInterface;
@@ -63,7 +63,7 @@ class Filters
6363
/**
6464
* The original config file
6565
*
66-
* @var BaseConfig
66+
* @var \Config\Filters
6767
*/
6868
protected $config;
6969

@@ -101,14 +101,14 @@ class Filters
101101
/**
102102
* Constructor.
103103
*
104-
* @param type $config
104+
* @param \Config\Filters $config
105105
* @param RequestInterface $request
106106
* @param ResponseInterface $response
107107
*/
108108
public function __construct($config, RequestInterface $request, ResponseInterface $response)
109109
{
110110
$this->config = $config;
111-
$this->request = & $request;
111+
$this->request = &$request;
112112
$this->setResponse($response);
113113
}
114114

@@ -119,7 +119,7 @@ public function __construct($config, RequestInterface $request, ResponseInterfac
119119
*/
120120
public function setResponse(ResponseInterface $response)
121121
{
122-
$this->response = & $response;
122+
$this->response = &$response;
123123
}
124124

125125
//--------------------------------------------------------------------
@@ -337,6 +337,8 @@ public function enableFilter(string $name, string $when = 'before')
337337
/**
338338
* Returns the arguments for a specified key, or all.
339339
*
340+
* @param string|null $key
341+
*
340342
* @return mixed
341343
*/
342344
public function getArguments(string $key = null)
@@ -352,8 +354,9 @@ public function getArguments(string $key = null)
352354
/**
353355
* Add any applicable (not excluded) global filter settings to the mix.
354356
*
355-
* @param string $uri
356-
* @return type
357+
* @param string $uri
358+
*
359+
* @return void
357360
*/
358361
protected function processGlobals(string $uri = null)
359362
{
@@ -369,6 +372,7 @@ protected function processGlobals(string $uri = null)
369372
'before',
370373
'after',
371374
];
375+
372376
foreach ($sets as $set)
373377
{
374378
if (isset($this->config->globals[$set]))
@@ -394,6 +398,7 @@ protected function processGlobals(string $uri = null)
394398
{
395399
$alias = $rules; // simple name of filter to apply
396400
}
401+
397402
if ($keep)
398403
{
399404
$this->filters[$set][] = $alias;
@@ -408,7 +413,7 @@ protected function processGlobals(string $uri = null)
408413
/**
409414
* Add any method-specific flters to the mix.
410415
*
411-
* @return type
416+
* @return void
412417
*/
413418
protected function processMethods()
414419
{
@@ -432,8 +437,9 @@ protected function processMethods()
432437
/**
433438
* Add any applicable configured filters to the mix.
434439
*
435-
* @param string $uri
436-
* @return type
440+
* @param string $uri
441+
*
442+
* @return void
437443
*/
438444
protected function processFilters(string $uri = null)
439445
{
@@ -456,6 +462,7 @@ protected function processFilters(string $uri = null)
456462
$this->filters['before'][] = $alias;
457463
}
458464
}
465+
459466
if (isset($settings['after']))
460467
{
461468
$path = $settings['after'];
@@ -470,9 +477,10 @@ protected function processFilters(string $uri = null)
470477
/**
471478
* Check paths for match for URI
472479
*
473-
* @param string $uri URI to test against
474-
* @param mixed $paths The path patterns to test
475-
* @return boolean True if any of the paths apply to the URI
480+
* @param string $uri URI to test against
481+
* @param mixed $paths The path patterns to test
482+
*
483+
* @return boolean True if any of the paths apply to the URI
476484
*/
477485
private function pathApplies(string $uri, $paths)
478486
{
@@ -501,6 +509,7 @@ private function pathApplies(string $uri, $paths)
501509
return true;
502510
}
503511
}
512+
504513
return false;
505514
}
506515

system/Filters/Honeypot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* CodeIgniter
45
*
@@ -56,7 +57,6 @@ class Honeypot implements FilterInterface
5657
* @param \CodeIgniter\HTTP\RequestInterface $request
5758
*
5859
* @return void
59-
*
6060
* @throws \CodeIgniter\Honeypot\Exceptions\HoneypotException
6161
*/
6262
public function before(RequestInterface $request)

0 commit comments

Comments
 (0)