Commit ea109439 authored by Thomas Löffler's avatar Thomas Löffler

Change models to PHP7 and CGL compatibility

parent 1349ae90
......@@ -25,6 +25,9 @@ namespace T3o\TerFe2\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Author of an extension
*/
......@@ -33,47 +36,54 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Name of the author
*
* @var string
* @validate NotEmpty
*/
protected $name;
protected $name = '';
/**
* Email address
*
* @var string
*/
protected $email;
protected $email = '';
/**
* Company name
*
* @var string
*/
protected $company;
protected $company = '';
/**
* Link to forge profile
*
* @var string
*/
protected $forgeLink;
protected $forgeLink = '';
/**
* Owner username
*
* @var string
*/
protected $username;
protected $username = '';
/**
* versions
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version>
* @lazy
*/
protected $versions;
protected $versions = null;
/**
* Frontend user
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $frontendUser;
protected $frontendUser = null;
/**
* Author type
......@@ -92,17 +102,16 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
public function __construct()
{
$this->versions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$this->versions = new ObjectStorage();
}
/**
* Setter for name
*
* @param string $name Name of the author
* @return void
*/
public function setName($name)
public function setName(string $name)
{
$this->name = $name;
}
......@@ -113,7 +122,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Name of the author
*/
public function getName()
public function getName(): string
{
return $this->name;
}
......@@ -125,7 +134,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $email Email address
* @return void
*/
public function setEmail($email)
public function setEmail(string $email)
{
$this->email = $email;
}
......@@ -136,7 +145,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Email address
*/
public function getEmail()
public function getEmail(): string
{
return $this->email;
}
......@@ -148,7 +157,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $company Company name
* @return void
*/
public function setCompany($company)
public function setCompany(string $company)
{
$this->company = $company;
}
......@@ -159,7 +168,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Company name
*/
public function getCompany()
public function getCompany(): string
{
return $this->company;
}
......@@ -171,7 +180,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $forgeLink Link to forge profile
* @return void
*/
public function setForgeLink($forgeLink)
public function setForgeLink(string $forgeLink)
{
$this->forgeLink = $forgeLink;
}
......@@ -182,7 +191,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Link to forge profile
*/
public function getForgeLink()
public function getForgeLink(): string
{
return $this->forgeLink;
}
......@@ -194,7 +203,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $username Owner username
* @return void
*/
public function setUsername($username)
public function setUsername(string $username)
{
$this->username = $username;
}
......@@ -205,7 +214,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Owner username
*/
public function getUsername()
public function getUsername(): string
{
return $this->username;
}
......@@ -216,7 +225,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version> versions
*/
public function getVersions()
public function getVersions(): ObjectStorage
{
return $this->versions;
}
......@@ -228,7 +237,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param \T3o\TerFe2\Domain\Model\Version $version The Version to be added
* @return void
*/
public function addVersion(\T3o\TerFe2\Domain\Model\Version $version)
public function addVersion(Version $version)
{
$this->versions->attach($version);
}
......@@ -240,7 +249,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param \T3o\TerFe2\Domain\Model\Version $version The Version to be removed
* @return void
*/
public function removeVersion(\T3o\TerFe2\Domain\Model\Version $version)
public function removeVersion(Version $version)
{
$this->versions->detach($version);
}
......@@ -250,7 +259,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
public function getFrontendUser()
public function getFrontendUser(): FrontendUser
{
return $this->frontendUser;
}
......@@ -260,7 +269,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $frontendUser
*/
public function setFrontendUser($frontendUser)
public function setFrontendUser(FrontendUser $frontendUser)
{
$this->frontendUser = $frontendUser;
}
......@@ -268,10 +277,10 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Setter for authorType
*
* @param integer $authorType Type of the author
* @param integer $type Type of the author
* @return void
*/
public function setAuthorType($type)
public function setAuthorType(integer $type)
{
$this->authorType = $type;
}
......@@ -282,7 +291,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return integer Type of the author
*/
public function getAuthorType()
public function getAuthorType(): integer
{
return $this->authorType;
}
......
<?php
namespace T3o\TerFe2\Domain\Model;
/*******************************************************************
......@@ -25,6 +26,8 @@ namespace T3o\TerFe2\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Extension container
*/
......@@ -33,9 +36,10 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Extension key
*
* @var string
*/
protected $extKey;
protected $extKey = '';
/**
* Link to forge project
......@@ -43,62 +47,76 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @var string
* @validate \T3o\TerFe2\Validation\Validator\UrlValidator
*/
protected $forgeLink;
protected $forgeLink = '';
/**
* Last update
* @var DateTime
*
* @var \DateTime
*/
protected $lastUpdate;
protected $lastUpdate = null;
/**
* @var \DateTime
*/
protected $lastMaintained = null;
/**
* Tags
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Tag>
*/
protected $tags;
protected $tags = null;
/**
* Versions
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version>
* @lazy
*/
protected $versions;
protected $versions = null;
/**
* Last version
*
* @var \T3o\TerFe2\Domain\Model\Version
*/
protected $lastVersion;
protected $lastVersion = null;
/**
* Frontend user
*
* @var string
*/
protected $frontendUser;
protected $frontendUser = '';
/**
* Sum of all version downloads
*
* @var integer
*/
protected $downloads;
protected $downloads = 0;
/**
* Flattr username
*
* @var string
*/
protected $flattrUsername;
protected $flattrUsername = '';
/**
* Flattr data from result
*
* @var string
*/
protected $flattrData;
protected $flattrData = '';
/**
* Creation date
* @var DateTime
*
* @var \DateTime
*/
protected $crdate;
protected $crdate = null;
/**
* Link to an external repository
......@@ -106,14 +124,14 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @var string
* @validate \T3o\TerFe2\Validation\Validator\UrlValidator
*/
protected $repositoryUrl;
protected $repositoryUrl = '';
/**
* External repository clone url
*
* @var string
*/
protected $repositoryCloneUrl;
protected $repositoryCloneUrl = '';
/**
* Link to an external manual
......@@ -121,7 +139,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @var string
* @validate \T3o\TerFe2\Validation\Validator\UrlValidator
*/
protected $externalManual;
protected $externalManual = '';
/**
* Link to paypal donation
......@@ -129,12 +147,12 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @var string
* @validate \T3o\TerFe2\Validation\Validator\UrlValidator
*/
protected $paypalUrl;
protected $paypalUrl = '';
/**
* @var \DateTime
*/
protected $expire;
protected $expire = null;
/**
......@@ -142,8 +160,8 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
public function __construct()
{
$this->tags = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$this->versions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$this->tags = new ObjectStorage();
$this->versions = new ObjectStorage();
}
......@@ -153,7 +171,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $extKey extKey
* @return void
*/
public function setExtKey($extKey)
public function setExtKey(string $extKey)
{
$this->extKey = $extKey;
}
......@@ -164,7 +182,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string extKey
*/
public function getExtKey()
public function getExtKey(): string
{
return $this->extKey;
}
......@@ -176,7 +194,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $forgeLink forgeLink
* @return void
*/
public function setForgeLink($forgeLink)
public function setForgeLink(string $forgeLink)
{
$this->forgeLink = $forgeLink;
}
......@@ -187,7 +205,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string forgeLink
*/
public function getForgeLink()
public function getForgeLink(): string
{
return $this->forgeLink;
}
......@@ -197,7 +215,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param \DateTime $lastUpdate
*/
public function setLastUpdate($lastUpdate)
public function setLastUpdate(\DateTime $lastUpdate)
{
$this->lastUpdate = $lastUpdate;
}
......@@ -207,7 +225,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \DateTime
*/
public function getLastUpdate()
public function getLastUpdate(): \DateTime
{
return $this->lastUpdate;
}
......@@ -215,10 +233,10 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Setter for crdate
*
* @param DateTime $crdate creation date
* @param \DateTime $crdate creation date
* @return void
*/
public function setCrdate(DateTime $crdate)
public function setCrdate(\DateTime $crdate)
{
$this->crdate = $crdate;
}
......@@ -227,9 +245,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Getter for crdate
*
* @return DateTime crdate
* @return \DateTime crdate
*/
public function getCrdate()
public function getCrdate(): \DateTime
{
return $this->crdate;
}
......@@ -238,10 +256,10 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Setter for lastMaintained
*
* @param DateTime $lastMaintained lastMaintained
* @param \DateTime $lastMaintained lastMaintained
* @return void
*/
public function setLastMaintained(DateTime $lastMaintained)
public function setLastMaintained(\DateTime $lastMaintained)
{
$this->lastMaintained = $lastMaintained;
}
......@@ -250,9 +268,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Getter for lastMaintained
*
* @return DateTime lastMaintained
* @return \DateTime lastMaintained
*/
public function getLastMaintained()
public function getLastMaintained(): \DateTime
{
return $this->lastMaintained;
}
......@@ -263,7 +281,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Tag> Tags
*/
public function getTags()
public function getTags(): ObjectStorage
{
return $this->tags;
}
......@@ -275,7 +293,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param \T3o\TerFe2\Domain\Model\Tag $tag The tag to be added
* @return void
*/
public function addTag(\T3o\TerFe2\Domain\Model\Tag $tag)
public function addTag(Tag $tag)
{
$this->tags->attach($tag);
}
......@@ -287,7 +305,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param \T3o\TerFe2\Domain\Model\Tag $tag The tag to be removed
* @return void
*/
public function removeTag(\T3o\TerFe2\Domain\Model\Tag $tag)
public function removeTag(Tag $tag)
{
$this->tags->detach($tag);
}
......@@ -298,7 +316,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version> Versions
*/
public function getVersions()
public function getVersions(): ObjectStorage
{
return $this->versions;
}
......@@ -309,9 +327,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return array Versions
*/
public function getReverseVersionsWithPositiveReviewsByVersionNumber()
public function getReverseVersionsWithPositiveReviewsByVersionNumber(): array
{
$versions = array();
$versions = [];
foreach ($this->versions as $version) {
if ($version->getReviewState() > -1) {
......@@ -320,6 +338,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
krsort($versions);
return $versions;
}
......@@ -330,9 +349,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param bool $reverseAfterSlice
* @return array|\T3o\TerFe2\Domain\Model\Version[] Versions
*/
public function getReverseVersionsByVersionNumber($limit = 0, $reverseAfterSlice = true)
public function getReverseVersionsByVersionNumber($limit = 0, $reverseAfterSlice = true): array
{
$versions = array();
$versions = [];
foreach ($this->versions as $version) {
$versions[$version->getVersionNumber()] = $version;
......@@ -353,7 +372,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return integer Version count
*/
public function getVersionCount()
public function getVersionCount(): integer
{
return (!empty($this->versions) ? count($this->versions) : 0);
}
......@@ -365,7 +384,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param \T3o\TerFe2\Domain\Model\Version $version The version to be added
* @return void
*/
public function addVersion(\T3o\TerFe2\Domain\Model\Version $version)
public function addVersion(Version $version)
{
$this->versions->attach($version);
$this->setLastVersion($version);
......@@ -378,15 +397,15 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param \T3o\TerFe2\Domain\Model\Version $version
*/
public function removeVersion(\T3o\TerFe2\Domain\Model\Version $version)
public function removeVersion(Version $version)
{
if (!$this->versions->contains($version)) {
throw new UnexpectedValueException('Tried to remove a version which is not part of the extension.', 1339359060);
throw new \UnexpectedValueException('Tried to remove a version which is not part of the extension.', 1339359060);
}
$versionCount = $this->getVersionCount();
$this->versions->detach($version);
if ($version == $this->lastVersion) {
if ($version === $this->lastVersion) {
if ($versionCount === 1) {
$this->lastVersion = null;
} else {
......@@ -401,10 +420,11 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param \T3o\TerFe2\Domain\Model\Version $lastVersion lastVersion
* @return void
*/
public function setLastVersion(\T3o\TerFe2\Domain\Model\Version $lastVersion)
public function setLastVersion(Version $lastVersion)
{
if (empty($this->lastVersion)) {
$this->lastVersion = $lastVersion;
return;
}
......@@ -423,7 +443,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \T3o\TerFe2\Domain\Model\Version lastVersion
*/
public function getLastVersion()
public function getLastVersion(): Version
{
return $this->lastVersion;
}
......@@ -434,7 +454,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @param string $frontendUser Frontend user
* @return void
*/
public function setFrontendUser($frontendUser)
public function setFrontendUser(string $frontendUser)
{
$this->frontendUser = $frontendUser;
}
......@@ -445,7 +465,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Frontend user
*/
public function getFrontendUser()
public function getFrontendUser(): string
{
return $this->frontendUser;
}
......@@ -455,7 +475,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param string $externalManual
*/
public function setExternalManual($externalManual)
public function setExternalManual(string $externalManual)
{
$this->externalManual = $externalManual;
}
......@@ -465,7 +485,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string
*/
public function getExternalManual()
public function getExternalManual(): string