Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Intl] Refactored Locale component into two new components Icu and Intl

  • Loading branch information...
commit 5917a2e0cb1857eda21a4ee7d8060f1106aaf6e3 1 parent a7c9863
Bernhard Schussek webmozart authored
Showing with 15,304 additions and 266 deletions.
  1. +0 −2  .travis.yml
  2. +0 −4 autoload.php.dist
  3. +5 −2 composer.json
  4. +3 −0  src/Symfony/Component/Intl/.gitignore
  5. +91 −0 src/Symfony/Component/Intl/CONTRIBUTING.md
  6. +284 −0 src/Symfony/Component/Intl/Collator/StubCollator.php
  7. +46 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php
  8. +59 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php
  9. +46 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
  10. +46 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php
  11. +356 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
  12. +62 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php
  13. +62 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php
  14. +61 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php
  15. +64 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php
  16. +30 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php
  17. +48 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php
  18. +143 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php
  19. +64 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php
  20. +48 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php
  21. +99 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php
  22. +64 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
  23. +50 −0 src/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php
  24. +601 −0 src/Symfony/Component/Intl/DateFormatter/StubIntlDateFormatter.php
  25. +21 −0 src/Symfony/Component/Intl/Exception/BadMethodCallException.php
  26. +21 −0 src/Symfony/Component/Intl/Exception/ExceptionInterface.php
  27. +21 −0 src/Symfony/Component/Intl/Exception/InvalidArgumentException.php
  28. +32 −0 src/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php
  29. +41 −0 src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php
  30. +28 −0 src/Symfony/Component/Intl/Exception/MethodNotImplementedException.php
  31. +32 −0 src/Symfony/Component/Intl/Exception/NotImplementedException.php
  32. +21 −0 src/Symfony/Component/Intl/Exception/OutOfBoundsException.php
  33. +21 −0 src/Symfony/Component/Intl/Exception/RuntimeException.php
  34. +137 −0 src/Symfony/Component/Intl/Globals/StubIntlGlobals.php
  35. +332 −0 src/Symfony/Component/Intl/Intl.php
  36. +19 −0 src/Symfony/Component/Intl/LICENSE
  37. +317 −0 src/Symfony/Component/Intl/Locale/StubLocale.php
  38. +869 −0 src/Symfony/Component/Intl/NumberFormatter/StubNumberFormatter.php
  39. +195 −0 src/Symfony/Component/Intl/README.md
  40. +71 −0 src/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php
  41. +69 −0 src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php
  42. +29 −0 src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php
  43. +82 −0 src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php
  44. +71 −0 src/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php
  45. +99 −0 src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php
  46. +60 −0 src/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php
  47. +44 −0 src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php
  48. +39 −0 src/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php
  49. +42 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php
  50. +51 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php
  51. +63 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedReader.php
  52. +40 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php
  53. +61 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php
  54. +113 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php
  55. +49 −0 src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php
  56. +44 −0 src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php
  57. +39 −0 src/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php
  58. +27 −0 src/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php
  59. +26 −0 src/Symfony/Component/Intl/ResourceBundle/Stub/StubCurrencyBundle.php
  60. +26 −0 src/Symfony/Component/Intl/ResourceBundle/Stub/StubLanguageBundle.php
  61. +26 −0 src/Symfony/Component/Intl/ResourceBundle/Stub/StubLocaleBundle.php
  62. +26 −0 src/Symfony/Component/Intl/ResourceBundle/Stub/StubRegionBundle.php
  63. +96 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php
  64. +97 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php
  65. +56 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php
  66. +93 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php
  67. +70 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php
  68. +251 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php
  69. +69 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php
  70. +70 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php
  71. +80 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php
  72. +46 −0 src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php
  73. +79 −0 src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php
  74. +33 −0 src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php
  75. +88 −0 src/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php
  76. +29 −0 src/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php
  77. +50 −0 src/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php
  78. +202 −0 src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php
  79. +69 −0 src/Symfony/Component/Intl/Resources/bin/common.php
  80. +18 −0 src/Symfony/Component/Intl/Resources/bin/icu-version.php
  81. +7 −7 src/Symfony/Component/{Locale/Resources/data → Intl/Resources/bin}/icu.ini
  82. +150 −0 src/Symfony/Component/Intl/Resources/bin/update-icu-component.php
  83. +95 −0 src/Symfony/Component/Intl/Resources/bin/update-stubs.php
  84. +1,773 −0 src/Symfony/Component/Intl/Resources/data/curr/en.php
  85. +707 −0 src/Symfony/Component/Intl/Resources/data/lang/en.php
  86. +279 −0 src/Symfony/Component/Intl/Resources/data/locales/en.php
  87. +272 −0 src/Symfony/Component/Intl/Resources/data/region/en.php
  88. +1 −0  src/Symfony/Component/Intl/Resources/data/version.txt
  89. +4 −4 src/Symfony/Component/{Locale → Intl}/Resources/stubs/Collator.php
  90. +4 −4 src/Symfony/Component/{Locale → Intl}/Resources/stubs/IntlDateFormatter.php
  91. +4 −4 src/Symfony/Component/{Locale → Intl}/Resources/stubs/Locale.php
  92. +4 −4 src/Symfony/Component/{Locale → Intl}/Resources/stubs/NumberFormatter.php
  93. +80 −0 src/Symfony/Component/Intl/Resources/stubs/functions.php
  94. +63 −0 src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php
  95. +109 −0 src/Symfony/Component/Intl/Tests/Collator/StubCollatorTest.php
  96. +37 −0 src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php
  97. +965 −0 src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php
  98. +221 −0 src/Symfony/Component/Intl/Tests/DateFormatter/StubIntlDateFormatterTest.php
  99. +64 −0 src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php
  100. +43 −0 src/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php
  101. +22 −0 src/Symfony/Component/Intl/Tests/Globals/StubIntlGlobalsTest.php
  102. +36 −0 src/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php
  103. +68 −0 src/Symfony/Component/Intl/Tests/IntlTestCase.php
  104. +32 −0 src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php
  105. +159 −0 src/Symfony/Component/Intl/Tests/Locale/StubLocaleTest.php
  106. +38 −0 src/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php
  107. +718 −0 src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
  108. +231 −0 src/Symfony/Component/Intl/Tests/NumberFormatter/StubNumberFormatterTest.php
  109. +54 −0 src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php
  110. +55 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php
  111. +98 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php
  112. +197 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php
  113. +66 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php
  114. +64 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php
  115. +55 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php
  116. +14 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php
  117. BIN  src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res
  118. +3 −0  src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt
  119. +63 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php
  120. +223 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php
  121. +64 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php
  122. +101 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php
  123. +23 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php
  124. BIN  src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res
  125. +23 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt
  126. +62 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php
  127. +67 −0 src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php
  128. +111 −0 src/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php
  129. +87 −0 src/Symfony/Component/Intl/Tests/Util/VersionTest.php
  130. +105 −0 src/Symfony/Component/Intl/Util/IcuVersion.php
  131. +66 −0 src/Symfony/Component/Intl/Util/SvnCommit.php
  132. +149 −0 src/Symfony/Component/Intl/Util/SvnRepository.php
  133. +96 −0 src/Symfony/Component/Intl/Util/Version.php
  134. +48 −0 src/Symfony/Component/Intl/composer.json
  135. +29 −0 src/Symfony/Component/Intl/phpunit.xml.dist
  136. +0 −6 src/Symfony/Component/Locale/.gitignore
  137. +9 −14 src/Symfony/Component/Locale/Exception/MethodArgumentNotImplementedException.php
  138. +9 −23 src/Symfony/Component/Locale/Exception/MethodArgumentValueNotImplementedException.php
  139. +10 −11 src/Symfony/Component/Locale/Exception/MethodNotImplementedException.php
  140. +9 −14 src/Symfony/Component/Locale/Exception/NotImplementedException.php
  141. +24 −132 src/Symfony/Component/Locale/Locale.php
  142. +2 −35 src/Symfony/Component/Locale/README.md
  143. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/af.res
  144. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/agq.res
  145. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ak.res
  146. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/am.res
  147. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ar.res
  148. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/as.res
  149. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/asa.res
  150. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/az.res
  151. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/az_AZ.res
  152. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/az_Cyrl.res
  153. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/az_Latn.res
  154. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/az_Latn_AZ.res
  155. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bas.res
  156. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/be.res
  157. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bem.res
  158. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bez.res
  159. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bg.res
  160. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bm.res
  161. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bn.res
  162. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bn_IN.res
  163. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bo.res
  164. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/br.res
  165. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/brx.res
  166. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/bs.res
  167. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ca.res
  168. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/cgg.res
  169. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/chr.res
  170. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/cs.res
  171. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/cy.res
  172. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/da.res
  173. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/dav.res
  174. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/de.res
  175. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/de_CH.res
  176. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/dje.res
  177. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/dua.res
  178. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/dyo.res
  179. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ebu.res
  180. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ee.res
  181. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/el.res
  182. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/en.res
  183. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/en_RH.res
  184. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/en_ZW.res
  185. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/eo.res
  186. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/es.res
  187. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/es_419.res
  188. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/es_CL.res
  189. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/et.res
  190. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/eu.res
  191. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ewo.res
  192. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fa.res
  193. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fa_AF.res
  194. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ff.res
  195. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fi.res
  196. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fil.res
  197. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fil_PH.res
  198. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fo.res
  199. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fr.res
  200. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/fr_CA.res
  201. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ga.res
  202. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/gl.res
  203. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/gsw.res
  204. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/gu.res
  205. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/guz.res
  206. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/gv.res
  207. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha.res
  208. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_GH.res
  209. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_Latn.res
  210. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_Latn_GH.res
  211. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_Latn_NE.res
  212. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_Latn_NG.res
  213. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_NE.res
  214. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ha_NG.res
  215. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/haw.res
  216. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/he.res
  217. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/he_IL.res
  218. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/hi.res
  219. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/hr.res
  220. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/hu.res
  221. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/hy.res
  222. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/id.res
  223. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/id_ID.res
  224. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ig.res
  225. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ii.res
  226. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/in.res
  227. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/in_ID.res
  228. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/is.res
  229. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/it.res
  230. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/iw.res
  231. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/iw_IL.res
  232. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ja.res
  233. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ja_JP.res
  234. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ja_JP_TRADITIONAL.res
  235. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/jmc.res
  236. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ka.res
  237. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kab.res
  238. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kam.res
  239. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kde.res
  240. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kea.res
  241. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/khq.res
  242. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ki.res
  243. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kk.res
  244. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kk_Cyrl.res
  245. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kk_Cyrl_KZ.res
  246. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kk_KZ.res
  247. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kl.res
  248. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kln.res
  249. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/km.res
  250. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kn.res
  251. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ko.res
  252. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kok.res
  253. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ksb.res
  254. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ksf.res
  255. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/kw.res
  256. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/lag.res
  257. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/lg.res
  258. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ln.res
  259. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/lt.res
  260. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/lu.res
  261. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/luo.res
  262. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/luy.res
  263. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/lv.res
  264. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mas.res
  265. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mer.res
  266. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mfe.res
  267. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mg.res
  268. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mgh.res
  269. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mk.res
  270. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ml.res
  271. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mo.res
  272. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mr.res
  273. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ms.res
  274. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mt.res
  275. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/mua.res
  276. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/my.res
  277. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/naq.res
  278. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nb.res
  279. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nb_NO.res
  280. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nd.res
  281. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/ne.res
  282. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nl.res
  283. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nl_BE.res
  284. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nmg.res
  285. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nn.res
  286. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nn_NO.res
  287. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/no.res
  288. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/no_NO.res
  289. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/no_NO_NY.res
  290. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nus.res
  291. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/nyn.res
  292. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/om.res
  293. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/or.res
  294. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa.res
  295. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa_Arab.res
  296. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa_Arab_PK.res
  297. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa_Guru.res
  298. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa_Guru_IN.res
  299. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa_IN.res
  300. BIN  src/Symfony/Component/Locale/Resources/data/49/lang/pa_PK.res
