PageRenderTime 23ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/PHP/CompatInfo/Reference/spl.php

http://github.com/llaville/php-compat-info
PHP | 281 lines | 184 code | 13 blank | 84 comment | 32 complexity | 9900f7fcaba38d3ee4ccf3c653254b89 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Version informations about SPL extension
  4. *
  5. * PHP version 5
  6. *
  7. * @category PHP
  8. * @package PHP_CompatInfo
  9. * @author Laurent Laville <pear@laurent-laville.org>
  10. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  11. * @version SVN: $Id$
  12. * @link http://php5.laurent-laville.org/compatinfo/
  13. */
  14. /**
  15. * All interfaces, classes, functions, constants about SPL extension
  16. *
  17. * @category PHP
  18. * @package PHP_CompatInfo
  19. * @author Laurent Laville <pear@laurent-laville.org>
  20. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  21. * @version Release: @package_version@
  22. * @link http://php5.laurent-laville.org/compatinfo/
  23. * @link http://www.php.net/manual/en/book.spl.php
  24. */
  25. class PHP_CompatInfo_Reference_SPL implements PHP_CompatInfo_Reference
  26. {
  27. /**
  28. * Gets all informations at once about:
  29. * extensions, interfaces, classes, functions, constants
  30. *
  31. * @param string $extension OPTIONAL
  32. * @param string $version OPTIONAL PHP version
  33. * (4 => only PHP4, 5 or null => PHP4 + PHP5)
  34. *
  35. * @return array
  36. */
  37. public function getAll($extension = null, $version = null)
  38. {
  39. $references = array(
  40. 'extensions' => $this->getExtensions($extension, $version),
  41. 'interfaces' => $this->getInterfaces($extension, $version),
  42. 'classes' => $this->getClasses($extension, $version),
  43. 'functions' => $this->getFunctions($extension, $version),
  44. 'constants' => $this->getConstants($extension, $version),
  45. );
  46. return $references;
  47. }
  48. /**
  49. * Gets informations about extensions
  50. *
  51. * @param string $extension OPTIONAL
  52. * @param string $version OPTIONAL PHP version
  53. * (4 => only PHP4, 5 or null => PHP4 + PHP5)
  54. *
  55. * @return array
  56. */
  57. public function getExtensions($extension = null, $version = null)
  58. {
  59. $extensions = array(
  60. 'SPL' => array('5.0.0', '', '0.2')
  61. );
  62. return $extensions;
  63. }
  64. /**
  65. * Gets informations about interfaces
  66. *
  67. * @param string $extension OPTIONAL
  68. * @param string $version OPTIONAL PHP version
  69. * (4 => only PHP4, 5 or null => PHP4 + PHP5)
  70. *
  71. * @return array
  72. * @link http://www.php.net/manual/en/spl.interfaces.php
  73. */
  74. public function getInterfaces($extension = null, $version = null)
  75. {
  76. $interfaces = array();
  77. if ((null == $version ) || ('4' == $version)) {
  78. $version4 = array(
  79. );
  80. $interfaces = array_merge(
  81. $interfaces,
  82. $version4
  83. );
  84. }
  85. if ((null == $version ) || ('5' == $version)) {
  86. $version5 = array(
  87. 'Countable' => array('5.1.0', ''),
  88. 'OuterIterator' => array('5.1.0', ''),
  89. 'RecursiveIterator' => array('5.1.0', ''),
  90. 'SeekableIterator' => array('5.1.0', ''),
  91. 'Traversable' => array('5.1.0', ''),
  92. 'Iterator' => array('5.1.0', ''),
  93. 'IteratorAggregate' => array('5.1.0', ''),
  94. 'ArrayAccess' => array('5.1.0', ''),
  95. 'Serializable' => array('5.1.0', ''),
  96. 'SplObserver' => array('5.1.0', ''),
  97. 'SplSubject' => array('5.1.0', ''),
  98. );
  99. $interfaces = array_merge(
  100. $interfaces,
  101. $version5
  102. );
  103. }
  104. return $interfaces;
  105. }
  106. /**
  107. * Gets informations about classes
  108. *
  109. * @param string $extension OPTIONAL
  110. * @param string $version OPTIONAL PHP version
  111. * (4 => only PHP4, 5 or null => PHP4 + PHP5)
  112. *
  113. * @return array
  114. * @link http://www.php.net/manual/en/spl.datastructures.php
  115. * @link http://www.php.net/manual/en/spl.iterators.php
  116. * @link http://www.php.net/manual/en/spl.exceptions.php
  117. * @link http://www.php.net/manual/en/spl.files.php
  118. */
  119. public function getClasses($extension = null, $version = null)
  120. {
  121. $classes = array();
  122. if ((null == $version ) || ('4' == $version)) {
  123. $version4 = array(
  124. );
  125. $classes = array_merge(
  126. $classes,
  127. $version4
  128. );
  129. }
  130. if ((null == $version ) || ('5' == $version)) {
  131. $version5 = array(
  132. 'Exception' => array('5.1.0', ''),
  133. 'ErrorException' => array('5.1.0', ''),
  134. 'LogicException' => array('5.1.0', ''),
  135. 'BadFunctionCallException' => array('5.1.0', ''),
  136. 'BadMethodCallException' => array('5.1.0', ''),
  137. 'DomainException' => array('5.1.0', ''),
  138. 'InvalidArgumentException' => array('5.1.0', ''),
  139. 'LengthException' => array('5.1.0', ''),
  140. 'OutOfRangeException' => array('5.1.0', ''),
  141. 'RuntimeException' => array('5.1.0', ''),
  142. 'OutOfBoundsException' => array('5.1.0', ''),
  143. 'OverflowException' => array('5.1.0', ''),
  144. 'RangeException' => array('5.1.0', ''),
  145. 'UnderflowException' => array('5.1.0', ''),
  146. 'UnexpectedValueException' => array('5.1.0', ''),
  147. 'RecursiveIteratorIterator' => array('5.1.3', ''),
  148. 'IteratorIterator' => array('5.1.0', ''),
  149. 'FilterIterator' => array('5.1.0', ''),
  150. 'RecursiveFilterIterator' => array('5.1.0', ''),
  151. 'CallbackFilterIterator' => array('5.4.0', ''),
  152. 'RecursiveCallbackFilterIterator'
  153. => array('5.4.0', ''),
  154. 'ParentIterator' => array('5.1.0', ''),
  155. 'LimitIterator' => array('5.1.0', ''),
  156. 'CachingIterator' => array('5.0.0', ''),
  157. 'RecursiveCachingIterator' => array('5.1.0', ''),
  158. 'NoRewindIterator' => array('5.1.0', ''),
  159. 'AppendIterator' => array('5.1.0', ''),
  160. 'InfiniteIterator' => array('5.1.0', ''),
  161. 'RegexIterator' => array('5.2.0', ''),
  162. 'RecursiveRegexIterator' => array('5.2.0', ''),
  163. 'EmptyIterator' => array('5.1.0', ''),
  164. 'RecursiveTreeIterator' => array('5.3.0', ''),
  165. 'ArrayObject' => array('5.0.0', ''),
  166. 'ArrayIterator' => array('5.0.0', ''),
  167. 'RecursiveArrayIterator' => array('5.1.0', ''),
  168. 'SplFileInfo' => array('5.1.2', ''),
  169. 'DirectoryIterator' => array('5.0.0', ''),
  170. 'FilesystemIterator' => array('5.3.0', ''),
  171. 'RecursiveDirectoryIterator' => array('5.1.2', ''),
  172. 'GlobIterator' => array('5.3.0', ''),
  173. 'SplFileObject' => array('5.1.0', ''),
  174. 'SplTempFileObject' => array('5.1.2', ''),
  175. 'SplDoublyLinkedList' => array('5.3.0', ''),
  176. 'SplQueue' => array('5.3.0', ''),
  177. 'SplStack' => array('5.3.0', ''),
  178. 'SplHeap' => array('5.3.0', ''),
  179. 'SplMinHeap' => array('5.3.0', ''),
  180. 'SplMaxHeap' => array('5.3.0', ''),
  181. 'SplPriorityQueue' => array('5.3.0', ''),
  182. 'SplFixedArray' => array('5.3.0', ''),
  183. 'SplObjectStorage' => array('5.1.0', ''),
  184. 'MultipleIterator' => array('5.3.0', ''),
  185. );
  186. $classes = array_merge(
  187. $classes,
  188. $version5
  189. );
  190. }
  191. return $classes;
  192. }
  193. /**
  194. * Gets informations about functions
  195. *
  196. * @param string $extension OPTIONAL
  197. * @param string $version OPTIONAL PHP version
  198. * (4 => only PHP4, 5 or null => PHP4 + PHP5)
  199. *
  200. * @return array
  201. * @link http://www.php.net/manual/en/ref.spl.php
  202. */
  203. public function getFunctions($extension = null, $version = null)
  204. {
  205. $functions = array();
  206. if ((null == $version ) || ('4' == $version)) {
  207. $version4 = array(
  208. );
  209. $functions = array_merge(
  210. $functions,
  211. $version4
  212. );
  213. }
  214. if ((null == $version ) || ('5' == $version)) {
  215. $version5 = array(
  216. 'spl_classes' => array('5.0.0', ''),
  217. 'spl_autoload' => array('5.1.2', ''),
  218. 'spl_autoload_extensions' => array('5.1.2', ''),
  219. 'spl_autoload_register' => array('5.1.2', ''),
  220. 'spl_autoload_unregister' => array('5.1.2', ''),
  221. 'spl_autoload_functions' => array('5.1.2', ''),
  222. 'spl_autoload_call' => array('5.1.2', ''),
  223. 'class_parents' => array('5.1.0', ''),
  224. 'class_uses' => array('5.4.0', ''),
  225. 'class_implements' => array('5.1.0', ''),
  226. 'spl_object_hash' => array('5.2.0', ''),
  227. 'iterator_to_array' => array('5.1.0', ''),
  228. 'iterator_count' => array('5.1.0', ''),
  229. 'iterator_apply' => array('5.1.0', ''),
  230. );
  231. $functions = array_merge(
  232. $functions,
  233. $version5
  234. );
  235. }
  236. return $functions;
  237. }
  238. /**
  239. * Gets informations about constants
  240. *
  241. * @param string $extension OPTIONAL
  242. * @param string $version OPTIONAL PHP version
  243. * (4 => only PHP4, 5 or null => PHP4 + PHP5)
  244. *
  245. * @return array
  246. */
  247. public function getConstants($extension = null, $version = null)
  248. {
  249. $constants = array();
  250. if ((null == $version ) || ('4' == $version)) {
  251. $version4 = array(
  252. );
  253. $constants = array_merge(
  254. $constants,
  255. $version4
  256. );
  257. }
  258. if ((null == $version ) || ('5' == $version)) {
  259. $version5 = array(
  260. );
  261. $constants = array_merge(
  262. $constants,
  263. $version5
  264. );
  265. }
  266. return $constants;
  267. }
  268. }