Skip to content
Permalink
Browse files

Require PHP 7.1

  • Loading branch information...
Kévin Gomez
Kévin Gomez committed Feb 6, 2018
1 parent b89ff99 commit 7ce9754542fb77dd3acb4f408c101af46d5910b1
@@ -7,12 +7,11 @@ cache:
- $HOME/.composer/cache

php:
- 7.0
- 7.1

matrix:
include:
- { php: 7.0, env: COMPOSER_FLAGS='--prefer-lowest' }
- { php: 7.1, env: COMPOSER_FLAGS='--prefer-lowest' }

fast_finish: true

@@ -12,7 +12,7 @@
}
],
"require": {
"php": "~7.0",
"php": "~7.1",
"symfony/property-access": "~3.0|^4.0",
"nikic/iter": "^1.3"
},
@@ -9,7 +9,7 @@
/**
* Dump the sitemap into a file.
*
* @see \SitemapGenerator\Dumper\GzFile
* @see GzFile
*/
class File implements FileDumper
{
@@ -49,7 +49,7 @@ public function dump(string $string)
fwrite($this->handle, $string);
}
private function openFile()
private function openFile(): void
{
$this->handle = @fopen($this->filename, 'w');
@@ -62,7 +62,7 @@ private function openFile()
/**
* {@inheritdoc}
*/
private function clearHandle()
private function clearHandle(): void
{
if ($this->handle !== null) {
fclose($this->handle);
@@ -9,9 +9,9 @@
/**
* Dump the sitemap into a compressed file.
*
* @see \SitemapGenerator\Dumper\File
* @see File
*/
class GzFile extends File
final class GzFile extends File
{
public function __construct(string $filename)
{
@@ -10,7 +10,7 @@
* Dump a sitemap in memory. Useful if you don't want to touch your filesystem
* or if you want to access the sitemap's content.
*/
class Memory implements Dumper
final class Memory implements Dumper
{
private $buffer = '';
@@ -4,17 +4,17 @@
namespace SitemapGenerator\Entity;
class ChangeFrequency
final class ChangeFrequency
{
const ALWAYS = 'always';
const HOURLY = 'hourly';
const DAILY = 'daily';
const WEEKLY = 'weekly';
const MONTHLY = 'monthly';
const YEARLY = 'yearly';
const NEVER = 'never';
public const ALWAYS = 'always';
public const HOURLY = 'hourly';
public const DAILY = 'daily';
public const WEEKLY = 'weekly';
public const MONTHLY = 'monthly';
public const YEARLY = 'yearly';
public const NEVER = 'never';
const KNOWN_FREQUENCIES = [
public const KNOWN_FREQUENCIES = [
self::ALWAYS, self::HOURLY, self::DAILY,
self::WEEKLY, self::MONTHLY, self::YEARLY,
self::NEVER,
@@ -9,7 +9,7 @@
*
* @see http://support.google.com/webmasters/bin/answer.py?hl=fr&answer=178636
*/
class Image
final class Image
{
/**
* The URL of the image.
@@ -37,52 +37,52 @@ class Image
*/
private $license;
public function setLoc($loc)
public function __construct(string $loc)
{
$this->loc = $loc;
}
public function getLoc()
public function getLoc(): string
{
return $this->loc;
}
public function setCaption($caption)
public function setCaption(?string $caption)
{
$this->caption = $caption;
}
public function getCaption()
public function getCaption(): ?string
{
return $this->caption;
}
public function setGeoLocation($geoLocation)
public function setGeoLocation(?string $geoLocation)
{
$this->geoLocation = $geoLocation;
}
public function getGeoLocation()
public function getGeoLocation(): ?string
{
return $this->geoLocation;
}
public function setTitle($title)
public function setTitle(?string $title)
{
$this->title = $title;
}
public function getTitle()
public function getTitle(): ?string
{
return $this->title;
}
public function setLicense($license)
public function setLicense(?string $license)
{
$this->license = $license;
}
public function getLicense()
public function getLicense(): ?string
{
return $this->license;
}
@@ -9,7 +9,7 @@
*
* @see http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2620865
*/
class RichUrl extends Url
final class RichUrl extends Url
{
/**
* Alternate urls list, locale indexed.
@@ -30,12 +30,12 @@ class RichUrl extends Url
*
* @param string $locale The url's language (and optionnaly region. Ex: en, en-us).
*/
public function addAlternateUrl(string $locale, string $url)
public function addAlternateUrl(string $locale, string $url): void
{
$this->alternateUrl[$locale] = $url;
}
public function getAlternateUrls(): array
public function getAlternateUrls(): iterable
{
return $this->alternateUrl;
}
@@ -9,7 +9,7 @@
*
* @see http://www.sitemaps.org/protocol.html
*/
class SitemapIndexEntry
final class SitemapIndexEntry
{
/**
* URL of the sitemap index.
@@ -45,7 +45,7 @@ public function getLoc(): string
return $this->loc;
}
public function getLastmod()
public function getLastmod(): ?string
{
if ($this->lastmod === null) {
return null;
@@ -67,25 +67,25 @@ public function getLoc(): string
return $this->loc;
}
public function setLastmod(\DateTimeInterface $lastmod = null)
public function setLastmod(\DateTimeInterface $lastmod)
{
$this->lastmod = $lastmod;
}
public function getLastmod()
public function getLastmod(): ?string
{
if ($this->lastmod === null) {
return null;
}
if ($this->getChangeFreq() === null || \in_array($this->getChangeFreq(), [ChangeFrequency::ALWAYS, ChangeFrequency::HOURLY], true)) {
if ($this->changeFreq === null || \in_array($this->changeFreq, [ChangeFrequency::ALWAYS, ChangeFrequency::HOURLY], true)) {
return $this->lastmod->format(\DateTime::W3C);
}
return $this->lastmod->format('Y-m-d');
}
public function setChangeFreq($changeFreq)
public function setChangeFreq(string $changeFreq)
{
if ($changeFreq !== null && !ChangeFrequency::isValid($changeFreq)) {
throw new \DomainException(sprintf('Invalid changefreq given ("%s"). Valid values are: %s', $changeFreq, implode(', ', ChangeFrequency::KNOWN_FREQUENCIES)));
@@ -94,62 +94,60 @@ public function setChangeFreq($changeFreq)
$this->changeFreq = $changeFreq;
}
public function getChangeFreq()
public function getChangeFreq(): ?string
{
return $this->changeFreq;
}
public function setPriority($priority)
public function setPriority(float $priority)
{
$priority = (float) $priority;
if ($priority < 0 || $priority > 1) {
throw new \DomainException('The priority must be between 0 and 1');
}
$this->priority = $priority;
}
public function getPriority()
public function getPriority(): ?float
{
return $this->priority;
}
public function addVideo(Video $video)
public function addVideo(Video $video): void
{
$this->videos[] = $video;
}
/**
* @param Video[] $videos
*/
public function setVideos(array $videos)
public function setVideos(iterable $videos)
{
$this->videos = $videos;
}
/**
* @return Video[]
*/
public function getVideos(): array
public function getVideos(): iterable
{
return $this->videos;
}
public function addImage(Image $image)
public function addImage(Image $image): void
{
$this->images[] = $image;
}
public function setImages(array $images)
public function setImages(iterable $images): void
{
$this->images = $images;
}
/**
* @return Image[]
*/
public function getImages(): array
public function getImages(): iterable
{
return $this->images;
}

0 comments on commit 7ce9754

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