Skip to content

Commit

Permalink
Merge pull request #431 from sabre-io/feature/add-phpstan
Browse files Browse the repository at this point in the history
Feature/add phpstan
  • Loading branch information
DeepDiver1975 committed Oct 29, 2018
2 parents a2a813d + 9fed1c4 commit 898b2e7
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 23 deletions.
27 changes: 20 additions & 7 deletions .travis.yml
Expand Up @@ -8,19 +8,32 @@ php:
- 7.2
- 7.3

env:
global:
- RUN_PHPSTAN="FALSE"

matrix:
include:
- name: 'PHPStan'
php: 7.2
env: RUN_PHPSTAN="TRUE"
fast_finish: true
allow_failures:
- php: 5.5

install:
- if [ $RUN_PHPSTAN == "TRUE" ]; then wget https://github.com/phpstan/phpstan/releases/download/0.10.3/phpstan.phar; fi

before_script:
- composer install
- composer install

script:
- ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml
- if [ $RUN_PHPSTAN == "FALSE" ]; then ./bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml; fi
- if [ $RUN_PHPSTAN == "TRUE" ]; then php phpstan.phar analyse -c phpstan.neon lib; fi

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)

cache:
directories:
- $HOME/.composer/cache

matrix:
allow_failures:
- php: 5.5
11 changes: 7 additions & 4 deletions lib/Document.php
Expand Up @@ -95,13 +95,16 @@ abstract class Document extends Component
public function __construct()
{
$args = func_get_args();
$name = static::$defaultName;
if (0 === count($args) || is_array($args[0])) {
array_unshift($args, $this, static::$defaultName);
call_user_func_array(['parent', '__construct'], $args);
$children = isset($args[0]) ? $args[0] : [];
$defaults = isset($args[1]) ? $args[1] : true;
} else {
array_unshift($args, $this);
call_user_func_array(['parent', '__construct'], $args);
$name = $args[0];
$children = isset($args[1]) ? $args[1] : [];
$defaults = isset($args[2]) ? $args[2] : true;
}
parent::__construct($this, $name, $children, $defaults);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Parser/Json.php
Expand Up @@ -4,6 +4,7 @@

use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Document;
use Sabre\VObject\EofException;
use Sabre\VObject\ParseException;

Expand Down Expand Up @@ -43,7 +44,7 @@ class Json extends Parser
* @param resource|string|array|null $input
* @param int $options
*
* @return Sabre\VObject\Document
* @return \Sabre\VObject\Document
*/
public function parse($input = null, $options = 0)
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Parser/MimeDir.php
Expand Up @@ -7,6 +7,7 @@
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Document;
use Sabre\VObject\EofException;
use Sabre\VObject\Node;
use Sabre\VObject\ParseException;

/**
Expand Down Expand Up @@ -72,7 +73,7 @@ class MimeDir extends Parser
* @param string|resource|null $input
* @param int $options
*
* @return Sabre\VObject\Document
* @return \Sabre\VObject\Document
*/
public function parse($input = null, $options = 0)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Parser/XML.php
Expand Up @@ -40,7 +40,7 @@ class XML extends Parser
/**
* Document, root component.
*
* @var Sabre\VObject\Document
* @var \Sabre\VObject\Document
*/
protected $root;

Expand Down Expand Up @@ -69,7 +69,7 @@ public function __construct($input = null, $options = 0)
*
* @throws \Exception
*
* @return Sabre\VObject\Document
* @return \Sabre\VObject\Document
*/
public function parse($input = null, $options = 0)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Property/ICalendar/DateTime.php
Expand Up @@ -131,7 +131,7 @@ public function isFloating()
*
* @param DateTimeZone $timeZone
*
* @return DateTimeImmutable
* @return \DateTimeImmutable
*/
public function getDateTime(DateTimeZone $timeZone = null)
{
Expand All @@ -152,7 +152,7 @@ public function getDateTime(DateTimeZone $timeZone = null)
*
* @param DateTimeZone $timeZone
*
* @return DateTimeImmutable[]
* @return \DateTimeImmutable[]
* @return \DateTime[]
*/
public function getDateTimes(DateTimeZone $timeZone = null)
Expand Down
2 changes: 1 addition & 1 deletion lib/Splitter/ICalendar.php
Expand Up @@ -83,7 +83,7 @@ public function __construct($input, $options = 0)
*
* When the end is reached, null will be returned.
*
* @return Sabre\VObject\Component|null
* @return \Sabre\VObject\Component|null
*/
public function getNext()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Splitter/SplitterInterface.php
Expand Up @@ -32,7 +32,7 @@ public function __construct($input);
*
* When the end is reached, null will be returned.
*
* @return Sabre\VObject\Component|null
* @return \Sabre\VObject\Component|null
*/
public function getNext();
}
2 changes: 1 addition & 1 deletion lib/Splitter/VCard.php
Expand Up @@ -55,7 +55,7 @@ public function __construct($input, $options = 0)
*
* When the end is reached, null will be returned.
*
* @return Sabre\VObject\Component|null
* @return \Sabre\VObject\Component|null
*/
public function getNext()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/TimeZoneUtil.php
Expand Up @@ -120,7 +120,7 @@ class TimeZoneUtil
* @param string $tzid
* @param Sabre\VObject\Component $vcalendar
*
* @return DateTimeZone
* @return \DateTimeZone
*/
public static function getTimeZone($tzid, Component $vcalendar = null, $failIfUncertain = false)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Writer.php
Expand Up @@ -58,10 +58,10 @@ public static function writeXml(Component $component)

if ($component instanceof Component\VCalendar) {
$writer->startElement('icalendar');
$writer->writeAttribute('xmlns', Parser\Xml::XCAL_NAMESPACE);
$writer->writeAttribute('xmlns', Parser\XML::XCAL_NAMESPACE);
} else {
$writer->startElement('vcards');
$writer->writeAttribute('xmlns', Parser\Xml::XCARD_NAMESPACE);
$writer->writeAttribute('xmlns', Parser\XML::XCARD_NAMESPACE);
}

$component->xmlSerialize($writer);
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
@@ -0,0 +1,3 @@
parameters:
level: 0
bootstrap: %currentWorkingDirectory%/vendor/autoload.php

0 comments on commit 898b2e7

Please sign in to comment.