Sorry, we could not display the entire diff because too many files (1,361) changed.
2  .travis.yml
View
@@ -14,5 +14,3 @@ before_script:
- echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
- - php src/Symfony/Component/Locale/Resources/data/build-data.php
- - export USE_INTL_ICU_DATA_VERSION=1
4 autoload.php.dist
View
@@ -10,8 +10,4 @@ $loader = require_once __DIR__.'/vendor/autoload.php';
use Doctrine\Common\Annotations\AnnotationRegistry;
-if (!function_exists('intl_get_error_code')) {
- require_once __DIR__.'/src/Symfony/Component/Locale/Resources/stubs/functions.php';
-}
-
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
7 composer.json
View
@@ -17,6 +17,7 @@
],
"require": {
"php": ">=5.3.3",
+ "symfony/icu": ">=1.0",
"doctrine/common": "~2.2",
"twig/twig": "~1.11",
"psr/log": "~1.0"
@@ -37,6 +38,7 @@
"symfony/framework-bundle": "self.version",
"symfony/http-foundation": "self.version",
"symfony/http-kernel": "self.version",
+ "symfony/intl": "self.version",
"symfony/locale": "self.version",
"symfony/monolog-bridge": "self.version",
"symfony/options-resolver": "self.version",
@@ -68,8 +70,9 @@
"psr-0": { "Symfony\\": "src/" },
"classmap": [
"src/Symfony/Component/HttpFoundation/Resources/stubs",
- "src/Symfony/Component/Locale/Resources/stubs"
- ]
+ "src/Symfony/Component/Intl/Resources/stubs"
+ ],
+ "files": [ "src/Symfony/Component/Intl/Resources/stubs/functions.php" ]
},
"minimum-stability": "dev",
"extra": {
3  src/Symfony/Component/Intl/.gitignore
View
@@ -0,0 +1,3 @@
+vendor/
+composer.lock
+phpunit.xml
91 src/Symfony/Component/Intl/CONTRIBUTING.md
View
@@ -0,0 +1,91 @@
+Contributing to the Intl component
+==================================
+
+A very good way of contributing to the Intl component is by updating the
+included data for the ICU version you have installed on your system.
+
+Preparation
+-----------
+
+To prepare, you need to install the development dependencies of the component.
+
+ $ cd /path/to/Symfony/Component/Intl
+ $ composer.phar install --dev
+
+Determining your ICU version
+---------------------------
+
+The ICU version installed in your PHP environment can be found by running
+icu-version.php:
+
+ $ php Resources/bin/icu-version.php
+
+Updating the ICU data
+---------------------
+
+To update the data files, run the update-icu-component.php script:
+
+ $ php Resources/bin/update-icu-component.php
+
+The script needs the binaries "svn" and "make" to be available on your system.
+It will download the latest version of the ICU sources for the ICU version
+installed in your PHP environment. The script will then compile the "genrb"
+binary and use it to compile the ICU data files to binaries. The binaries are
+copied to the Resources/ directory of the Icu component found in the
+vendor/symfony/icu/ directory.
+
+Updating the stub data
+----------------------
+
+In the previous step you updated the Icu component for the ICU version
+installed on your system. If you are using the latest ICU version, you should
+also create the stub data files which will be used by people who don't have
+the intl extension installed.
+
+To update the stub files, run the update-stubs.php script:
+
+ $ php Resources/bin/update-stubs.php
+
+The script will fail if you don't have the latest ICU version. If you want to
+upgrade the ICU version, adjust the return value of the
+`Intl::getStubIcuVersion()` before you run the script.
+
+The script creates copies of the binary resource bundles in the Icu component
+and stores them in the Resources/ directory of the Intl component. The copies
+are made for the locale "en" only and are stored in .php files, so that they
+can be read even if the intl extension is not available.
+
+Creating a pull request
+-----------------------
+
+You need to create up to two pull requests:
+
+* If you updated the Icu component, you need to push that change and create a
+ pull request in the `symfony/Icu` repository. Make sure to submit the pull
+ request to the correct master branch. If you updated the ICU data for version
+ 4.8, your pull request goes to branch `48-master`, for version 49 to
+ `49-master` and so on.
+
+* If you updated the stub files of the Intl component, you need to push that
+ change and create a pull request in the `symfony/symfony` repository. The
+ pull request should be based on the `master` branch.
+
+Combining .res files to a .dat-package
+--------------------------------------
+
+The individual *.res files can be combined into a single .dat-file.
+Unfortunately, PHP's `ResourceBundle` class is currently not able to handle
+.dat-files.
+
+Once it is, the following steps have to be followed to build the .dat-file:
+
+1. Package the resource bundles into a single file
+
+ $ find . -name *.res | sed -e "s/\.\///g" > packagelist.txt
+ $ pkgdata -p region -T build -d . packagelist.txt
+
+2. Clean up
+
+ $ rm -rf build packagelist.txt
+
+3. You can now move region.dat to replace the version bundled with Symfony2.
284 src/Symfony/Component/Intl/Collator/StubCollator.php
View
@@ -0,0 +1,284 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\Collator;
+
+use Symfony\Component\Intl\Exception\MethodNotImplementedException;
+use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
+use Symfony\Component\Intl\Globals\StubIntlGlobals;
+use Symfony\Component\Intl\Locale\StubLocale;
+
+/**
+ * Provides a stub Collator for the 'en' locale.
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class StubCollator
+{
+ /** Attribute constants */
+ const FRENCH_COLLATION = 0;
+ const ALTERNATE_HANDLING = 1;
+ const CASE_FIRST = 2;
+ const CASE_LEVEL = 3;
+ const NORMALIZATION_MODE = 4;
+ const STRENGTH = 5;
+ const HIRAGANA_QUATERNARY_MODE = 6;
+ const NUMERIC_COLLATION = 7;
+
+ /** Attribute constants values */
+ const DEFAULT_VALUE = -1;
+
+ const PRIMARY = 0;
+ const SECONDARY = 1;
+ const TERTIARY = 2;
+ const DEFAULT_STRENGTH = 2;
+ const QUATERNARY = 3;
+ const IDENTICAL = 15;
+
+ const OFF = 16;
+ const ON = 17;
+
+ const SHIFTED = 20;
+ const NON_IGNORABLE = 21;
+
+ const LOWER_FIRST = 24;
+ const UPPER_FIRST = 25;
+
+ /** Sorting options */
+ const SORT_REGULAR = 0;
+ const SORT_NUMERIC = 2;
+ const SORT_STRING = 1;
+
+ /**
+ * Constructor
+ *
+ * @param string $locale The locale code
+ *
+ * @throws MethodArgumentValueNotImplementedException When $locale different than 'en' is passed
+ */
+ public function __construct($locale)
+ {
+ if ('en' != $locale) {
+ throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the \'en\' locale is supported');
+ }
+ }
+
+ /**
+ * Static constructor
+ *
+ * @param string $locale The locale code
+ *
+ * @return StubCollator
+ *
+ * @throws MethodArgumentValueNotImplementedException When $locale different than 'en' is passed
+ */
+ public static function create($locale)
+ {
+ return new self($locale);
+ }
+
+ /**
+ * Sort array maintaining index association
+ *
+ * @param array &$array Input array
+ * @param integer $sortFlag Flags for sorting, can be one of the following:
+ * StubCollator::SORT_REGULAR - compare items normally (don't change types)
+ * StubCollator::SORT_NUMERIC - compare items numerically
+ * StubCollator::SORT_STRING - compare items as strings
+ *
+ * @return Boolean True on success or false on failure
+ */
+ public function asort(&$array, $sortFlag = self::SORT_REGULAR)
+ {
+ $intlToPlainFlagMap = array(
+ self::SORT_REGULAR => \SORT_REGULAR,
+ self::SORT_NUMERIC => \SORT_NUMERIC,
+ self::SORT_STRING => \SORT_STRING,
+ );
+
+ $plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR;
+
+ return asort($array, $plainSortFlag);
+ }
+
+ /**
+ * Compare two Unicode strings
+ *
+ * @param string $str1 The first string to compare
+ * @param string $str2 The second string to compare
+ *
+ * @return Boolean|int Return the comparison result or false on failure:
+ * 1 if $str1 is greater than $str2
+ * 0 if $str1 is equal than $str2
+ * -1 if $str1 is less than $str2
+ *
+ * @see http://www.php.net/manual/en/collator.compare.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function compare($str1, $str2)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Get a value of an integer collator attribute
+ *
+ * @param int $attr An attribute specifier, one of the attribute constants
+ *
+ * @return Boolean|int The attribute value on success or false on error
+ *
+ * @see http://www.php.net/manual/en/collator.getattribute.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function getAttribute($attr)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Returns collator's last error code. Always returns the U_ZERO_ERROR class constant value
+ *
+ * @return int The error code from last collator call
+ */
+ public function getErrorCode()
+ {
+ return StubIntlGlobals::U_ZERO_ERROR;
+ }
+
+ /**
+ * Returns collator's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value
+ *
+ * @return string The error message from last collator call
+ */
+ public function getErrorMessage()
+ {
+ return 'U_ZERO_ERROR';
+ }
+
+ /**
+ * Returns the collator's locale
+ *
+ * @param int $type The locale name type to return between valid or actual (StubLocale::VALID_LOCALE or StubLocale::ACTUAL_LOCALE, respectively)
+ *
+ * @return string The locale name used to create the collator
+ */
+ public function getLocale($type = StubLocale::ACTUAL_LOCALE)
+ {
+ return 'en';
+ }
+
+ /**
+ * Get sorting key for a string
+ *
+ * @param string $string The string to produce the key from
+ *
+ * @return string The collation key for $string
+ *
+ * @see http://www.php.net/manual/en/collator.getsortkey.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function getSortKey($string)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Get current collator's strength
+ *
+ * @return Boolean|int The current collator's strength or false on failure
+ *
+ * @see http://www.php.net/manual/en/collator.getstrength.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function getStrength()
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Set a collator's attribute
+ *
+ * @param int $attr An attribute specifier, one of the attribute constants
+ * @param int $val The attribute value, one of the attribute value constants
+ *
+ * @return Boolean True on success or false on failure
+ *
+ * @see http://www.php.net/manual/en/collator.setattribute.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function setAttribute($attr, $val)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Set the collator's strength
+ *
+ * @param int $strength Strength to set, possible values:
+ * StubCollator::PRIMARY
+ * StubCollator::SECONDARY
+ * StubCollator::TERTIARY
+ * StubCollator::QUATERNARY
+ * StubCollator::IDENTICAL
+ * StubCollator::DEFAULT
+ *
+ * @return Boolean True on success or false on failure
+ *
+ * @see http://www.php.net/manual/en/collator.setstrength.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function setStrength($strength)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Sort array using specified collator and sort keys
+ *
+ * @param array &$arr Array of strings to sort
+ *
+ * @return Boolean True on success or false on failure
+ *
+ * @see http://www.php.net/manual/en/collator.sortwithsortkeys.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function sortWithSortKeys(&$arr)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+
+ /**
+ * Sort array using specified collator
+ *
+ * @param array &$arr Array of string to sort
+ * @param int $sortFlag Optional sorting type, one of the following:
+ * StubCollator::SORT_REGULAR
+ * StubCollator::SORT_NUMERIC
+ * StubCollator::SORT_STRING
+ *
+ * @return Boolean True on success or false on failure
+ *
+ * @see http://www.php.net/manual/en/collator.sort.php
+ *
+ * @throws MethodNotImplementedException
+ */
+ public function sort(&$arr, $sortFlag = self::SORT_REGULAR)
+ {
+ throw new MethodNotImplementedException(__METHOD__);
+ }
+}
46 src/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php
View
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for AM/PM markers format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class AmPmTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ return $dateTime->format('A');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return 'AM|PM';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'marker' => $matched
+ );
+ }
+}
59 src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php
View
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for day of week format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class DayOfWeekTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $dayOfWeek = $dateTime->format('l');
+ switch ($length) {
+ case 4:
+ return $dayOfWeek;
+ case 5:
+ return $dayOfWeek[0];
+ default:
+ return substr($dayOfWeek, 0, 3);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ switch ($length) {
+ case 4:
+ return 'Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday';
+ case 5:
+ return '[MTWFS]';
+ default:
+ return 'Mon|Tue|Wed|Thu|Fri|Sat|Sun';
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array();
+ }
+}
46 src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
View
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for day of year format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class DayOfYearTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $dayOfYear = $dateTime->format('z') + 1;
+
+ return $this->padLeft($dayOfYear, $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return '\d{'.$length.'}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array();
+ }
+}
46 src/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php
View
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for day format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class DayTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ return $this->padLeft($dateTime->format('j'), $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'day' => (int) $matched,
+ );
+ }
+}
356 src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
View
@@ -0,0 +1,356 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+use Symfony\Component\Intl\Exception\NotImplementedException;
+use Symfony\Component\Intl\Globals\StubIntlGlobals;
+use Symfony\Component\Intl\DateFormatter\DateFormat\MonthTransformer;
+
+/**
+ * Parser and formatter for date formats
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class FullTransformer
+{
+ private $quoteMatch = "'(?:[^']+|'')*'";
+ private $implementedChars = 'MLydQqhDEaHkKmsz';
+ private $notImplementedChars = 'GYuwWFgecSAZvVW';
+ private $regExp;
+
+ /**
+ * @var Transformer[]
+ */
+ private $transformers;
+
+ private $pattern;
+ private $timezone;
+
+ /**
+ * Constructor
+ *
+ * @param string $pattern The pattern to be used to format and/or parse values
+ * @param string $timezone The timezone to perform the date/time calculations
+ */
+ public function __construct($pattern, $timezone)
+ {
+ $this->pattern = $pattern;
+ $this->timezone = $timezone;
+
+ $implementedCharsMatch = $this->buildCharsMatch($this->implementedChars);
+ $notImplementedCharsMatch = $this->buildCharsMatch($this->notImplementedChars);
+ $this->regExp = "/($this->quoteMatch|$implementedCharsMatch|$notImplementedCharsMatch)/";
+
+ $this->transformers = array(
+ 'M' => new MonthTransformer(),
+ 'L' => new MonthTransformer(),
+ 'y' => new YearTransformer(),
+ 'd' => new DayTransformer(),
+ 'q' => new QuarterTransformer(),
+ 'Q' => new QuarterTransformer(),
+ 'h' => new Hour1201Transformer(),
+ 'D' => new DayOfYearTransformer(),
+ 'E' => new DayOfWeekTransformer(),
+ 'a' => new AmPmTransformer(),
+ 'H' => new Hour2400Transformer(),
+ 'K' => new Hour1200Transformer(),
+ 'k' => new Hour2401Transformer(),
+ 'm' => new MinuteTransformer(),
+ 's' => new SecondTransformer(),
+ 'z' => new TimeZoneTransformer(),
+ );
+ }
+
+ /**
+ * Return the array of Transformer objects
+ *
+ * @return Transformer[] Associative array of Transformer objects (format char => Transformer)
+ */
+ public function getTransformers()
+ {
+ return $this->transformers;
+ }
+
+ /**
+ * Format a DateTime using ICU dateformat pattern
+ *
+ * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
+ *
+ * @return string The formatted value
+ */
+ public function format(\DateTime $dateTime)
+ {
+ $that = $this;
+
+ $formatted = preg_replace_callback($this->regExp, function($matches) use ($that, $dateTime) {
+ return $that->formatReplace($matches[0], $dateTime);
+ }, $this->pattern);
+
+ return $formatted;
+ }
+
+ /**
+ * Return the formatted ICU value for the matched date characters
+ *
+ * @param string $dateChars The date characters to be replaced with a formatted ICU value
+ * @param DateTime $dateTime A DateTime object to be used to generate the formatted value
+ *
+ * @return string The formatted value
+ *
+ * @throws NotImplementedException When it encounters a not implemented date character
+ */
+ public function formatReplace($dateChars, $dateTime)
+ {
+ $length = strlen($dateChars);
+
+ if ($this->isQuoteMatch($dateChars)) {
+ return $this->replaceQuoteMatch($dateChars);
+ }
+
+ if (isset($this->transformers[$dateChars[0]])) {
+ $transformer = $this->transformers[$dateChars[0]];
+
+ return $transformer->format($dateTime, $length);
+ }
+
+ // handle unimplemented characters
+ if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
+ throw new NotImplementedException(sprintf("Unimplemented date character '%s' in format '%s'", $dateChars[0], $this->pattern));
+ }
+ }
+
+ /**
+ * Parse a pattern based string to a timestamp value
+ *
+ * @param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
+ * @param string $value String to convert to a time value
+ *
+ * @return int The corresponding Unix timestamp
+ *
+ * @throws \InvalidArgumentException When the value can not be matched with pattern
+ */
+ public function parse(\DateTime $dateTime, $value)
+ {
+ $reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
+ $reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';
+
+ $options = array();
+
+ if (preg_match($reverseMatchingRegExp, $value, $matches)) {
+ $matches = $this->normalizeArray($matches);
+
+ foreach ($this->transformers as $char => $transformer) {
+ if (isset($matches[$char])) {
+ $length = strlen($matches[$char]['pattern']);
+ $options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
+ }
+ }
+
+ // reset error code and message
+ StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
+
+ return $this->calculateUnixTimestamp($dateTime, $options);
+ }
+
+ // behave like the intl extension
+ StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
+
+ return false;
+ }
+
+ /**
+ * Retrieve a regular expression to match with a formatted value.
+ *
+ * @param string $pattern The pattern to create the reverse matching regular expression
+ *
+ * @return string The reverse matching regular expression with named captures being formed by the
+ * transformer index in the $transformer array
+ */
+ public function getReverseMatchingRegExp($pattern)
+ {
+ $that = $this;
+
+ $escapedPattern = preg_quote($pattern, '/');
+
+ // ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
+ // when parsing a date/time value
+ $escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
+
+ $reverseMatchingRegExp = preg_replace_callback($this->regExp, function($matches) use ($that) {
+ $length = strlen($matches[0]);
+ $transformerIndex = $matches[0][0];
+
+ $dateChars = $matches[0];
+ if ($that->isQuoteMatch($dateChars)) {
+ return $that->replaceQuoteMatch($dateChars);
+ }
+
+ $transformers = $that->getTransformers();
+ if (isset($transformers[$transformerIndex])) {
+ $transformer = $transformers[$transformerIndex];
+ $captureName = str_repeat($transformerIndex, $length);
+
+ return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
+ }
+ }, $escapedPattern);
+
+ return $reverseMatchingRegExp;
+ }
+
+ /**
+ * Check if the first char of a string is a single quote
+ *
+ * @param string $quoteMatch The string to check
+ *
+ * @return Boolean true if matches, false otherwise
+ */
+ public function isQuoteMatch($quoteMatch)
+ {
+ return ("'" === $quoteMatch[0]);
+ }
+
+ /**
+ * Replaces single quotes at the start or end of a string with two single quotes
+ *
+ * @param string $quoteMatch The string to replace the quotes
+ *
+ * @return string A string with the single quotes replaced
+ */
+ public function replaceQuoteMatch($quoteMatch)
+ {
+ if (preg_match("/^'+$/", $quoteMatch)) {
+ return str_replace("''", "'", $quoteMatch);
+ }
+
+ return str_replace("''", "'", substr($quoteMatch, 1, -1));
+ }
+
+ /**
+ * Builds a chars match regular expression
+ *
+ * @param string $specialChars A string of chars to build the regular expression
+ *
+ * @return string The chars match regular expression
+ */
+ protected function buildCharsMatch($specialChars)
+ {
+ $specialCharsArray = str_split($specialChars);
+
+ $specialCharsMatch = implode('|', array_map(function($char) {
+ return $char.'+';
+ }, $specialCharsArray));
+
+ return $specialCharsMatch;
+ }
+
+ /**
+ * Normalize a preg_replace match array, removing the numeric keys and returning an associative array
+ * with the value and pattern values for the matched Transformer
+ *
+ * @param array $data
+ *
+ * @return array
+ */
+ protected function normalizeArray(array $data)
+ {
+ $ret = array();
+
+ foreach ($data as $key => $value) {
+ if (!is_string($key)) {
+ continue;
+ }
+
+ $ret[$key[0]] = array(
+ 'value' => $value,
+ 'pattern' => $key
+ );
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Calculates the Unix timestamp based on the matched values by the reverse matching regular
+ * expression of parse()
+ *
+ * @param \DateTime $dateTime The DateTime object to be used to calculate the timestamp
+ * @param array $options An array with the matched values to be used to calculate the timestamp
+ *
+ * @return Boolean|int The calculated timestamp or false if matched date is invalid
+ */
+ protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
+ {
+ $options = $this->getDefaultValueForOptions($options);
+
+ $year = $options['year'];
+ $month = $options['month'];
+ $day = $options['day'];
+ $hour = $options['hour'];
+ $hourInstance = $options['hourInstance'];
+ $minute = $options['minute'];
+ $second = $options['second'];
+ $marker = $options['marker'];
+ $timezone = $options['timezone'];
+
+ // If month is false, return immediately (intl behavior)
+ if (false === $month) {
+ StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
+
+ return false;
+ }
+
+ // Normalize hour
+ if ($hourInstance instanceof HourTransformer) {
+ $hour = $hourInstance->normalizeHour($hour, $marker);
+ }
+
+ // Set the timezone if different from the default one
+ if (null !== $timezone && $timezone !== $this->timezone) {
+ $dateTime->setTimezone(new \DateTimeZone($timezone));
+ }
+
+ // Normalize yy year
+ preg_match_all($this->regExp, $this->pattern, $matches);
+ if (in_array('yy', $matches[0])) {
+ $dateTime->setTimestamp(time());
+ $year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
+ }
+
+ $dateTime->setDate($year, $month, $day);
+ $dateTime->setTime($hour, $minute, $second);
+
+ return $dateTime->getTimestamp();
+ }
+
+ /**
+ * Add sensible default values for missing items in the extracted date/time options array. The values
+ * are base in the beginning of the Unix era
+ *
+ * @param array $options
+ *
+ * @return array
+ */
+ private function getDefaultValueForOptions(array $options)
+ {
+ return array(
+ 'year' => isset($options['year']) ? $options['year'] : 1970,
+ 'month' => isset($options['month']) ? $options['month'] : 1,
+ 'day' => isset($options['day']) ? $options['day'] : 1,
+ 'hour' => isset($options['hour']) ? $options['hour'] : 0,
+ 'hourInstance' => isset($options['hourInstance']) ? $options['hourInstance'] : null,
+ 'minute' => isset($options['minute']) ? $options['minute'] : 0,
+ 'second' => isset($options['second']) ? $options['second'] : 0,
+ 'marker' => isset($options['marker']) ? $options['marker'] : null,
+ 'timezone' => isset($options['timezone']) ? $options['timezone'] : null,
+ );
+ }
+}
62 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php
View
@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for 12 hour format (0-11)
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class Hour1200Transformer extends HourTransformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $hourOfDay = $dateTime->format('g');
+ $hourOfDay = '12' == $hourOfDay ? '0' : $hourOfDay;
+
+ return $this->padLeft($hourOfDay, $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function normalizeHour($hour, $marker = null)
+ {
+ if ('PM' === $marker) {
+ $hour += 12;
+ }
+
+ return $hour;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return '\d{1,2}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'hour' => (int) $matched,
+ 'hourInstance' => $this
+ );
+ }
+}
62 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php
View
@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for 12 hour format (1-12)
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class Hour1201Transformer extends HourTransformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ return $this->padLeft($dateTime->format('g'), $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function normalizeHour($hour, $marker = null)
+ {
+ if ('PM' !== $marker && 12 === $hour) {
+ $hour = 0;
+ } elseif ('PM' === $marker && 12 !== $hour) {
+ // If PM and hour is not 12 (1-12), sum 12 hour
+ $hour += 12;
+ }
+
+ return $hour;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return '\d{1,2}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'hour' => (int) $matched,
+ 'hourInstance' => $this
+ );
+ }
+}
61 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php
View
@@ -0,0 +1,61 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for 24 hour format (0-23)
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class Hour2400Transformer extends HourTransformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ return $this->padLeft($dateTime->format('G'), $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function normalizeHour($hour, $marker = null)
+ {
+ if ('AM' == $marker) {
+ $hour = 0;
+ } elseif ('PM' == $marker) {
+ $hour = 12;
+ }
+
+ return $hour;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return '\d{1,2}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'hour' => (int) $matched,
+ 'hourInstance' => $this
+ );
+ }
+}
64 src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php
View
@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for 24 hour format (1-24)
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class Hour2401Transformer extends HourTransformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $hourOfDay = $dateTime->format('G');
+ $hourOfDay = ('0' == $hourOfDay) ? '24' : $hourOfDay;
+
+ return $this->padLeft($hourOfDay, $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function normalizeHour($hour, $marker = null)
+ {
+ if ((null === $marker && 24 === $hour) || 'AM' == $marker) {
+ $hour = 0;
+ } elseif ('PM' == $marker) {
+ $hour = 12;
+ }
+
+ return $hour;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return '\d{1,2}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'hour' => (int) $matched,
+ 'hourInstance' => $this
+ );
+ }
+}
30 src/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php
View
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Base class for hour transformers
+ *
+ * @author Eriksen Costa <eriksen.costa@infranology.com.br>
+ */
+abstract class HourTransformer extends Transformer
+{
+ /**
+ * Returns a normalized hour value suitable for the hour transformer type
+ *
+ * @param int $hour The hour value
+ * @param string $marker An optional AM/PM marker
+ *
+ * @return int The normalized hour value
+ */
+ abstract public function normalizeHour($hour, $marker = null);
+}
48 src/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php
View
@@ -0,0 +1,48 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for minute format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class MinuteTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $minuteOfHour = (int) $dateTime->format('i');
+
+ return $this->padLeft($minuteOfHour, $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'minute' => (int) $matched,
+ );
+ }
+}
143 src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php
View
@@ -0,0 +1,143 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for month format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class MonthTransformer extends Transformer
+{
+ /**
+ * @var array
+ */
+ protected static $months = array(
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December'
+ );
+
+ /**
+ * Short months names (first 3 letters)
+ * @var array
+ */
+ protected static $shortMonths = array();
+
+ /**
+ * Flipped $months array, $name => $index
+ * @var array
+ */
+ protected static $flippedMonths = array();
+
+ /**
+ * Flipped $shortMonths array, $name => $index
+ * @var array
+ */
+ protected static $flippedShortMonths = array();
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ if (0 === count(self::$shortMonths)) {
+ self::$shortMonths = array_map(function($month) {
+ return substr($month, 0, 3);
+ }, self::$months);
+
+ self::$flippedMonths = array_flip(self::$months);
+ self::$flippedShortMonths = array_flip(self::$shortMonths);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $matchLengthMap = array(
+ 1 => 'n',
+ 2 => 'm',
+ 3 => 'M',
+ 4 => 'F',
+ );
+
+ if (isset($matchLengthMap[$length])) {
+ return $dateTime->format($matchLengthMap[$length]);
+ }
+
+ if (5 === $length) {
+ return substr($dateTime->format('M'), 0, 1);
+ }
+
+ return $this->padLeft($dateTime->format('m'), $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ switch ($length) {
+ case 1:
+ $regExp = '\d{1,2}';
+ break;
+ case 3:
+ $regExp = implode('|', self::$shortMonths);
+ break;
+ case 4:
+ $regExp = implode('|', self::$months);
+ break;
+ case 5:
+ $regExp = '[JFMASOND]';
+ break;
+ default:
+ $regExp = '\d{'.$length.'}';
+ break;
+ }
+
+ return $regExp;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ if (!is_numeric($matched)) {
+ if (3 === $length) {
+ $matched = self::$flippedShortMonths[$matched] + 1;
+ } elseif (4 === $length) {
+ $matched = self::$flippedMonths[$matched] + 1;
+ } elseif (5 === $length) {
+ // IntlDateFormatter::parse() always returns false for MMMMM or LLLLL
+ $matched = false;
+ }
+ } else {
+ $matched = (int) $matched;
+ }
+
+ return array(
+ 'month' => $matched,
+ );
+ }
+}
64 src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php
View
@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for quarter format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class QuarterTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $month = (int) $dateTime->format('n');
+ $quarter = (int) floor(($month - 1) / 3) + 1;
+ switch ($length) {
+ case 1:
+ case 2:
+ return $this->padLeft($quarter, $length);
+ case 3:
+ return 'Q'.$quarter;
+ default:
+ $map = array(1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter');
+
+ return $map[$quarter];
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ switch ($length) {
+ case 1:
+ case 2:
+ return '\d{'.$length.'}';
+ case 3:
+ return 'Q\d';
+ default:
+ return '(?:1st|2nd|3rd|4th) quarter';
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array();
+ }
+}
48 src/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php
View
@@ -0,0 +1,48 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for the second format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class SecondTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $secondOfMinute = (int) $dateTime->format('s');
+
+ return $this->padLeft($secondOfMinute, $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'second' => (int) $matched,
+ );
+ }
+}
99 src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php
View
@@ -0,0 +1,99 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+use Symfony\Component\Intl\Exception\NotImplementedException;
+
+/**
+ * Parser and formatter for time zone format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class TimeZoneTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @throws NotImplementedException When time zone is different than UTC or GMT (Etc/GMT)
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ $timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
+
+ if (!in_array($timeZone, array('Etc', 'UTC'))) {
+ throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
+ }
+
+ // From ICU >= 4.8, the zero offset is not more used, example: GMT instead of GMT+00:00
+ $format = (0 !== (int) $dateTime->format('O')) ? '\G\M\TP' : '\G\M\T';
+
+ return $dateTime->format($format);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return 'GMT[+-]\d{2}:?\d{2}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'timezone' => self::getEtcTimeZoneId($matched)
+ );
+ }
+
+ /**
+ * Get an Etc/GMT timezone identifier for the specified timezone
+ *
+ * The PHP documentation for timezones states to not use the 'Other' time zones because them exists
+ * "for backwards compatibility". However all Etc/GMT time zones are in the tz database 'etcetera' file,
+ * which indicates they are not deprecated (neither are old names).
+ *
+ * Only GMT, Etc/Universal, Etc/Zulu, Etc/Greenwich, Etc/GMT-0, Etc/GMT+0 and Etc/GMT0 are old names and
+ * are linked to Etc/GMT or Etc/UTC.
+ *
+ * @param string $formattedTimeZone A GMT timezone string (GMT-03:00, e.g.)
+ *
+ * @return string A timezone identifier
+ *
+ * @see http://php.net/manual/en/timezones.others.php
+ * @see http://www.twinsun.com/tz/tz-link.htm
+ *
+ * @throws NotImplementedException When the GMT time zone have minutes offset different than zero
+ * @throws \InvalidArgumentException When the value can not be matched with pattern
+ */
+ public static function getEtcTimeZoneId($formattedTimeZone)
+ {
+ if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
+ $hours = (int) $matches['hours'];
+ $minutes = (int) $matches['minutes'];
+ $signal = $matches['signal'] == '-' ? '+' : '-';
+
+ if (0 < $minutes) {
+ throw new NotImplementedException(sprintf(
+ 'It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.',
+ $formattedTimeZone
+ ));
+ }
+
+ return 'Etc/GMT'.($hours !== 0 ? $signal.$hours : '');
+ }
+
+ throw new \InvalidArgumentException('The GMT time zone \'%s\' does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.');
+ }
+}
64 src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
View
@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for date formats
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+abstract class Transformer
+{
+ /**
+ * Format a value using a configured DateTime as date/time source
+ *
+ *
+ * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
+ * @param int $length The formatted value string length
+ *
+ * @return string The formatted value
+ */
+ abstract public function format(\DateTime $dateTime, $length);
+
+ /**
+ * Returns a reverse matching regular expression of a string generated by format()
+ *
+ * @param int $length The length of the value to be reverse matched
+ *
+ * @return string The reverse matching regular expression
+ */
+ abstract public function getReverseMatchingRegExp($length);
+
+ /**
+ * Extract date options from a matched value returned by the processing of the reverse matching
+ * regular expression
+ *
+ * @param string $matched The matched value
+ * @param int $length The length of the Transformer pattern string
+ *
+ * @return array An associative array
+ */
+ abstract public function extractDateOptions($matched, $length);
+
+ /**
+ * Pad a string with zeros to the left
+ *
+ * @param string $value The string to be padded
+ * @param int $length The length to pad
+ *
+ * @return string The padded string
+ */
+ protected function padLeft($value, $length)
+ {
+ return str_pad($value, $length, '0', STR_PAD_LEFT);
+ }
+}
50 src/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php
View
@@ -0,0 +1,50 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter\DateFormat;
+
+/**
+ * Parser and formatter for year format
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class YearTransformer extends Transformer
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function format(\DateTime $dateTime, $length)
+ {
+ if (2 === $length) {
+ return $dateTime->format('y');
+ }
+
+ return $this->padLeft($dateTime->format('Y'), $length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getReverseMatchingRegExp($length)
+ {
+ return 2 === $length ? '\d{2}' : '\d{4}';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function extractDateOptions($matched, $length)
+ {
+ return array(
+ 'year' => (int) $matched,
+ );
+ }
+}
601 src/Symfony/Component/Intl/DateFormatter/StubIntlDateFormatter.php
View
@@ -0,0 +1,601 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Intl\DateFormatter;
+
+use Symfony\Component\Intl\Globals\StubIntlGlobals;
+use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer;
+use Symfony\Component\Intl\Exception\MethodNotImplementedException;
+use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
+use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
+use Symfony\Component\Intl\Locale\StubLocale;
+
+/**
+ * Provides a stub IntlDateFormatter for the 'en' locale.
+ *
+ * @author Igor Wiedler <igor@wiedler.ch>
+ */
+class StubIntlDateFormatter
+{
+ /**
+ * The error code from the last operation
+ *
+ * @var integer
+ */
+ protected $errorCode = StubIntlGlobals::U_ZERO_ERROR;
+
+ /**
+ * The error message from the last operation
+ *
+ * @var string
+ */
+ protected $errorMessage = 'U_ZERO_ERROR';
+
+ /* date/time format types */
+ const NONE = -1;
+ const FULL = 0;
+ const LONG = 1;
+ const MEDIUM = 2;
+ const SHORT = 3;
+
+ /* calendar formats */
+ const TRADITIONAL = 0;
+ const GREGORIAN = 1;
+
+ /**
+ * Patterns used to format the date when no pattern is provided
+ *
+ * @var array
+ */
+ private $defaultDateFormats = array(
+ self::NONE => '',
+ self::FULL => 'EEEE, LLLL d, y',
+ self::LONG => 'LLLL d, y',
+ self::MEDIUM => 'LLL d, y',
+ self::SHORT => 'M/d/yy',
+ );
+
+ /**
+ * Patterns used to format the time when no pattern is provided
+ *
+ * @var array
+ */
+ private $defaultTimeFormats = array(
+ self::FULL => 'h:mm:ss a zzzz',
+ self::LONG => 'h:mm:ss a z',
+ self::MEDIUM => 'h:mm:ss a',
+ self::SHORT => 'h:mm a',
+ );
+
+ /**
+ * @var int
+ */
+ private $datetype;
+
+ /**
+ * @var int
+ */
+ private $timetype;
+
+ /**
+ * @var string
+ */
+ private $pattern;
+
+ /**
+ * @var \DateTimeZone
+ */
+ private $dateTimeZone;
+
+ /**
+ * @var Boolean
+ */
+ private $unitializedTimeZoneId = false;
+
+ /**
+ * @var string
+ */
+ private $timeZoneId;
+
+ /**
+ * Constructor
+ *
+ * @param string $locale The locale code
+ * @param int $datetype Type of date formatting, one of the format type constants
+ * @param int $timetype Type of time formatting, one of the format type constants
+ * @param string $timezone Timezone identifier
+ * @param int $calendar Calendar to use for formatting or parsing; default is Gregorian.
+ * One of the calendar constants.
+ * @param string $pattern Optional pattern to use when formatting
+ *
+ * @see http://www.php.net/manual/en/intldateformatter.create.php
+ * @see http://userguide.icu-project.org/formatparse/datetime
+ *
+ * @throws MethodArgumentValueNotImplementedException When $locale different than 'en' is passed
+ * @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
+ */
+ public function __construct($locale, $datetype, $timetype, $timezone = null, $calendar = self::GREGORIAN, $pattern = null)
+ {
+ if ('en' !== $locale) {
+ throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the \'en\' locale is supported');
+ }
+
+ if (self::GREGORIAN !== $calendar) {
+ throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
+ }
+
+ $this->datetype = $datetype;
+ $this->timetype = $timetype;
+
+ $this->setPattern($pattern);
+ $this->setTimeZoneId($timezone);
+ }
+
+ /**
+ * Static constructor
+ *