Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS-Fixer: Enable phpdoc_to_property_type #38

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@
],
],
'yoda_style' => false,
'php_unit_test_case_static_method_calls' => false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep this rule, or shall we switch to:

- $this->assertSame(
+ self::assertSame(

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I like $this->assertSame( more too.


// temp disabled to keep the diff small in the first run
'declare_strict_types' => false,
'php_unit_test_case_static_method_calls' => false,
'strict_comparison' => false,
'phpdoc_to_property_type' => false,
'phpdoc_summary' => false,
'nullable_type_declaration_for_default_null_value' => false,
]));
Expand Down
14 changes: 5 additions & 9 deletions src/Api/Glances/Glance.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@
class Glance
{
/**
* @var Application pushover application
* Pushover application
*/
private $application;
private Application $application;

/**
* @var Recipient pushover user
* Pushover user
*/
private $recipient;

/**
* @var GlanceDataFields glance Data Fields
*/
private $glanceDataFields;
private Recipient $recipient;
private GlanceDataFields $glanceDataFields;

public function __construct(Application $application, GlanceDataFields $glanceDataFields)
{
Expand Down
25 changes: 15 additions & 10 deletions src/Api/Glances/GlanceDataFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,37 @@
class GlanceDataFields
{
/**
* @var null|string (100 characters) - a description of the data being shown, such as "Widgets Sold"
* (100 characters) - a description of the data being shown, such as "Widgets Sold"
*/
private $title;
private ?string $title;

/**
* @var null|string (100 characters) - the main line of data, used on most screens
* (100 characters) - the main line of data, used on most screens
*/
private $text;
private ?string $text;

/**
* @var null|string (100 characters) - a second line of data
* (100 characters) - a second line of data
*/
private $subtext;
private ?string $subtext;

/**
* @var null|int (integer, may be negative) - shown on smaller screens; useful for simple counts
* (integer, may be negative) - shown on smaller screens; useful for simple counts
*/
private $count;
private ?int $count;

/**
* @var null|int (integer 0 through 100, inclusive) - shown on some screens as a progress bar/circle
* (integer 0 through 100, inclusive) - shown on some screens as a progress bar/circle
*/
private $percent;
private ?int $percent;

public function __construct()
{
$this->title = null;
$this->text = null;
$this->subtext = null;
$this->count = null;
$this->percent = null;
}

public function getTitle(): ?string
Expand Down
14 changes: 7 additions & 7 deletions src/Api/Groups/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@
class Group
{
/**
* @var string group key
* Group key
*/
private $key;
private string $key;

/**
* @var Application pushover application this group belongs to
* Pushover application this group belongs to
*/
private $application;
private Application $application;

/**
* @var string name of the group
* Name of the group
*/
private $name;
private string $name;

/**
* @var Recipient[] group users
*/
private $users;
private array $users;

/**
* @param string $key Group key. (Use any valid key or placeholder e.g. str_repeat('0', 30) if you are creating a group)
Expand Down
21 changes: 10 additions & 11 deletions src/Api/Licensing/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,29 @@ class License
* License for any device type
*/
public const OS_ANY = null;
private Application $application;

/**
* @var Application
* (required unless email supplied) - the user's Pushover user key
*/
private $application;
private ?Recipient $recipient;

/**
* @var null|recipient (required unless email supplied) - the user's Pushover user key
* (required unless user supplied) - the user's e-mail address
*/
private $recipient;
private ?string $email;

/**
* @var null|string (required unless user supplied) - the user's e-mail address
* Can be left blank, or one of Android, iOS, or Desktop
*/
private $email;

/**
* @var null|string can be left blank, or one of Android, iOS, or Desktop
*/
private $os;
private ?string $os;

public function __construct(Application $application)
{
$this->application = $application;
$this->recipient = null;
$this->email = null;
$this->os = null;
}

public function getApplication(): Application
Expand Down
8 changes: 2 additions & 6 deletions src/Api/Message/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,14 @@ class Attachment
* A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) is a standard
* that indicates the nature and format of a document, file, or assortment of bytes.
* In case of Pushover attachment only image MIME type is accepted.
*
* @var string
*/
private $mimeType;
private string $mimeType;

/**
* Path to the file.
* Path and filename of the image file to be sent with notification.
*
* @var string
*/
private $filename;
private string $filename;

public function __construct(string $filename, string $mimeType)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Api/Message/CustomSound.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ class CustomSound
* without having to copy sound files to each device. Can only contain letters, numbers, underscores, and dashes,
* and is limited to 20 characters, such as "warning", "door_open", or "long_siren2". It cannot match the name
* of any built-in sound and will be specified as the sound parameter through our API when requesting this sound.
*
* @var string
*/
private $customSound;
private string $customSound;

public function __construct(string $customSound)
{
Expand Down
37 changes: 13 additions & 24 deletions src/Api/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,51 +26,39 @@ class Message
{
/**
* (required) - your message.
*
* @var string
*/
private $message;
private string $message;

/**
* Your message's title, otherwise your app's name is used.
*
* @var null|string
*/
private $title;
private ?string $title;

/**
* A supplementary URL to show with your message.
*
* @var null|string
*/
private $url;
private ?string $url;

/**
* A title for your supplementary URL, otherwise just the URL is shown.
*
* @var null|string
*/
private $urlTitle;
private ?string $urlTitle;

/**
* Message Priority.
* Send as -2 to generate no notification/alert, -1 to always send as a quiet notification,
* 1 to display as high-priority and bypass the user's quiet hours,
* or 2 to also require confirmation from the user.
* See {@link https://pushover.net/api#priority} for more information.
*
* @var null|Priority
*/
private $priority;
private ?Priority $priority;

/**
* HTML Message.
* As of version 2.3 of our device clients, messages can be formatted with HTML tags.
* See {@link https://pushover.net/api#html} for more information.
*
* @var null|bool
*/
private $isHtml = false;
private ?bool $isHtml = false;

/**
* Message Time.
Expand All @@ -79,10 +67,8 @@ class Message
* In some cases, such as when messages have been queued on a remote server before reaching the Pushover servers,
* or delivered to Pushover out of order, this default timestamping may cause a confusing order of messages when viewed on the user's device.
* For these scenarios, your app may send messages to the API with the timestamp parameter set to the Unix timestamp of the original message.
*
* @var \DateTime
*/
private $timestamp;
private \DateTime $timestamp;

/**
* Normally a message delivered to a device is retained on the device until it is deleted by the user,
Expand All @@ -93,10 +79,8 @@ class Message
* The ttl parameter is ignored for messages with a priority value of 2.
*
* The ttl value must be a positive number of seconds, and is counted from the time the message is received by our API.
*
* @var null|int
*/
private $ttl;
private ?int $ttl;

public function __construct(string $message, string $title = null)
{
Expand All @@ -107,6 +91,11 @@ public function __construct(string $message, string $title = null)
}

$this->timestamp = new \DateTime();

$this->ttl = null;
$this->priority = null;
$this->url = null;
$this->urlTitle = null;
}

public function getMessage(): string
Expand Down
39 changes: 10 additions & 29 deletions src/Api/Message/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,22 @@
*/
class Notification
{
/**
* @var Application
*/
private $application;

/**
* @var Recipient
*/
private $recipient;

/**
* @var Message
*/
private $message;

/**
* @var null|Sound
*/
private $sound;

/**
* @var null|CustomSound
*/
private $customSound;

/**
* @var null|Attachment
*/
private $attachment;
private Application $application;
private Recipient $recipient;
private Message $message;
private ?Sound $sound;
private ?CustomSound $customSound;
private ?Attachment $attachment;

public function __construct(Application $application, Recipient $recipient, Message $message)
{
$this->application = $application;
$this->recipient = $recipient;
$this->message = $message;

$this->sound = null;
$this->customSound = null;
$this->attachment = null;
}

public function getApplication(): Application
Expand Down
16 changes: 4 additions & 12 deletions src/Api/Message/Priority.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,26 @@ class Priority

/**
* Priority of the message.
*
* @var int
*/
private $priority;
private int $priority;

/**
* Specifies how often (in seconds) the Pushover servers will send the same notification to the user.
* Used only and required with Emergency Priority.
*
* @var null|int
*/
private $retry;
private ?int $retry;

/**
* Specifies how many seconds your notification will continue to be retried for (every "retry" seconds).
* Used only and required with Emergency Priority.
*
* @var null|int
*/
private $expire;
private ?int $expire;

/**
* (Optional) may be supplied with a publicly-accessible URL that our servers will send a request to when the user has acknowledged your notification.
* Used only but not required with Emergency Priority.
*
* @var null|string
*/
private $callback;
private ?string $callback;

public function __construct(int $priority = self::NORMAL, int $retry = null, int $expire = null)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Api/Message/Sound.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ class Sound
* Notification Sound
* Users can choose from 22 different default sounds to play when receiving notifications, rather than our standard Pushover tone.
* Applications can override a user's default tone choice on a per-notification basis.
*
* @var string
*/
private $sound;
private string $sound;

public function __construct(string $sound)
{
Expand Down
Loading
Loading