More PHPStan fixes

This commit is contained in:
Timothy Warren 2017-02-22 15:08:29 -05:00
parent adc331d60d
commit 14e8fa9f03
18 changed files with 57 additions and 38 deletions

View File

@ -28,25 +28,14 @@ if ($timezone === '' || $timezone === FALSE)
ini_set('date.timezone', 'GMT'); ini_set('date.timezone', 'GMT');
} }
/** // Load composer autoloader
* Joins paths together. Variadic to take an require __DIR__ . '/vendor/autoload.php';
* arbitrary number of arguments
*
* @return string
*/
function _dir()
{
return implode(DIRECTORY_SEPARATOR, func_get_args());
}
// Define base directories // Define base directories
$APP_DIR = _dir(__DIR__, 'app'); $APP_DIR = _dir(__DIR__, 'app');
$APPCONF_DIR = _dir($APP_DIR, 'appConf'); $APPCONF_DIR = _dir($APP_DIR, 'appConf');
$CONF_DIR = _dir($APP_DIR, 'config'); $CONF_DIR = _dir($APP_DIR, 'config');
// Load composer autoloader
require _dir(__DIR__, 'vendor/autoload.php');
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Setup error handling // Setup error handling
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -40,7 +40,7 @@ class MenuGenerator extends UrlGenerator {
/** /**
* Request object * Request object
* *
* @var \Aura\Web\Request * @var \Psr\Http\Message\RequestInterface
*/ */
protected $request; protected $request;

View File

@ -25,6 +25,8 @@ use Psr\Log\NullLogger;
class APIRequestBuilderTest extends TestCase { class APIRequestBuilderTest extends TestCase {
protected $builder;
public function setUp() public function setUp()
{ {
$this->builder = new class extends APIRequestBuilder { $this->builder = new class extends APIRequestBuilder {

View File

@ -23,6 +23,11 @@ use Aviat\Ion\Json;
class AnimeListTransformerTest extends AnimeClientTestCase { class AnimeListTransformerTest extends AnimeClientTestCase {
protected $dir;
protected $beforeTransform;
protected $afterTransform;
protected $transformer;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -23,6 +23,11 @@ use Aviat\Ion\Json;
class AnimeTransformerTest extends AnimeClientTestCase { class AnimeTransformerTest extends AnimeClientTestCase {
protected $dir;
protected $beforeTransform;
protected $afterTransform;
protected $transformer;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -23,6 +23,12 @@ use Aviat\Ion\Json;
class MangaListTransformerTest extends AnimeClientTestCase { class MangaListTransformerTest extends AnimeClientTestCase {
protected $dir;
protected $rawBefore;
protected $beforeTransform;
protected $afterTransform;
protected $transformer;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -23,6 +23,11 @@ use Aviat\Ion\Json;
class MangaTransformerTest extends AnimeClientTestCase { class MangaTransformerTest extends AnimeClientTestCase {
protected $dir;
protected $beforeTransform;
protected $afterTransform;
protected $transformer;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -6,7 +6,7 @@ use Aviat\AnimeClient\API\{APIRequestBuilder, ParallelAPIRequest};
use Aviat\Ion\Friend; use Aviat\Ion\Friend;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class ParallelAPIRequestsTest extends TestCase { class ParallelAPIRequestTest extends TestCase {
public function testAddStringUrlRequest() public function testAddStringUrlRequest()
{ {

View File

@ -21,6 +21,12 @@ use PHPUnit\Framework\TestCase;
class XMLTest extends TestCase { class XMLTest extends TestCase {
protected $malExport;
protected $xml;
protected $expectedXml;
protected $object;
protected $array;
public function setUp() public function setUp()
{ {
$this->malExport = file_get_contents(__DIR__ . '/../test_data/XML/MALExport.xml'); $this->malExport = file_get_contents(__DIR__ . '/../test_data/XML/MALExport.xml');

View File

@ -16,12 +16,14 @@
namespace Aviat\AnimeClient\Tests; namespace Aviat\AnimeClient\Tests;
use function Aviat\AnimeClient\_dir;
class AnimeClientTest extends AnimeClientTestCase { class AnimeClientTest extends AnimeClientTestCase {
/** /**
* Basic sanity test for _dir function * Basic sanity test for _dir function
*/ */
public function testDir() public function testDir()
{ {
$this->assertEquals('foo' . \DIRECTORY_SEPARATOR . 'bar', \_dir('foo', 'bar')); $this->assertEquals('foo' . \DIRECTORY_SEPARATOR . 'bar', _dir('foo', 'bar'));
} }
} }

View File

@ -18,8 +18,9 @@ namespace Aviat\AnimeClient\Tests;
use const Aviat\AnimeClient\SRC_DIR; use const Aviat\AnimeClient\SRC_DIR;
use function Aviat\AnimeClient\_dir;
use Aura\Web\WebFactory; use Aura\Web\WebFactory;
use Aviat\AnimeClient\AnimeClient;
use Aviat\Ion\Json; use Aviat\Ion\Json;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Zend\Diactoros\{ use Zend\Diactoros\{

View File

@ -22,6 +22,9 @@ use Aviat\Ion\Friend;
use ConsoleKit\Console; use ConsoleKit\Console;
class BaseCommandTest extends AnimeClientTestCase { class BaseCommandTest extends AnimeClientTestCase {
protected $base;
protected $friend;
public function setUp() public function setUp()
{ {
$this->base = new BaseCommand(new Console()); $this->base = new BaseCommand(new Console());

View File

@ -27,6 +27,8 @@ use Aviat\AnimeClient\Controller\{
class ControllerTest extends AnimeClientTestCase { class ControllerTest extends AnimeClientTestCase {
protected $BaseController;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -28,6 +28,7 @@ class DispatcherTest extends AnimeClientTestCase {
protected $container; protected $container;
protected $router; protected $router;
protected $config; protected $config;
protected $urlGenerator;
protected function doSetUp($config, $uri, $host) protected function doSetUp($config, $uri, $host)
{ {

View File

@ -14,12 +14,16 @@
* @link https://github.com/timw4mail/HummingBirdAnimeClient * @link https://github.com/timw4mail/HummingBirdAnimeClient
*/ */
namespace Aviat\AnimeClient\Tests; namespace Aviat\AnimeClient\Tests\Helper;
use Aviat\AnimeClient\Helper\Menu as MenuHelper; use Aviat\AnimeClient\Helper\Menu as MenuHelper;
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
class MenuHelperTest extends AnimeClientTestCase { class MenuHelperTest extends AnimeClientTestCase {
protected $helper;
protected $urlGenerator;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -20,6 +20,8 @@ use Aviat\AnimeClient\RoutingBase;
class RoutingBaseTest extends AnimeClientTestCase { class RoutingBaseTest extends AnimeClientTestCase {
protected $routingBase;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -20,6 +20,8 @@ use Aviat\AnimeClient\Util;
class UtilTest extends AnimeClientTestCase { class UtilTest extends AnimeClientTestCase {
protected $util;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -10,28 +10,12 @@ if ($timezone === '' || $timezone === FALSE)
ini_set('date.timezone', 'GMT'); ini_set('date.timezone', 'GMT');
} }
// -----------------------------------------------------------------------------
// Global functions
// -----------------------------------------------------------------------------
/**
* Joins paths together. Variadic to take an
* arbitrary number of arguments
*
* @return string
*/
function _dir()
{
return implode(DIRECTORY_SEPARATOR, func_get_args());
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Autoloading // Autoloading
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
require _dir(__DIR__, 'AnimeClientTestCase.php'); require __DIR__ . '/AnimeClientTestCase.php';
require _dir(__DIR__, '../vendor/autoload.php'); require __DIR__ . '/../vendor/autoload.php';
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Ini Settings // Ini Settings
@ -51,7 +35,7 @@ $_SESSION = [];
$_COOKIE = []; $_COOKIE = [];
// Request base test case and mocks // Request base test case and mocks
require _dir(__DIR__, 'TestSessionHandler.php'); require __DIR__ . '/TestSessionHandler.php';
require _dir(__DIR__, 'mocks.php'); require __DIR__ . '/mocks.php';
// End of bootstrap.php // End of bootstrap.php