1 | <?php |
||
39 | class CaptchaAction extends Action |
||
40 | { |
||
41 | /** |
||
42 | * The name of the GET parameter indicating whether the CAPTCHA image should be regenerated. |
||
43 | */ |
||
44 | const REFRESH_GET_VAR = 'refresh'; |
||
45 | |||
46 | /** |
||
47 | * @var int how many times should the same CAPTCHA be displayed. Defaults to 3. |
||
48 | * A value less than or equal to 0 means the test is unlimited. |
||
49 | */ |
||
50 | public $testLimit = 3; |
||
51 | /** |
||
52 | * @var string the fixed verification code. When this property is set, |
||
53 | * [[getVerifyCode()]] will always return the value of this property. |
||
54 | * This is mainly used in automated tests where we want to be able to reproduce |
||
55 | * the same verification code each time we run the tests. |
||
56 | * If not set, it means the verification code will be randomly generated. |
||
57 | */ |
||
58 | public $fixedVerifyCode; |
||
59 | /** |
||
60 | * @var DriverInterface|array|string the driver to be used for CAPTCHA rendering. It could be either an instance |
||
61 | * of [[DriverInterface]] or its DI compatible configuration. |
||
62 | * For example: |
||
63 | * |
||
64 | * ```php |
||
65 | * [ |
||
66 | * 'class' => \yii\captcha\ImagickDriver::class, |
||
67 | * // 'backColor' => 0xFFFFFF, |
||
68 | * // 'foreColor' => 0x2040A0, |
||
69 | * ] |
||
70 | * ``` |
||
71 | * |
||
72 | * After the action object is created, if you want to change this property, you should assign it |
||
73 | * with a [[DriverInterface]] object only. |
||
74 | * @since 2.1.0 |
||
75 | */ |
||
76 | public $driver; |
||
77 | |||
78 | |||
79 | /** |
||
80 | * Initializes the action. |
||
81 | * @throws InvalidConfigException if the font file does not exist. |
||
82 | */ |
||
83 | 2 | public function init() |
|
88 | |||
89 | /** |
||
90 | * Runs the action. |
||
91 | */ |
||
92 | 2 | public function run() |
|
112 | |||
113 | /** |
||
114 | * Generates a hash code that can be used for client-side validation. |
||
115 | * @param string $code the CAPTCHA code |
||
116 | * @return string a hash code generated from the CAPTCHA code |
||
117 | */ |
||
118 | 1 | public function generateValidationHash($code) |
|
126 | |||
127 | /** |
||
128 | * Gets the verification code. |
||
129 | * @param bool $regenerate whether the verification code should be regenerated. |
||
130 | * @return string the verification code. |
||
131 | */ |
||
132 | 2 | public function getVerifyCode($regenerate = false) |
|
148 | |||
149 | /** |
||
150 | * Validates the input to see if it matches the generated code. |
||
151 | * @param string $input user input |
||
152 | * @param bool $caseSensitive whether the comparison should be case-sensitive |
||
153 | * @return bool whether the input is valid |
||
154 | */ |
||
155 | public function validate($input, $caseSensitive) |
||
169 | |||
170 | /** |
||
171 | * Returns the session variable name used to store verification code. |
||
172 | * @return string the session variable name |
||
173 | */ |
||
174 | 2 | protected function getSessionKey() |
|
178 | |||
179 | /** |
||
180 | * Sets the HTTP headers needed by image response. |
||
181 | */ |
||
182 | 1 | protected function setHttpHeaders() |
|
191 | } |
||
192 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: