Skip to content
Permalink
Browse files

Apply php-cs-fixer

  • Loading branch information...
K-Phoen committed Jan 3, 2016
1 parent 8387e4e commit 03428a40c465d23029370542113824ed6b453496
@@ -1,4 +1,3 @@
vendor
composer.lock
composer.phar
Tests/Fixtures/App/app/cache
/composer.lock
/vendor
/.php_cs.cache
10 .php_cs
@@ -3,6 +3,16 @@
return Symfony\CS\Config\Config::create()
->setUsingCache(true)
->level(Symfony\CS\FixerInterface::CONTRIB_LEVEL)
->fixers([
'-pre_increment',
'-empty_return',
'-align_double_arrow',
'-align_equals',
'-logical_not_operators_with_spaces',
'-logical_not_operators_with_successor_space',
'-ordered_use',
'-phpdoc_var_to_type',
])
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
@@ -50,7 +50,7 @@ public function clearHandle()
*/
public function dump($string)
{
if ($this->handle == null) {
if ($this->handle === null) {
$this->openFile();
}
@@ -11,6 +11,6 @@ class GzFile extends File
{
public function __construct($filename)
{
parent::__construct('compress.zlib://'.$filename);
parent::__construct('compress.zlib://' . $filename);
}
}
@@ -90,7 +90,7 @@ public function getLastmod()
return null;
}
if ($this->getChangefreq() === null || in_array($this->getChangefreq(), [ChangeFrequency::ALWAYS, ChangeFrequency::HOURLY])) {
if ($this->getChangefreq() === null || in_array($this->getChangefreq(), [ChangeFrequency::ALWAYS, ChangeFrequency::HOURLY], true)) {
return $this->lastmod->format(\DateTime::W3C);
}
@@ -105,7 +105,7 @@ public function setChangefreq($changefreq)
ChangeFrequency::NEVER,
];
if ($changefreq !== null && !in_array($changefreq, $validFreqs)) {
if ($changefreq !== null && !in_array($changefreq, $validFreqs, true)) {
throw new \DomainException(sprintf('Invalid changefreq given. Valid values are: %s', implode(', ', $validFreqs)));
}
@@ -465,7 +465,7 @@ public function setPlatforms(array $platforms)
$valid_platforms = [self::PLATFORM_TV, self::PLATFORM_WEB, self::PLATFORM_MOBILE];
foreach ($platforms as $platform => $relationship) {
if (!in_array($platform, $valid_platforms)) {
if (!in_array($platform, $valid_platforms, true)) {
throw new \DomainException(sprintf('Invalid platform given. Valid values are: %s', implode(', ', $valid_platforms)));
}
@@ -9,10 +9,10 @@ class RichXml extends Xml
{
public function getSitemapStart()
{
return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset '.
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '.
'xmlns:xhtml="http://www.w3.org/1999/xhtml" '.
'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" '.
return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset ' .
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ' .
'xmlns:xhtml="http://www.w3.org/1999/xhtml" ' .
'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" ' .
'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n";
}
@@ -8,9 +8,9 @@ class Xml extends BaseFormatter implements SitemapIndex
{
public function getSitemapStart()
{
return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset '.
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '.
'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" '.
return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset ' .
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ' .
'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" ' .
'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n";
}
@@ -39,15 +39,15 @@ protected function formatBody(Entity\Url $url)
$buffer = "\t" . '<loc>' . $this->escape($url->getLoc()) . '</loc>' . "\n";
if ($url->getLastmod() !== null) {
$buffer .= "\t" . '<lastmod>' . $this->escape($url->getLastmod()) .'</lastmod>' . "\n";
$buffer .= "\t" . '<lastmod>' . $this->escape($url->getLastmod()) . '</lastmod>' . "\n";
}
if ($url->getChangefreq() !== null) {
$buffer .= "\t" . '<changefreq>' . $this->escape($url->getChangefreq()) .'</changefreq>' . "\n";
$buffer .= "\t" . '<changefreq>' . $this->escape($url->getChangefreq()) . '</changefreq>' . "\n";
}
if ($url->getPriority() !== null) {
$buffer .= "\t" . '<priority>' . $this->escape($url->getPriority()) .'</priority>' . "\n";
$buffer .= "\t" . '<priority>' . $this->escape($url->getPriority()) . '</priority>' . "\n";
}
foreach ($url->getVideos() as $video) {
@@ -71,7 +71,7 @@ protected function formatSitemapIndexBody(Entity\SitemapIndex $sitemapIndex)
$buffer = "\t" . '<loc>' . $this->escape($sitemapIndex->getLoc()) . '</loc>' . "\n";
if ($sitemapIndex->getLastmod() !== null) {
$buffer .= "\t" . '<lastmod>' . $this->escape($sitemapIndex->getLastmod()) .'</lastmod>' . "\n";
$buffer .= "\t" . '<lastmod>' . $this->escape($sitemapIndex->getLastmod()) . '</lastmod>' . "\n";
}
return $buffer;
@@ -135,7 +135,7 @@ protected function formatVideo(Entity\Video $video)
$restrictions = $video->getRestrictions();
$relationship = $this->escape($restrictions['relationship']);
$buffer .= "\t\t" . '<video:restriction relationship="' . $relationship . '">'. $this->escape(implode(' ', $restrictions['countries'])) . '</video:restriction>' . "\n";
$buffer .= "\t\t" . '<video:restriction relationship="' . $relationship . '">' . $this->escape(implode(' ', $restrictions['countries'])) . '</video:restriction>' . "\n";
}
if ($video->getGalleryLoc() !== null) {
@@ -158,7 +158,7 @@ protected function formatVideo(Entity\Video $video)
if ($video->getPlatforms() !== null) {
foreach ($video->getPlatforms() as $platform => $relationship) {
$buffer .= "\t\t" . '<video:platform relationship="' . $this->escape($relationship) . '">'. $this->escape($platform) . '</video:platform>' . "\n";
$buffer .= "\t\t" . '<video:platform relationship="' . $this->escape($relationship) . '">' . $this->escape($platform) . '</video:platform>' . "\n";
}
}
@@ -65,7 +65,7 @@ protected function getResultLoc($result)
protected function getColumnValue($result, $column)
{
$method = 'get'.ucfirst($column);
$method = 'get' . ucfirst($column);
if (!method_exists($result, $method)) {
throw new \RuntimeException(sprintf('"%s" method not found in "%s"', $method, get_class($result)));
@@ -111,36 +111,36 @@ public function add(Url $url)
if ($this->baseHost !== null) {
if ($this->needHost($loc)) {
$url->setLoc($this->baseHost.$loc);
$url->setLoc($this->baseHost . $loc);
}
foreach ($url->getVideos() as $video) {
if ($this->needHost($video->getThumbnailLoc())) {
$video->setThumbnailLoc($this->baseHost.$video->getThumbnailLoc());
$video->setThumbnailLoc($this->baseHost . $video->getThumbnailLoc());
}
if ($this->needHost($video->getContentLoc())) {
$video->setContentLoc($this->baseHost.$video->getContentLoc());
$video->setContentLoc($this->baseHost . $video->getContentLoc());
}
$player = $video->getPlayerLoc();
if ($player !== null && $this->needHost($player['loc'])) {
$video->setPlayerLoc($this->baseHost.$player['loc'], $player['allow_embed'], $player['autoplay']);
$video->setPlayerLoc($this->baseHost . $player['loc'], $player['allow_embed'], $player['autoplay']);
}
$gallery = $video->getGalleryLoc();
if ($gallery !== null && $this->needHost($gallery['loc'])) {
$video->setGalleryLoc($this->baseHost.$gallery['loc'], $gallery['title']);
$video->setGalleryLoc($this->baseHost . $gallery['loc'], $gallery['title']);
}
}
foreach ($url->getImages() as $image) {
if ($this->needHost($image->getLoc())) {
$image->setLoc($this->baseHost.$image->getLoc());
$image->setLoc($this->baseHost . $image->getLoc());
}
if ($this->needHost($image->getLicense())) {
$image->setLicense($this->baseHost.$image->getLicense());
$image->setLicense($this->baseHost . $image->getLicense());
}
}
}
@@ -174,7 +174,7 @@ protected function createSitemapIndex()
$sitemapIndex = new SitemapIndex();
$loc = DIRECTORY_SEPARATOR . basename($sitemapIndexFilename);
if ($this->baseHostSitemap !== null) {
$sitemapIndex->setLoc($this->baseHostSitemap.$loc);
$sitemapIndex->setLoc($this->baseHostSitemap . $loc);
}
$sitemapIndex->setLastmod(new \DateTime());
@@ -213,9 +213,9 @@ protected function getSitemapIndexFilename($filename)
$index = count($this->sitemapIndexes) + 1;
$extPosition = strrpos($sitemapIndexFilename, ".");
if ($extPosition !== false) {
$sitemapIndexFilename = substr($sitemapIndexFilename, 0, $extPosition).'-'.$index.substr($sitemapIndexFilename, $extPosition);
$sitemapIndexFilename = substr($sitemapIndexFilename, 0, $extPosition) . '-' . $index . substr($sitemapIndexFilename, $extPosition);
} else {
$sitemapIndexFilename .= '-'.$index;
$sitemapIndexFilename .= '-' . $index;
}
$sitemapIndexFilename = dirname($filename) . DIRECTORY_SEPARATOR . $sitemapIndexFilename;
@@ -13,9 +13,9 @@ public function testDumper()
$dumper->dump('joe');
$this->assertTrue(file_exists($this->file));
$this->assertEquals('joe', file_get_contents($this->file));
$this->assertSame('joe', file_get_contents($this->file));
$dumper->dump('-hell yeah!');
$this->assertEquals('joe-hell yeah!', file_get_contents($this->file));
$this->assertSame('joe-hell yeah!', file_get_contents($this->file));
}
}
@@ -16,7 +16,7 @@ public function testDumper()
$this->assertTrue(file_exists($this->file));
$dumper->clearHandle(); // force the dumper to close the file
$this->assertEquals('joe-hell yeah!', file_get_contents('compress.zlib://'.$this->file));
$this->assertNotEquals('joe-hell yeah!', file_get_contents($this->file), 'The file\'s content is compressed');
$this->assertSame('joe-hell yeah!', file_get_contents('compress.zlib://' . $this->file));
$this->assertNotSame('joe-hell yeah!', file_get_contents($this->file), 'The file\'s content is compressed');
}
}
@@ -9,7 +9,7 @@ class MemoryTest extends \PHPUnit_Framework_TestCase
public function testDumper()
{
$dumper = new Memory();
$this->assertEquals('foo', $dumper->dump('foo'));
$this->assertEquals('foo-bar', $dumper->dump('-bar'));
$this->assertSame('foo', $dumper->dump('foo'));
$this->assertSame('foo-bar', $dumper->dump('-bar'));
}
}
@@ -13,7 +13,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
public function testLocMaxLength()
{
$url = new Url();
$url->setLoc('http://google.fr/?q='.str_repeat('o', 2048));
$url->setLoc('http://google.fr/?q=' . str_repeat('o', 2048));
}
/**
@@ -43,7 +43,7 @@ public function testChangefreq($changefreq)
$url = new Url();
$url->setChangefreq($changefreq);
$this->assertEquals($changefreq, $url->getChangefreq());
$this->assertSame($changefreq, $url->getChangefreq());
}
/**
@@ -55,7 +55,7 @@ public function testLastmodFormatting($lastmod, $changefreq, $expected_lastmod)
$url->setLastmod($lastmod);
$url->setChangefreq($changefreq);
$this->assertEquals($expected_lastmod, $url->getLastmod());
$this->assertSame($expected_lastmod, $url->getLastmod());
}
public function lastmodProvider()
@@ -47,7 +47,7 @@ public function testExpirationDate($date, $expected_date)
{
$video = new Video();
$video->setExpirationDate($date);
$this->assertEquals($video->getExpirationDate(), $expected_date);
$this->assertSame($video->getExpirationDate(), $expected_date);
}
/**
@@ -57,7 +57,7 @@ public function testPublicationDate($date, $expected_date)
{
$video = new Video();
$video->setPublicationDate($date);
$this->assertEquals($video->getPublicationDate(), $expected_date);
$this->assertSame($video->getPublicationDate(), $expected_date);
}
/**
@@ -85,7 +85,7 @@ public function testInvalidViewCount()
public function testInvalidTagsCount()
{
$video = new Video();
$video->setTags(array_pad(array(), 33, 'tag'));
$video->setTags(array_pad([], 33, 'tag'));
}
/**
@@ -106,7 +106,7 @@ public function testCategoryMaxLength()
public function testInvalidRestriction()
{
$video = new Video();
$video->setRestrictions(array('fr', 'en'), 'foo');
$video->setRestrictions(['fr', 'en'], 'foo');
}
/**
@@ -115,7 +115,7 @@ public function testInvalidRestriction()
public function testInvalidPlatform()
{
$video = new Video();
$video->setPlatforms(array(Video::PLATFORM_TV => Video::RESTRICTION_DENY, 'foo' => Video::RESTRICTION_DENY));
$video->setPlatforms([Video::PLATFORM_TV => Video::RESTRICTION_DENY, 'foo' => Video::RESTRICTION_DENY]);
}
/**
@@ -124,32 +124,32 @@ public function testInvalidPlatform()
public function testInvalidPlatformRelationship()
{
$video = new Video();
$video->setPlatforms(array(Video::PLATFORM_TV => Video::RESTRICTION_DENY, Video::PLATFORM_MOBILE => 'foo'));
$video->setPlatforms([Video::PLATFORM_TV => Video::RESTRICTION_DENY, Video::PLATFORM_MOBILE => 'foo']);
}
public function invalidDurationProvider()
{
return array(
array(-1),
array(28801),
);
return [
[-1],
[28801],
];
}
public function invalidRatingProvider()
{
return array(
array(-1),
array(6),
);
return [
[-1],
[6],
];
}
public function dateProvider()
{
return array(
array(null, null),
array('2012-12-20 18:44', $this->dateFormatW3C('2012-12-20 18:44')),
array('2012-12-20', $this->dateFormatW3C('2012-12-20')),
);
return [
[null, null],
['2012-12-20 18:44', $this->dateFormatW3C('2012-12-20 18:44')],
['2012-12-20', $this->dateFormatW3C('2012-12-20')],
];
}
protected function dateFormatW3C($date)
@@ -16,7 +16,7 @@ protected function setUp()
public function testSitemapStart()
{
$this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>'."\n".'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\n", $this->formatter->getSitemapStart());
$this->assertSame('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n", $this->formatter->getSitemapStart());
}
public function testFormatRichUrl()
@@ -28,12 +28,12 @@ public function testFormatRichUrl()
$url->addAlternateUrl('en', 'http://www.google.com');
$url->addAlternateUrl('es-es', 'http://www.google.es');
$this->assertEquals("<url>\n".
"\t<loc>http://www.google.fr</loc>\n".
"\t<changefreq>never</changefreq>\n".
"\t<priority>0.2</priority>\n".
"\t<xhtml:link rel=\"alternate\" hreflang=\"en\" href=\"http://www.google.com\" />\n".
"\t<xhtml:link rel=\"alternate\" hreflang=\"es-es\" href=\"http://www.google.es\" />\n".
$this->assertSame("<url>\n" .
"\t<loc>http://www.google.fr</loc>\n" .
"\t<changefreq>never</changefreq>\n" .
"\t<priority>0.2</priority>\n" .
"\t<xhtml:link rel=\"alternate\" hreflang=\"en\" href=\"http://www.google.com\" />\n" .
"\t<xhtml:link rel=\"alternate\" hreflang=\"es-es\" href=\"http://www.google.es\" />\n" .
"</url>\n", $this->formatter->formatUrl($url));
}
}

0 comments on commit 03428a4

Please sign in to comment.
You can’t perform that action at this time.