Skip to content

Commit

Permalink
Merge pull request #4 from natenolting/master
Browse files Browse the repository at this point in the history
Psalm
  • Loading branch information
natenolting committed Feb 21, 2019
2 parents 7472c18 + de7a4fe commit f09c445
Show file tree
Hide file tree
Showing 37 changed files with 744 additions and 125 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Gemfile.lock
*.phar
/phan.log
phpstan.phar
psalm
psalm.log.*
psalm.log
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ before_script:
- if [ "$PHAN" != "" ]; then curl -L https://github.com/phan/phan/releases/download/0.12.0/phan.phar -o phan.phar; fi;
script:
- vendor/bin/phpunit
- bash psalm.sh
- if [ "$STATIC_ANALYSIS" != "" ]; then php phpstan.phar analyse --level=4 src; fi;
- if [ "$PHAN" != "" ]; then php phan.phar; fi;
cache:
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"phpunit/phpunit": "^4.8",
"mockery/mockery": "^0.9.9",
"fzaninotto/faker": "^1.6",
"symfony/var-dumper": "^3.2"
"symfony/var-dumper": "^3.2",
"mikey179/vfsStream": "^1.6"
},
"autoload": {
"psr-4": {
Expand Down
52 changes: 49 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions psalm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Install and run Psalm php static analysis tool
# https://getpsalm.org/docs/
PSALM_DIR=psalm
mkdir ./$PSALM_DIR || :
cd ./$PSALM_DIR;
if [ ! -f composer.json ]; then composer init --no-interaction; fi;
(composer info -N | grep -q "vimeo/psalm") && : || composer require vimeo/psalm --dev --no-suggest --no-ansi --no-interaction --no-progress --ignore-platform-reqs
cd ..

# Initialize Psalm if xml file does not exist
if [ ! -f ./psalm.xml ]; then ./$PSALM_DIR/vendor/bin/psalm init; fi;
./$PSALM_DIR/vendor/bin/psalm

#fin
53 changes: 53 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config file://./psalm/vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>
27 changes: 27 additions & 0 deletions src/Bandolier/Exception/Collection/KeyHasUseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* KeyHasUseException
*
* Created 6/9/17 12:46 PM
* Exception handler for in use keys
*
* @author Nate Nolting <naten@paulbunyan.net>
* @package Pbc\Bandolier\Type\Collection\Exception
*/

namespace Pbc\Bandolier\Exception\Collection;

use Pbc\Bandolier\Exception\Exception;
use Pbc\Bandolier\Exception\ExceptionInterface;

class KeyHasUseException extends Exception implements ExceptionInterface{

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
27 changes: 27 additions & 0 deletions src/Bandolier/Exception/Collection/KeyInvalidException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* KeyInvalidException
*
* Created 6/9/17 12:44 PM
* Exception handler for invalid keys from collection
*
* @author Nate Nolting <naten@paulbunyan.net>
* @package Pbc\Bandolier\Type\Collection\Exception
*/

namespace Pbc\Bandolier\Exception\Collection;

use Pbc\Bandolier\Exception\Exception;
use Pbc\Bandolier\Exception\ExceptionInterface;

class KeyInvalidException extends Exception implements ExceptionInterface {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
4 changes: 4 additions & 0 deletions src/Bandolier/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
namespace Pbc\Bandolier\Exception;

abstract class Exception extends \Exception implements ExceptionInterface {}
63 changes: 63 additions & 0 deletions src/Bandolier/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Pbc\Bandolier\Exception;

interface ExceptionInterface
{
// Protected methods inherited from Exception class
/**
* Exception message
* @return mixed
*/
public function getMessage();

/**
* User-defined Exception code
* @return mixed
*/
public function getCode();

/**
* Source filename
*
* @return mixed
*/
public function getFile();

/**
* Source line
*
* @return mixed
*/
public function getLine();

/**
* An array of the backtrace()
*
* @return mixed
*/
public function getTrace();

/**
* Formatted string of trace
*
* @return mixed
*/
public function getTraceAsString();

// Overrideable methods inherited from Exception class

/**
* formatted string for display
*
* @return mixed
*/
public function __toString();

/**
* ExceptionInterface constructor.
* @param string $message
* @param int $code
*/
public function __construct($message, $code = 0);
}
17 changes: 17 additions & 0 deletions src/Bandolier/Exception/Setup/UnknownPropertyException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Pbc\Bandolier\Exception\Setup;

use Pbc\Bandolier\Exception\Exception;
use Pbc\Bandolier\Exception\ExceptionInterface;

class UnknownPropertyException extends Exception implements ExceptionInterface {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
17 changes: 17 additions & 0 deletions src/Bandolier/Exception/Type/Numbers/OutOfRangeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Pbc\Bandolier\Exception\Type\Numbers;

use Pbc\Bandolier\Exception\Exception;
use Pbc\Bandolier\Exception\ExceptionInterface;

class OutOfRangeException extends Exception implements ExceptionInterface {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
14 changes: 14 additions & 0 deletions src/Bandolier/Exception/Writable/LocationDoesExist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Pbc\Bandolier\Exception\Writable;

class LocationDoesExist extends WritableLocation {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
14 changes: 14 additions & 0 deletions src/Bandolier/Exception/Writable/LocationIsADirectory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Pbc\Bandolier\Exception\Writable;

class LocationIsADirectory extends WritableLocation {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
14 changes: 14 additions & 0 deletions src/Bandolier/Exception/Writable/LocationIsWritable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Pbc\Bandolier\Exception\Writable;

class LocationIsWritable extends WritableLocation {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
17 changes: 17 additions & 0 deletions src/Bandolier/Exception/Writable/WritableLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Pbc\Bandolier\Exception\Writable;

use Pbc\Bandolier\Exception\Exception;
use Pbc\Bandolier\Exception\ExceptionInterface;

class WritableLocation extends Exception implements ExceptionInterface {

/**
* @param string $message
* @param int $code
* @return void
*/
public function __construct($message = '', $code = 0) {
parent::__construct($message, $code);
}
}
Loading

0 comments on commit f09c445

Please sign in to comment.