Commit 37b445c4 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen

Merge branch 'fixing-terfe2-models-cgl' into 'develop'

Change models to PHP7 and CGL compatibility

See merge request !200
parents 27126b19 57224622
Pipeline #2383 passed with stages
in 1 minute and 30 seconds
......@@ -25,45 +25,53 @@ 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
*/
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
*/
......@@ -71,6 +79,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Frontend user
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $frontendUser;
......@@ -83,7 +92,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* 2 = Developer
* 3 = Support
*
* @var integer
* @var int
*/
protected $authorType;
......@@ -92,17 +101,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 +121,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 +133,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 +144,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 +156,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 +167,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 +179,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 +190,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 +202,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 +213,7 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string Owner username
*/
public function getUsername()
public function getUsername(): string
{
return $this->username;
}
......@@ -214,9 +222,9 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Getter for versions
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version> versions
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getVersions()
public function getVersions(): ObjectStorage
{
return $this->versions;
}
......@@ -228,7 +236,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 +248,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 +258,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 +268,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 = null)
{
$this->frontendUser = $frontendUser;
}
......@@ -268,10 +276,10 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Setter for authorType
*
* @param integer $authorType Type of the author
* @param int $type Type of the author
* @return void
*/
public function setAuthorType($type)
public function setAuthorType(int $type)
{
$this->authorType = $type;
}
......@@ -280,9 +288,9 @@ class Author extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Getter for authorType
*
* @return integer Type of the author
* @return int Type of the author
*/
public function getAuthorType()
public function getAuthorType(): int
{
return $this->authorType;
}
......
......@@ -25,17 +25,19 @@ namespace T3o\TerFe2\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Extension container
*/
class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* Extension key
*
* @var string
*/
protected $extKey;
protected $extKey = '';
/**
* Link to forge project
......@@ -43,22 +45,30 @@ 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;
/**
* @var \DateTime
*/
protected $lastMaintained;
/**
* Tags
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Tag>
*/
protected $tags;
/**
* Versions
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version>
* @lazy
*/
......@@ -66,37 +76,43 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Last version
*
* @var \T3o\TerFe2\Domain\Model\Version
*/
protected $lastVersion;
/**
* Frontend user
*
* @var string
*/
protected $frontendUser;
protected $frontendUser = '';
/**
* Sum of all version downloads
* @var integer
*
* @var int
*/
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;
......@@ -106,14 +122,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 +137,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,7 +145,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @var string
* @validate \T3o\TerFe2\Validation\Validator\UrlValidator
*/
protected $paypalUrl;
protected $paypalUrl = '';
/**
* @var \DateTime
......@@ -142,8 +158,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 +169,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 +180,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string extKey
*/
public function getExtKey()
public function getExtKey(): string
{
return $this->extKey;
}
......@@ -176,7 +192,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 +203,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string forgeLink
*/
public function getForgeLink()
public function getForgeLink(): string
{
return $this->forgeLink;
}
......@@ -197,7 +213,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 +223,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return \DateTime
*/
public function getLastUpdate()
public function getLastUpdate(): \DateTime
{
return $this->lastUpdate;
}
......@@ -215,10 +231,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 +243,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 +254,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 +266,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 +279,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 +291,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 +303,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 +314,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 +325,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 +336,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
krsort($versions);
return $versions;
}
......@@ -330,9 +347,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(int $limit = 0, bool $reverseAfterSlice = true): array
{
$versions = array();
$versions = [];
foreach ($this->versions as $version) {
$versions[$version->getVersionNumber()] = $version;
......@@ -351,9 +368,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Returns the count of versions
*
* @return integer Version count
* @return int Version count
*/
public function getVersionCount()
public function getVersionCount(): int
{
return (!empty($this->versions) ? count($this->versions) : 0);
}
......@@ -365,11 +382,11 @@ 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);
$this->addDownloads((int)$version->getAllDownloads());
$this->addDownloads($version->getAllDownloads());
}
......@@ -378,15 +395,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,15 +418,16 @@ 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;
}
$curVersionNumber = (int)$this->lastVersion->getVersionNumber();
$newVersionNumber = (int)$lastVersion->getVersionNumber();
$curVersionNumber = $this->lastVersion->getVersionNumber();
$newVersionNumber = $lastVersion->getVersionNumber();
// Add lastVersion only if newer
if ($newVersionNumber > $curVersionNumber) {
......@@ -423,7 +441,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 +452,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 +463,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 +473,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param string $externalManual