These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.ec-cube.co.jp/ |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Eccube\Twig\Extension; |
||
15 | |||
16 | use Twig\Environment; |
||
17 | use Twig\Extension\AbstractExtension; |
||
18 | use Twig\TwigFilter; |
||
19 | |||
20 | class IntlExtension extends AbstractExtension |
||
21 | { |
||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 243 | public function getFilters() |
|
26 | { |
||
27 | return [ |
||
28 | 243 | new TwigFilter('date_day', [$this, 'date_day'], ['needs_environment' => true]), |
|
29 | 243 | new TwigFilter('date_min', [$this, 'date_min'], ['needs_environment' => true]), |
|
30 | 243 | new TwigFilter('date_sec', [$this, 'date_sec'], ['needs_environment' => true]), |
|
31 | 243 | new TwigFilter('date_day_with_weekday', [$this, 'date_day_with_weekday'], ['needs_environment' => true]), |
|
32 | ]; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * localizeddate('medium', 'none')のショートカット. |
||
37 | * |
||
38 | * 2015/08/28のように、日までのフォーマットで表示します(localeがjaの場合). |
||
39 | * null,空文字に対して利用した場合は、空文字を返却します. |
||
40 | * |
||
41 | * @param Environment $env |
||
42 | * @param $date |
||
43 | * |
||
44 | * @return bool|string |
||
45 | */ |
||
46 | 1 | public function date_day(Environment $env, $date) |
|
47 | { |
||
48 | 1 | if (!$date) { |
|
49 | return ''; |
||
50 | } |
||
51 | |||
52 | 1 | return \twig_localized_date_filter($env, $date, 'medium', 'none'); |
|
0 ignored issues
–
show
|
|||
53 | } |
||
54 | |||
55 | /** |
||
56 | * localizeddate('medium', 'short')のショートカット. |
||
57 | * |
||
58 | * 2015/08/28 16:13のように、分までのフォーマットで表示します(localeがjaの場合). |
||
59 | * null,空文字に対して利用した場合は、空文字を返却します. |
||
60 | * |
||
61 | * @param Environment $env |
||
62 | * @param $date |
||
63 | * |
||
64 | * @return bool|string |
||
65 | */ |
||
66 | 152 | public function date_min(Environment $env, $date) |
|
67 | { |
||
68 | 152 | if (!$date) { |
|
69 | 151 | return ''; |
|
70 | } |
||
71 | |||
72 | 8 | return \twig_localized_date_filter($env, $date, 'medium', 'short'); |
|
0 ignored issues
–
show
$env of type object<Twig\Environment> is not a sub-type of object<Twig_Environment> . It seems like you assume a child class of the class Twig\Environment to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.
Loading history...
|
|||
73 | } |
||
74 | |||
75 | /** |
||
76 | * localizeddate('medium', 'medium')のショートカット. |
||
77 | * |
||
78 | * 2015/08/28 16:13:05(localeがjaの場合). |
||
79 | * null,空文字に対して利用した場合は、空文字を返却します. |
||
80 | * |
||
81 | * @param Environment $env |
||
82 | * @param $date |
||
83 | * |
||
84 | * @return bool|string |
||
85 | */ |
||
86 | 5 | public function date_sec(Environment $env, $date) |
|
87 | { |
||
88 | 5 | if (!$date) { |
|
89 | 2 | return ''; |
|
90 | } |
||
91 | |||
92 | 4 | return \twig_localized_date_filter($env, $date, 'medium', 'medium'); |
|
0 ignored issues
–
show
$env of type object<Twig\Environment> is not a sub-type of object<Twig_Environment> . It seems like you assume a child class of the class Twig\Environment to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.
Loading history...
|
|||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @param Environment $env |
||
97 | * @param $date |
||
98 | * |
||
99 | * @return bool|string |
||
100 | */ |
||
101 | public function date_day_with_weekday(Environment $env, $date) |
||
102 | { |
||
103 | if (!$date) { |
||
104 | return ''; |
||
105 | } |
||
106 | |||
107 | $date_day = \twig_localized_date_filter($env, $date, 'medium', 'none'); |
||
0 ignored issues
–
show
$env of type object<Twig\Environment> is not a sub-type of object<Twig_Environment> . It seems like you assume a child class of the class Twig\Environment to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.
Loading history...
|
|||
108 | // 曜日 |
||
109 | $dateFormatter = \IntlDateFormatter::create( |
||
110 | 'ja_JP@calendar=japanese', |
||
111 | \IntlDateFormatter::FULL, |
||
112 | \IntlDateFormatter::FULL, |
||
113 | 'Asia/Tokyo', |
||
114 | \IntlDateFormatter::TRADITIONAL, |
||
115 | 'E' |
||
116 | ); |
||
117 | |||
118 | return $date_day.'('.$dateFormatter->format($date).')'; |
||
119 | } |
||
120 | } |
||
121 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.