mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Type hinting fixes
This commit is contained in:
parent
716fc8bea9
commit
f9c873003e
4 changed files with 12 additions and 9 deletions
|
@ -11,8 +11,8 @@ parameters:
|
|||
# Ignore errors caused by no type hints on class properties, as that's not available till PHP 7.4
|
||||
- '#Property .+? has no type specified.#'
|
||||
|
||||
# Ignore errors caused by type hints that should be union types. Union types are not yet supported in PHP.
|
||||
- '#Function vd(s|d)?\(\) has parameter \$var with no type specified.#'
|
||||
# Ignore setters for properties that accept several types
|
||||
- '#Property Artwork::\$Tags \(array<ArtworkTag>\) does not accept.+#'
|
||||
level:
|
||||
8
|
||||
paths:
|
||||
|
|
|
@ -21,7 +21,7 @@ use function Safe\preg_replace;
|
|||
* @property User $Submitter
|
||||
* @property User $Reviewer
|
||||
* @property ?ImageMimeType $MimeType
|
||||
* @property array<ArtworkTag> $_Tags
|
||||
* @property ?array<ArtworkTag> $_Tags
|
||||
*/
|
||||
class Artwork extends PropertiesBase{
|
||||
public ?string $Name = null;
|
||||
|
@ -60,6 +60,9 @@ class Artwork extends PropertiesBase{
|
|||
// SETTERS
|
||||
// *******
|
||||
|
||||
/**
|
||||
* @param string|null|array<ArtworkTag> $tags
|
||||
*/
|
||||
protected function SetTags(string|array|null $tags): void{
|
||||
if($tags === null || is_array($tags)){
|
||||
$this->_Tags = $tags;
|
||||
|
@ -289,14 +292,14 @@ class Artwork extends PropertiesBase{
|
|||
$error->Add(new Exceptions\MissingEbookException());
|
||||
}
|
||||
|
||||
if($this->Tags === null || count($this->_Tags) == 0){
|
||||
if(count($this->Tags) == 0){
|
||||
// In-use artwork doesn't have user-provided tags.
|
||||
if($this->Status !== COVER_ARTWORK_STATUS_IN_USE){
|
||||
$error->Add(new Exceptions\TagsRequiredException());
|
||||
}
|
||||
}
|
||||
|
||||
if($this->Tags !== null && count($this->_Tags) > COVER_ARTWORK_MAX_TAGS){
|
||||
if(count($this->Tags) > COVER_ARTWORK_MAX_TAGS){
|
||||
$error->Add(new Exceptions\TooManyTagsException());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,18 +6,18 @@ use function Safe\ob_end_clean;
|
|||
use function Safe\ob_start;
|
||||
|
||||
// Convenience alias of var_dump.
|
||||
function vd($var): void{
|
||||
function vd(mixed $var): void{
|
||||
var_dump($var);
|
||||
}
|
||||
|
||||
// var_dump($var) then die().
|
||||
function vdd($var): void{
|
||||
function vdd(mixed $var): void{
|
||||
var_dump($var);
|
||||
die();
|
||||
}
|
||||
|
||||
// var_dump into a string.
|
||||
function vds($var): string{
|
||||
function vds(mixed $var): string{
|
||||
ob_start();
|
||||
var_dump($var);
|
||||
$str = ob_get_contents();
|
||||
|
|
|
@ -30,7 +30,7 @@ try{
|
|||
$artwork->Name = HttpInput::Str(POST, 'artwork-name', false);
|
||||
$artwork->CompletedYear = HttpInput::Int(POST, 'artwork-year');
|
||||
$artwork->CompletedYearIsCirca = HttpInput::Bool(POST, 'artwork-year-is-circa', false);
|
||||
$artwork->Tags = HttpInput::Str(POST, 'artwork-tags', false);
|
||||
$artwork->Tags = HttpInput::Str(POST, 'artwork-tags', false) ?? [];
|
||||
$artwork->Status = HttpInput::Str(POST, 'artwork-status', false, COVER_ARTWORK_STATUS_UNVERIFIED);
|
||||
$artwork->EbookWwwFilesystemPath = HttpInput::Str(POST, 'artwork-ebook-www-filesystem-path', false);
|
||||
$artwork->SubmitterUserId = $GLOBALS['User']->UserId ?? null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue