Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
/**
3
 * Mockery
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://github.com/padraic/mockery/blob/master/LICENSE
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to padraic@php.net so we can send you a copy immediately.
14
 *
15
 * @category   Mockery
16
 * @package    Mockery
17
 * @copyright  Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
18
 * @license    http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
19
 */
20
 
21
namespace Mockery\Generator;
22
 
23
use Mockery\Reflector;
24
 
25
class Parameter
26
{
27
    /** @var int */
28
    private static $parameterCounter = 0;
29
 
30
    /** @var \ReflectionParameter */
31
    private $rfp;
32
 
33
    public function __construct(\ReflectionParameter $rfp)
34
    {
35
        $this->rfp = $rfp;
36
    }
37
 
38
    public function __call($method, array $args)
39
    {
40
        return call_user_func_array(array($this->rfp, $method), $args);
41
    }
42
 
43
    /**
44
     * Get the reflection class for the parameter type, if it exists.
45
     *
46
     * This will be null if there was no type, or it was a scalar or a union.
47
     *
48
     * @return \ReflectionClass|null
49
     *
50
     * @deprecated since 1.3.3 and will be removed in 2.0.
51
     */
52
    public function getClass()
53
    {
54
        $typeHint = Reflector::getTypeHint($this->rfp, true);
55
 
56
        return \class_exists($typeHint) ? DefinedTargetClass::factory($typeHint, false) : null;
57
    }
58
 
59
    /**
60
     * Get the string representation for the paramater type.
61
     *
62
     * @return string|null
63
     */
64
    public function getTypeHint()
65
    {
66
        return Reflector::getTypeHint($this->rfp);
67
    }
68
 
69
    /**
70
     * Get the string representation for the paramater type.
71
     *
72
     * @return string
73
     *
74
     * @deprecated since 1.3.2 and will be removed in 2.0. Use getTypeHint() instead.
75
     */
76
    public function getTypeHintAsString()
77
    {
78
        return (string) Reflector::getTypeHint($this->rfp, true);
79
    }
80
 
81
    /**
82
     * Get the name of the parameter.
83
     *
84
     * Some internal classes have funny looking definitions!
85
     *
86
     * @return string
87
     */
88
    public function getName()
89
    {
90
        $name = $this->rfp->getName();
91
        if (!$name || $name == '...') {
92
            $name = 'arg' . self::$parameterCounter++;
93
        }
94
 
95
        return $name;
96
    }
97
 
98
    /**
99
     * Determine if the parameter is an array.
100
     *
101
     * @return bool
102
     */
103
    public function isArray()
104
    {
105
        return Reflector::isArray($this->rfp);
106
    }
107
 
108
    /**
109
     * Determine if the parameter is variadic.
110
     *
111
     * @return bool
112
     */
113
    public function isVariadic()
114
    {
115
        return $this->rfp->isVariadic();
116
    }
117
}