Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
OptionalParametersFilter.php
01 <?php
02 /**
03 * Zend Framework (http://framework.zend.com/)
04 *
05 * @link http://github.com/zendframework/zf2 for the canonical source repository
06 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
07 * @license http://framework.zend.com/license/new-bsd New BSD License
08 */
09 namespace Zend\Stdlib\Hydrator\Filter;
10
11 use InvalidArgumentException;
12 use ReflectionException;
13 use ReflectionMethod;
14 use ReflectionParameter;
15
16 /**
17 * Filter that includes methods which have no parameters or only optional parameters
18 */
19 class OptionalParametersFilter implements FilterInterface
20 {
21 /**
22 * Map of methods already analyzed
23 * by {@see \Zend\Stdlib\Hydrator\Filter\OptionalParametersFilter::filter()},
24 * cached for performance reasons
25 *
26 * @var bool[]
27 */
28 protected static $propertiesCache = array();
29
30 /**
31 * {@inheritDoc}
32 */
33 public function filter($property)
34 {
35 if (isset(static::$propertiesCache[$property])) {
36 return static::$propertiesCache[$property];
37 }
38
39 try {
40 $reflectionMethod = new ReflectionMethod($property);
41 } catch (ReflectionException $exception) {
42 throw new InvalidArgumentException(sprintf('Method %s doesn\'t exist', $property));
43 }
44
45 $mandatoryParameters = array_filter(
46 $reflectionMethod->getParameters(),
47 function (ReflectionParameter $parameter) {
48 return ! $parameter->isOptional();
49 }
50 );
51
52 return static::$propertiesCache[$property] = empty($mandatoryParameters);
53 }
54 }
55