remove-comments-in-switch.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. $files = [
  12. __DIR__.'/../src/Carbon/Traits/Date.php',
  13. __DIR__.'/../src/Carbon/Traits/Units.php',
  14. __DIR__.'/../src/Carbon/Lang/fr.php',
  15. ];
  16. $comments = [
  17. '// @property',
  18. '// @call ',
  19. '// Words with feminine grammatical gender: semaine',
  20. ];
  21. foreach ($files as $file) {
  22. $contents = str_replace("\r", '', file_get_contents($file));
  23. $newContents = implode("\n", array_filter(explode("\n", $contents), static function ($line) use ($comments) {
  24. $code = trim($line);
  25. foreach ($comments as $comment) {
  26. if (str_starts_with($code, $comment)) {
  27. return false;
  28. }
  29. }
  30. return true;
  31. }));
  32. if ($newContents !== $contents) {
  33. file_put_contents($file, $newContents);
  34. }
  35. }