1 | <?php |
||
7 | class Address |
||
8 | { |
||
9 | /** |
||
10 | * NO. |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | const NO = 0; |
||
15 | |||
16 | /** |
||
17 | * SUBNO. |
||
18 | * |
||
19 | * @var int |
||
20 | */ |
||
21 | const SUBNO = 1; |
||
22 | |||
23 | /** |
||
24 | * NAME. |
||
25 | * |
||
26 | * @var int |
||
27 | */ |
||
28 | const NAME = 2; |
||
29 | |||
30 | /** |
||
31 | * UNIT. |
||
32 | * |
||
33 | * @var int |
||
34 | */ |
||
35 | const UNIT = 3; |
||
36 | |||
37 | /** |
||
38 | * $normalizer. |
||
39 | * |
||
40 | * @var \Recca0120\Twzipcode\Normalizer |
||
41 | */ |
||
42 | public $normalizer; |
||
43 | |||
44 | /** |
||
45 | * $tokens. |
||
46 | * |
||
47 | * @var \Recca0120\Lodash\JArray |
||
48 | */ |
||
49 | public $tokens = []; |
||
50 | |||
51 | /** |
||
52 | * __construct. |
||
53 | * |
||
54 | * @param static|array $address |
||
55 | */ |
||
56 | 73 | public function __construct($address = '') |
|
62 | |||
63 | /** |
||
64 | * __toString. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 5 | public function __toString() |
|
72 | |||
73 | /** |
||
74 | * set. |
||
75 | * |
||
76 | * @param static|string $address |
||
77 | * @return $this |
||
78 | */ |
||
79 | 73 | public function set($address) |
|
80 | { |
||
81 | 73 | $this->normalizer = (new Normalizer($address)) |
|
|
|||
82 | 73 | ->normalize() |
|
83 | 73 | ->normalizeAddress(); |
|
84 | |||
85 | 73 | $this->tokens = $this->tokenize(); |
|
86 | |||
87 | 73 | return $this; |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * tokens. |
||
92 | * |
||
93 | * @return \Recca0120\Lodash\JArray |
||
94 | */ |
||
95 | 67 | public function tokens() |
|
99 | |||
100 | /** |
||
101 | * getPoint. |
||
102 | * |
||
103 | * @param string $index |
||
104 | * @return \Recca0120\Twzipcode\Point |
||
105 | */ |
||
106 | 37 | public function getPoint($index) |
|
107 | { |
||
108 | 37 | if (isset($this->tokens[$index]) === false) { |
|
109 | 9 | return new Point(0, 0); |
|
110 | } |
||
111 | 37 | $token = $this->tokens[$index]; |
|
112 | |||
113 | 37 | return new Point( |
|
114 | 37 | (int) $token[static::NO] ?: 0, |
|
115 | 37 | (int) str_replace('之', '', $token[static::SUBNO] ?: '0') |
|
116 | 37 | ); |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * flat. |
||
121 | * |
||
122 | * @param int $length |
||
123 | * @param int $offset |
||
124 | * @return string |
||
125 | */ |
||
126 | 7 | public function flat($length = null, $offset = 0) |
|
135 | |||
136 | /** |
||
137 | * tokenize. |
||
138 | * |
||
139 | * @return \Recca0120\Lodash\JArray |
||
140 | */ |
||
141 | 73 | protected function tokenize() |
|
248 | } |
||
249 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.