1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- /*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace Symfony\CS\Fixer\PSR2;
- use Symfony\CS\FixerInterface;
- /**
- * @author Fabien Potencier <fabien@symfony.com>
- */
- class EofEndingFixer implements FixerInterface
- {
- /**
- * {@inheritdoc}
- */
- public function fix(\SplFileInfo $file, $content)
- {
- // [Structure] A file must always end with a linefeed character
- $content = rtrim($content);
- if (strlen($content)) {
- return $content."\n";
- }
- return $content;
- }
- /**
- * {@inheritdoc}
- */
- public function getLevel()
- {
- return FixerInterface::PSR2_LEVEL;
- }
- /**
- * {@inheritdoc}
- */
- public function getPriority()
- {
- // must run last to be sure the file is properly formatted before it runs
- return -50;
- }
- /**
- * {@inheritdoc}
- */
- public function supports(\SplFileInfo $file)
- {
- return true;
- }
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'eof_ending';
- }
- /**
- * {@inheritdoc}
- */
- public function getDescription()
- {
- return 'A file must always end with an empty line feed.';
- }
- }
|