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

Update PHP language level & better RFC compliance #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor/
/.idea/
/composer.lock
/.phpunit.result.cache
/.phpunit.result.cache
.phpcs-cache
29 changes: 18 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"name": "simshaun/recurr",
"type": "library",
"description": "PHP library for working with recurrence rules",
"keywords": ["rrule", "recurrence", "recurring", "events", "dates"],
"keywords": [
"rrule",
"recurrence",
"recurring",
"events",
"dates"
],
"homepage": "https://github.com/simshaun/recurr",
"type": "library",
"license": "MIT",
"authors": [
{
Expand All @@ -13,12 +19,18 @@
}
],
"require": {
"php": "^7.2||^8.0",
"doctrine/collections": "~1.6"
"php": "^8.0",
"doctrine/collections": "^1.6"
},
"require-dev": {
"phpunit/phpunit": "^8.5.16",
"symfony/yaml": "^5.3"
"phpunit/phpunit": "^8.5 || ^9.0",
"squizlabs/php_codesniffer": "^3.6",
"symfony/yaml": "^5.3 || ^6.0"
},
"extra": {
"branch-alias": {
"dev-master": "0.x-dev"
}
},
"autoload": {
"psr-4": {
Expand All @@ -30,11 +42,6 @@
"Recurr\\Test\\": "tests/Recurr/Test"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.x-dev"
}
},
"scripts": {
"test": "./vendor/bin/phpunit --color=always"
}
Expand Down
20 changes: 20 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset
name="PHPCS Coding Standards"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="colors" />
<arg name="cache" value=".phpcs-cache"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<rule ref="PSR12"/>

<file>src</file>
<file>tests</file>

</ruleset>
32 changes: 13 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd">
<testsuites>
<testsuite name="Recurr Test Suite">
<directory suffix="Test.php">./tests/Recurr/Test/</directory>
</testsuite>
</testsuites>
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
>

<filter>
<whitelist>
<directory suffix=".php">./src/Recurr/</directory>
</whitelist>
</filter>
<coverage>
<include>
<directory suffix=".php">./src/Recurr/</directory>
</include>
</coverage>

<testsuites>
<testsuite name="Recurr Test Suite">
<directory>./tests/Recurr/Test/</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 7 additions & 7 deletions src/Recurr/DateExclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Recurr;

use DateTimeInterface;

/**
* Class DateExclusion is a container for a single \DateTimeInterface.
*
Expand All @@ -23,23 +25,21 @@
*/
class DateExclusion
{
/** @var \DateTimeInterface */
public $date;
public DateTimeInterface $date;

/** @var bool Day of year */
public $hasTime;
public bool $hasTime;

/** @var bool */
public $isUtcExplicit;
public bool $isUtcExplicit;

/**
* Constructor
*
* @param \DateTimeInterface $date
* @param DateTimeInterface $date
* @param bool $hasTime
* @param bool $isUtcExplicit
*/
public function __construct(\DateTimeInterface $date, $hasTime = true, $isUtcExplicit = false)
public function __construct(DateTimeInterface $date, bool $hasTime = true, bool $isUtcExplicit = false)
{
$this->date = $date;
$this->hasTime = $hasTime;
Expand Down
14 changes: 7 additions & 7 deletions src/Recurr/DateInclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Recurr;

use DateTimeInterface;

/**
* Class DateInclusion is a container for a single \DateTimeInterface.
*
Expand All @@ -23,23 +25,21 @@
*/
class DateInclusion
{
/** @var \DateTimeInterface */
public $date;
public DateTimeInterface $date;

/** @var bool Day of year */
public $hasTime;
public bool $hasTime;

/** @var bool */
public $isUtcExplicit;
public bool $isUtcExplicit;

/**
* Constructor
*
* @param \DateTimeInterface $date
* @param DateTimeInterface $date
* @param bool $hasTime
* @param bool $isUtcExplicit
*/
public function __construct(\DateTimeInterface $date, $hasTime = true, $isUtcExplicit = false)
public function __construct(DateTimeInterface $date, bool $hasTime = true, bool $isUtcExplicit = false)
{
$this->date = $date;
$this->hasTime = $hasTime;
Expand Down
25 changes: 13 additions & 12 deletions src/Recurr/DateInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Recurr;

use DateTimeInterface;

/**
* Class DateInfo is responsible for holding information based on a particular
* date that is applicable to a Rule.
Expand All @@ -22,52 +24,51 @@
*/
class DateInfo
{
/** @var \DateTime */
public $dt;
public DateTimeInterface $dt;

/**
* @var int Number of days in the month.
*/
public $monthLength;
public int $monthLength;

/**
* @var int Number of days in the year (365 normally, 366 on leap years)
*/
public $yearLength;
public int $yearLength;

/**
* @var int Number of days in the next year (365 normally, 366 on leap years)
*/
public $nextYearLength;
public int $nextYearLength;

/**
* @var array Day of year of last day of each month.
*/
public $mRanges;
public array $mRanges;

/** @var int Day of week */
public $dayOfWeek;
public int $dayOfWeek;

/** @var int Day of week of the year's first day */
public $dayOfWeekYearDay1;
public int $dayOfWeekYearDay1;

/**
* @var array Month number for each day of the year.
*/
public $mMask;
public array $mMask;

/**
* @var array Month-daynumber for each day of the year.
*/
public $mDayMask;
public array $mDayMask;

/**
* @var array Month-daynumber for each day of the year (in reverse).
*/
public $mDayMaskNeg;
public array $mDayMaskNeg;

/**
* @var array Day of week (0-6) for each day of the year, 0 being Monday
*/
public $wDayMask;
public array $wDayMask;
}
Loading