mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 23:30:35 -04:00
Improve type hints
This commit is contained in:
parent
f21783d1f8
commit
fbcafb8f1d
17 changed files with 45 additions and 45 deletions
|
@ -3,11 +3,11 @@ use Safe\DateTimeImmutable;
|
|||
|
||||
/**
|
||||
* @property ?int $DeathYear
|
||||
* @property ?string $UrlName
|
||||
* @property ?string $Url
|
||||
* @property string $DeleteUrl
|
||||
* @property string $UrlName
|
||||
* @property-read string $Url
|
||||
* @property-read string $DeleteUrl
|
||||
* @property array<string> $AlternateNames
|
||||
* @property string $AlternateNamesString
|
||||
* @property-read string $AlternateNamesString
|
||||
*/
|
||||
class Artist{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -12,8 +12,8 @@ use function Safe\unlink;
|
|||
|
||||
/**
|
||||
* @property string $UrlName
|
||||
* @property string $Url
|
||||
* @property string $EditUrl
|
||||
* @property-read string $Url
|
||||
* @property-read string $EditUrl
|
||||
* @property-read array<ArtworkTag> $Tags
|
||||
* @property-write array<ArtworkTag>|string $Tags
|
||||
* @property Artist $Artist
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?
|
||||
/**
|
||||
* @property bool $HasBenefits Are any of the benefits in this object **`TRUE`**?
|
||||
* @property bool $RequiresPassword Do any of the benefits in this object require the `User` to have a password set?
|
||||
* @property-read bool $HasBenefits Are any of the benefits in this object **`TRUE`**?
|
||||
* @property-read bool $RequiresPassword Do any of the benefits in this object require the `User` to have a password set?
|
||||
*/
|
||||
class Benefits{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use function Safe\preg_replace;
|
||||
|
||||
/**
|
||||
* @property string $Url
|
||||
* @property-read string $Url
|
||||
* @property array<Ebook> $Ebooks
|
||||
*/
|
||||
class Collection{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use function Safe\preg_match;
|
||||
|
||||
/**
|
||||
* @property ?string $Url The URL of this `Contributor` if their MARC role is `Enums\MarcRole::Author`, or **null** otherwise.
|
||||
* @property-read ?string $Url The URL of this `Contributor` if their MARC role is `Enums\MarcRole::Author`, or `null` otherwise.
|
||||
*/
|
||||
class Contributor{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
use Safe\DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* @property int $DonationCount
|
||||
* @property int $StretchDonationCount
|
||||
* @property bool $IsStretchEnabled
|
||||
* @property int $TargetDonationCount
|
||||
* @property-read int $DonationCount
|
||||
* @property-read int $StretchDonationCount
|
||||
* @property-read bool $IsStretchEnabled
|
||||
* @property-read int $TargetDonationCount
|
||||
*/
|
||||
class DonationDrive{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -22,9 +22,9 @@ use function Safe\shell_exec;
|
|||
* @property ?array<string> $TocEntries A list of non-Roman ToC entries *only if* the work has the `se:is-a-collection` metadata element; `null` otherwise.
|
||||
* @property string $Url The relative URL of this ebook, like `/ebooks/...`.
|
||||
* @property string $FullUrl The absolute URL of this ebook, like `https://standardebooks.org/ebooks/...`.
|
||||
* @property string $EditUrl
|
||||
* @property string $DeleteUrl
|
||||
* @property bool $HasDownloads
|
||||
* @property-read string $EditUrl
|
||||
* @property-read string $DeleteUrl
|
||||
* @property-read bool $HasDownloads
|
||||
* @property string $UrlSafeIdentifier
|
||||
* @property string $HeroImageUrl
|
||||
* @property string $HeroImageAvifUrl
|
||||
|
@ -45,10 +45,10 @@ use function Safe\shell_exec;
|
|||
* @property string $TextSinglePageUrl
|
||||
* @property string $TextSinglePageSizeFormatted
|
||||
* @property ?EbookPlaceholder $EbookPlaceholder
|
||||
* @property array<Project> $Projects
|
||||
* @property array<Project> $PastProjects
|
||||
* @property ?Project $ProjectInProgress
|
||||
* @property ?Artwork $Artwork
|
||||
* @property-read array<Project> $Projects
|
||||
* @property-read array<Project> $PastProjects
|
||||
* @property-read ?Project $ProjectInProgress
|
||||
* @property-read ?Artwork $Artwork
|
||||
*/
|
||||
final class Ebook{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?
|
||||
|
||||
/**
|
||||
* @property bool $IsPublicDomain
|
||||
* @property string $TimeTillIsPublicDomain A string describing how much longer it will be before this work is in the U.S. public domain, like `3 months` or `20 years`.
|
||||
* @property-read bool $IsPublicDomain
|
||||
* @property-read string $TimeTillIsPublicDomain A string describing how much longer it will be before this work is in the U.S. public domain, like `3 months` or `20 years`.
|
||||
*/
|
||||
class EbookPlaceholder{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -3,7 +3,7 @@ use Safe\DateTimeImmutable;
|
|||
|
||||
/**
|
||||
* @property User $User
|
||||
* @property string $Url
|
||||
* @property-read string $Url
|
||||
*/
|
||||
class NewsletterSubscription{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -3,7 +3,7 @@ use Safe\DateTimeImmutable;
|
|||
|
||||
/**
|
||||
* @property User $User
|
||||
* @property ?Payment $LastPayment
|
||||
* @property-read ?Payment $LastPayment
|
||||
*/
|
||||
class Patron{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
use Safe\DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* @property string $Url
|
||||
* @property-read string $Url
|
||||
* @property array<PollItem> $PollItems
|
||||
* @property array<PollItem> $PollItemsByWinner
|
||||
* @property int $VoteCount
|
||||
* @property-read int $VoteCount
|
||||
*/
|
||||
class Poll{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?
|
||||
/**
|
||||
* @property int $VoteCount
|
||||
* @property-read int $VoteCount
|
||||
* @property Poll $Poll
|
||||
*/
|
||||
class PollItem{
|
||||
|
|
|
@ -4,7 +4,7 @@ use Safe\DateTimeImmutable;
|
|||
/**
|
||||
* @property User $User
|
||||
* @property PollItem $PollItem
|
||||
* @property string $Url
|
||||
* @property-read string $Url
|
||||
*/
|
||||
class PollVote{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -16,12 +16,12 @@ use Safe\DateTimeImmutable;
|
|||
* @property Ebook $Ebook
|
||||
* @property User $Manager
|
||||
* @property User $Reviewer
|
||||
* @property string $Url
|
||||
* @property string $EditUrl
|
||||
* @property-read string $Url
|
||||
* @property-read string $EditUrl
|
||||
* @property DateTimeImmutable $LastActivityTimestamp The timestamp of the latest activity, whether it's a commit, a discussion post, or simply the started timestamp.
|
||||
* @property array<ProjectReminder> $Reminders
|
||||
* @property ?string $VcsUrlDomain
|
||||
* @property ?string $DiscussionUrlDomain
|
||||
* @property-read ?string $VcsUrlDomain
|
||||
* @property-read ?string $DiscussionUrlDomain
|
||||
*/
|
||||
final class Project{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -5,7 +5,7 @@ use Ramsey\Uuid\Uuid;
|
|||
use Safe\DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* @property string $Url
|
||||
* @property-read string $Url
|
||||
*/
|
||||
class Session{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?
|
||||
/**
|
||||
* @property string $Url
|
||||
* @property-read string $Url
|
||||
*/
|
||||
class Tag{
|
||||
use Traits\Accessor;
|
||||
|
@ -10,5 +10,5 @@ class Tag{
|
|||
public string $UrlName;
|
||||
public Enums\TagType $Type;
|
||||
|
||||
protected string $_Url;
|
||||
protected string $_Url; // For subclasses.
|
||||
}
|
||||
|
|
18
lib/User.php
18
lib/User.php
|
@ -6,15 +6,15 @@ use function Safe\preg_match;
|
|||
|
||||
/**
|
||||
* @property array<Payment> $Payments
|
||||
* @property bool $IsRegistered A user is "registered" if they have an entry in the `Benefits` table; a password is required to log in.
|
||||
* @property-read bool $IsRegistered A user is "registered" if they have an entry in the `Benefits` table; a password is required to log in.
|
||||
* @property Benefits $Benefits
|
||||
* @property string $Url
|
||||
* @property string $EditUrl
|
||||
* @property-read string $Url
|
||||
* @property-read string $EditUrl
|
||||
* @property ?Patron $Patron
|
||||
* @property ?NewsletterSubscription $NewsletterSubscription
|
||||
* @property ?Payment $LastPayment
|
||||
* @property string $DisplayName The `User`'s name, or email, or ID.
|
||||
* @property ?string $SortName The `User`'s name in an (attempted) sort order, or `null` if the `User` has no name.
|
||||
* @property-read ?Payment $LastPayment
|
||||
* @property-read string $DisplayName The `User`'s name, or email, or ID.
|
||||
* @property-read ?string $SortName The `User`'s name in an (attempted) sort order, or `null` if the `User` has no name.
|
||||
*/
|
||||
class User{
|
||||
use Traits\Accessor;
|
||||
|
@ -50,7 +50,7 @@ class User{
|
|||
if($this->Name !== null){
|
||||
preg_match('/\s(?:de |de la |di |van |von )?[^\s]+$/iu', $this->Name, $lastNameMatches);
|
||||
if(sizeof($lastNameMatches) == 0){
|
||||
$this->SortName = $this->Name;
|
||||
$this->_SortName = $this->Name;
|
||||
}
|
||||
else{
|
||||
$lastName = trim($lastNameMatches[0]);
|
||||
|
@ -58,7 +58,7 @@ class User{
|
|||
preg_match('/^(.+)' . preg_quote($lastName, '/') . '$/u', $this->Name, $firstNameMatches);
|
||||
|
||||
if(sizeof($firstNameMatches) == 0){
|
||||
$this->SortName = $this->Name;
|
||||
$this->_SortName = $this->Name;
|
||||
}
|
||||
else{
|
||||
$this->_SortName = $lastName . ', ' . trim($firstNameMatches[1]);
|
||||
|
@ -289,7 +289,7 @@ class User{
|
|||
elseif($this->Benefits->HasBenefits){
|
||||
$this->Benefits->UserId = $this->UserId;
|
||||
$this->Benefits->Create();
|
||||
$this->IsRegistered = true;
|
||||
$this->_IsRegistered = true;
|
||||
}
|
||||
}
|
||||
catch(Exceptions\DuplicateDatabaseKeyException){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue