StdinFileInfo.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS;
  11. /**
  12. * @author Davi Koscianski Vidal <davividal@gmail.com>
  13. */
  14. class StdinFileInfo extends \SplFileInfo
  15. {
  16. public function __construct()
  17. {
  18. }
  19. public function __toString()
  20. {
  21. return $this->getContents();
  22. }
  23. public function getRealpath()
  24. {
  25. // So file_get_contents & friends will work.
  26. return 'php://stdin';
  27. }
  28. public function getContents()
  29. {
  30. return file_get_contents($this->getRealpath());
  31. }
  32. public function getATime()
  33. {
  34. return 0;
  35. }
  36. public function getBasename($suffix = null)
  37. {
  38. return $this->getFilename();
  39. }
  40. public function getCTime()
  41. {
  42. return 0;
  43. }
  44. public function getExtension()
  45. {
  46. return '.php';
  47. }
  48. public function getFileInfo($class_name = null)
  49. {
  50. throw new \RuntimeException('Not implemented');
  51. }
  52. public function getFilename()
  53. {
  54. /*
  55. * Useful so fixers depending on PHP-only files still work.
  56. *
  57. * The idea to use STDIN is to parse PHP-only files, so we can
  58. * assume that there will be always a PHP file out there.
  59. */
  60. return 'stdin.php';
  61. }
  62. public function getGroup()
  63. {
  64. return 0;
  65. }
  66. public function getInode()
  67. {
  68. return 0;
  69. }
  70. public function getLinkTarget()
  71. {
  72. return '';
  73. }
  74. public function getMTime()
  75. {
  76. return 0;
  77. }
  78. public function getOwner()
  79. {
  80. return 0;
  81. }
  82. public function getPath()
  83. {
  84. return '';
  85. }
  86. public function getPathInfo($class_name = null)
  87. {
  88. throw new \RuntimeException('Not implemented');
  89. }
  90. public function getPathname()
  91. {
  92. return $this->getFilename();
  93. }
  94. public function getPerms()
  95. {
  96. return 0;
  97. }
  98. public function getSize()
  99. {
  100. return 0;
  101. }
  102. public function getType()
  103. {
  104. return 'file';
  105. }
  106. public function isDir()
  107. {
  108. return false;
  109. }
  110. public function isExecutable()
  111. {
  112. return false;
  113. }
  114. public function isFile()
  115. {
  116. return true;
  117. }
  118. public function isLink()
  119. {
  120. return false;
  121. }
  122. public function isReadable()
  123. {
  124. return true;
  125. }
  126. public function isWritable()
  127. {
  128. return false;
  129. }
  130. public function openFile($open_mode = 'r', $use_include_path = false, $context = null)
  131. {
  132. throw new \RuntimeException('Not implemented');
  133. }
  134. public function setFileClass($class_name = null)
  135. {
  136. }
  137. public function setInfoClass($class_name = null)
  138. {
  139. }
  140. }