Merge pull request #532 from flightphp/cleanup

Docblocks simplified with help of PHPCS
pull/534/head
n0nag0n 1 year ago committed by GitHub
commit 15ec8e9c87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -41,7 +41,12 @@
{
"name": "Linter - Default",
"quiet": true,
"shell_cmd": "composer lint -- --no-ansi | composer phpcs -- --no-colors",
"shell_cmd": "composer lint -- --no-ansi & composer phpcs -- --no-colors",
},
{
"name": "PHPCS",
"quiet": true,
"shell_cmd": "composer phpcs -- --no-colors"
},
{
"name": "Format",

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight;
@ -28,36 +21,46 @@ use flight\net\Route;
* It is responsible for loading an HTTP request, running the assigned services,
* and generating an HTTP response.
*
* Core methods
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*
* # Core methods
* @method void start() Starts engine
* @method void stop() Stops framework and outputs current response
* @method void halt(int $code = 200, string $message = '') Stops processing and returns a given response.
*
* Routing
* @method Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a URL to a callback function with all applicable methods
* @method void group(string $pattern, callable $callback, array $group_middlewares = []) Groups a set of routes together under a common prefix.
* @method Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a POST URL to a callback function.
* @method Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PUT URL to a callback function.
* @method Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PATCH URL to a callback function.
* @method Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a DELETE URL to a callback function.
* # Routing
* @method Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a URL to a callback function with all applicable methods
* @method void group(string $pattern, callable $callback, array $group_middlewares = [])
* Groups a set of routes together under a common prefix.
* @method Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a POST URL to a callback function.
* @method Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a PUT URL to a callback function.
* @method Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a PATCH URL to a callback function.
* @method Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a DELETE URL to a callback function.
* @method Router router() Gets router
* @method string getUrl(string $alias) Gets a url from an alias
*
* Views
* # Views
* @method void render(string $file, array $data = null, string $key = null) Renders template
* @method View view() Gets current view
*
* Request-response
* # Request-Response
* @method Request request() Gets current request
* @method Response response() Gets current response
* @method void error(Throwable $e) Sends an HTTP 500 response for any errors.
* @method void notFound() Sends an HTTP 404 response when a URL is not found.
* @method void redirect(string $url, int $code = 303) Redirects the current request to another URL.
* @method void json(mixed $data, int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSON response.
* @method void jsonp(mixed $data, string $param = 'jsonp', int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSONP response.
* @method void json(mixed $data, int $code = 200, bool $encode = true, string $charset = 'utf-8', int $option = 0)
* Sends a JSON response.
* @method void jsonp(mixed $data, string $param = 'jsonp', int $code = 200,
* bool $encode = true, string $charset = 'utf-8', int $option = 0) Sends a JSONP response.
*
* HTTP caching
* # HTTP caching
* @method void etag($id, string $type = 'strong') Handles ETag HTTP caching.
* @method void lastModified(int $time) Handles last modified HTTP caching.
*/
@ -601,7 +604,6 @@ class Engine
*
* @param int $code HTTP status code
* @param string $message Response message
*
*/
public function _halt(int $code = 200, string $message = ''): void
{

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\core\Dispatcher;
@ -19,18 +12,29 @@ use flight\net\Route;
/**
* The Flight class is a static representation of the framework.
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*
* # Core methods
* @method static void start() Starts the framework.
* @method static void path(string $path) Adds a path for autoloading classes.
* @method static void stop() Stops the framework and sends a response.
* @method static void halt(int $code = 200, string $message = '') Stop the framework with an optional status code and message.
* @method static void halt(int $code = 200, string $message = '')
* Stop the framework with an optional status code and message.
*
* @method static Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Maps a URL pattern to a callback with all applicable methods.
* @method static void group(string $pattern, callable $callback, array $group_middlewares = []) Groups a set of routes together under a common prefix.
* @method static Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a POST URL to a callback function.
* @method static Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PUT URL to a callback function.
* @method static Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a PATCH URL to a callback function.
* @method static Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '') Routes a DELETE URL to a callback function.
* # Routing
* @method static Route route(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Maps a URL pattern to a callback with all applicable methods.
* @method static void group(string $pattern, callable $callback, array $group_middlewares = [])
* Groups a set of routes together under a common prefix.
* @method static Route post(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a POST URL to a callback function.
* @method static Route put(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a PUT URL to a callback function.
* @method static Route patch(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a PATCH URL to a callback function.
* @method static Route delete(string $pattern, callable $callback, bool $pass_route = false, string $alias = '')
* Routes a DELETE URL to a callback function.
* @method static Router router() Returns Router instance.
* @method static string getUrl(string $alias) Gets a url from an alias
*
@ -44,17 +48,22 @@ use flight\net\Route;
* @method static bool has($key) Checks if a variable is set.
* @method static void clear($key = null) Clears a variable.
*
* # Views
* @method static void render($file, array $data = null, $key = null) Renders a template file.
* @method static View view() Returns View instance.
*
* # Request-Response
* @method static Request request() Returns Request instance.
* @method static Response response() Returns Response instance.
* @method static void redirect($url, $code = 303) Redirects to another URL.
* @method static void json($data, $code = 200, $encode = true, $charset = "utf8", $encodeOption = 0, $encodeDepth = 512) Sends a JSON response.
* @method static void jsonp($data, $param = 'jsonp', $code = 200, $encode = true, $charset = "utf8", $encodeOption = 0, $encodeDepth = 512) Sends a JSONP response.
* @method static void json($data, $code = 200, $encode = true, $charset = "utf8",
* $encodeOption = 0, $encodeDepth = 512) Sends a JSON response.
* @method static void jsonp($data, $param = 'jsonp', $code = 200, $encode = true,
* $charset = "utf8", $encodeOption = 0, $encodeDepth = 512) Sends a JSONP response.
* @method static void error($exception) Sends an HTTP 500 response.
* @method static void notFound() Sends an HTTP 404 response.
*
* # HTTP caching
* @method static void etag($id, $type = 'strong') Performs ETag HTTP caching.
* @method static void lastModified($time) Performs last modified HTTP caching.
*/

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2013, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\core\Loader;

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\core;
@ -19,6 +12,9 @@ use InvalidArgumentException;
* are simply aliases for class methods or functions. The Dispatcher
* allows you to hook other functions to an event that can modify the
* input parameters and/or the output.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*/
class Dispatcher
{

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\core;
@ -19,6 +12,9 @@ use Exception;
* a list of reusable class instances and can generate a new class
* instances with custom initialization parameters. It also performs
* class autoloading.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*/
class Loader
{

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace flight\database;
use PDO;

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\net;
@ -18,6 +11,9 @@ use flight\util\Collection;
* all the super globals $_GET, $_POST, $_COOKIE, and $_FILES
* are stored and accessible via the Request object.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*
* The default request properties are:
*
* - **url** - The URL being requested

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\net;
@ -17,11 +10,14 @@ use Exception;
* The Response class represents an HTTP response. The object
* contains the response headers, HTTP status code, and response
* body.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*/
class Response
{
/**
* header Content-Length.
* Content-Length header.
*/
public bool $content_length = true;
@ -312,15 +308,15 @@ class Response
\strlen($this->body);
}
/**
* Gets the response body
*
* @return string
*/
public function getBody(): string
{
return $this->body;
}
/**
* Gets the response body
*
* @return string
*/
public function getBody(): string
{
return $this->body;
}
/**
* Gets whether response body was sent.

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\net;
@ -15,6 +8,9 @@ namespace flight\net;
* The Route class is responsible for routing an HTTP request to
* an assigned callback function. The Router tries to match the
* requested URL against a series of URL patterns.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*/
class Route
{

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\net;
@ -18,6 +11,9 @@ use flight\net\Route;
* The Router class is responsible for routing an HTTP request to
* an assigned callback function. The Router tries to match the
* requested URL against a series of URL patterns.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*/
class Router
{

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\template;
@ -15,6 +8,9 @@ namespace flight\template;
* The View class represents output to be displayed. It provides
* methods for managing view data and inserts the data into
* view templates upon rendering.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
*/
class View
{

@ -1,12 +1,5 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
namespace flight\util;
@ -19,6 +12,9 @@ use JsonSerializable;
/**
* The Collection class allows you to access a set of data
* using both array and object notation.
*
* @license MIT, http://flightphp.com/license
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @implements ArrayAccess<string, mixed>
* @implements Iterator<string, mixed>
*/

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
class ReturnTypeWillChange
{
}

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="pcsg-generated-ruleset">
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd"
name="pcsg-generated-ruleset">
<description>
Created with the PHP Coding Standard Generator.
http://edorian.github.io/php-coding-standard-generator/
@ -7,6 +10,27 @@
<arg name="colors" />
<arg name="tab-width" value="4" />
<rule ref="PSR12" />
<rule ref="PSR1">
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
</rule>
<rule ref="Generic">
<exclude name="Generic.Files.LineEndings.InvalidEOLChar" />
<exclude name="Generic.PHP.ClosingPHPTag.NotFound" />
<exclude name="Generic.PHP.UpperCaseConstant.Found" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Generic.Files.EndFileNoNewline.Found" />
<exclude name="Generic.Commenting.DocComment.TagValueIndent" />
<exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine" />
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" />
<exclude name="Generic.Files.LowercasedFilename.NotFound" />
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
<exclude name="Generic.Formatting.SpaceAfterNot.Incorrect" />
<exclude name="Generic.Commenting.DocComment.SpacingBeforeShort" />
<exclude name="Generic.Commenting.DocComment.ContentAfterOpen" />
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine" />
<exclude name="Generic.Commenting.DocComment.ContentBeforeClose" />
</rule>
<file>flight/</file>
<file>tests/</file>
</ruleset>

@ -1,20 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;
class AutoloadTest extends PHPUnit\Framework\TestCase
class AutoloadTest extends TestCase
{
/**
* @var Engine
*/
private $app;
private Engine $app;
protected function setUp(): void
{

@ -1,21 +1,17 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
class CollectionTest extends PHPUnit\Framework\TestCase
declare(strict_types=1);
use flight\util\Collection;
use PHPUnit\Framework\TestCase;
class CollectionTest extends TestCase
{
/**
* @var \flight\util\Collection
*/
private $collection;
private Collection $collection;
protected function setUp(): void
{
$this->collection = new \flight\util\Collection(['a' => 1, 'b' => 2]);
$this->collection = new Collection(['a' => 1, 'b' => 2]);
}
// Get an item

@ -1,19 +1,12 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\core\Dispatcher;
use PHPUnit\Framework\TestCase;
class DispatcherTest extends PHPUnit\Framework\TestCase
class DispatcherTest extends TestCase
{
/**
* @var Dispatcher|null
*/
private Dispatcher $dispatcher;
protected function setUp(): void
@ -131,7 +124,7 @@ class DispatcherTest extends PHPUnit\Framework\TestCase
return "Hello, $name!";
});
$this->dispatcher->hook('hello', 'before', function (&$params, &$output) {
$this->dispatcher->hook('hello', 'before', function (&$params) {
// Manipulate the parameter
$params[0] = 'Fred';
});

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use flight\net\Response;
@ -263,7 +258,7 @@ class EngineTest extends TestCase
$this->assertEquals(200, $engine->response()->status());
}
public function testJsonPBadParam()
public function testJsonpBadParam()
{
$engine = new Engine();
$engine->jsonp(['key1' => 'value1', 'key2' => 'value2']);

@ -1,20 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;
class FilterTest extends PHPUnit\Framework\TestCase
class FilterTest extends TestCase
{
/**
* @var Engine
*/
private $app;
private Engine $app;
protected function setUp(): void
{
@ -28,7 +21,7 @@ class FilterTest extends PHPUnit\Framework\TestCase
return "Hello, $name!";
});
$this->app->before('hello', function (&$params, &$output) {
$this->app->before('hello', function (&$params) {
// Manipulate the parameter
$params[0] = 'Fred';
});
@ -50,15 +43,15 @@ class FilterTest extends PHPUnit\Framework\TestCase
return "Bye, $name!";
});
$this->app->before('bye', function (&$params, &$output) {
$this->app->before('bye', function (&$params) {
$params[0] = 'Bob';
});
$this->app->before('bye', function (&$params, &$output) {
$this->app->before('bye', function (&$params) {
$params[0] = 'Fred';
return false;
});
$this->app->before('bye', function (&$params, &$output) {
$this->app->before('bye', function (&$params) {
$params[0] = 'Ted';
});

@ -1,18 +1,15 @@
<?php
declare(strict_types=1);
use flight\Engine;
use flight\net\Request;
use flight\net\Response;
use flight\net\Router;
use flight\template\View;
use PHPUnit\Framework\TestCase;
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
class FlightTest extends PHPUnit\Framework\TestCase
class FlightTest extends TestCase
{
protected function setUp(): void
{
@ -79,11 +76,11 @@ class FlightTest extends PHPUnit\Framework\TestCase
self::assertIsObject($user);
self::assertInstanceOf(User::class, $user);
Flight::unregister('user');
Flight::unregister('user');
self::expectException(Exception::class);
self::expectExceptionMessage('user must be a mapped method.');
$user = Flight::user();
self::expectException(Exception::class);
self::expectExceptionMessage('user must be a mapped method.');
$user = Flight::user();
}
// Map a function

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\core\Loader;
use PHPUnit\Framework\TestCase;

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;

@ -1,22 +1,13 @@
<?php
use flight\database\PdoWrapper;
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\database\PdoWrapper;
use PHPUnit\Framework\TestCase;
class PdoWrapperTest extends PHPUnit\Framework\TestCase
class PdoWrapperTest extends TestCase
{
/**
* @var Pdo_Wrapper
*/
private $pdo_wrapper;
private PdoWrapper $pdo_wrapper;
protected function setUp(): void
{

@ -1,15 +1,11 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2013, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;
class RedirectTest extends PHPUnit\Framework\TestCase
class RedirectTest extends TestCase
{
private Engine $app;

@ -1,11 +1,6 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;

@ -1,15 +1,11 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;
class RenderTest extends PHPUnit\Framework\TestCase
class RenderTest extends TestCase
{
private Engine $app;

@ -1,16 +1,12 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\net\Request;
use flight\util\Collection;
use PHPUnit\Framework\TestCase;
class RequestTest extends PHPUnit\Framework\TestCase
class RequestTest extends TestCase
{
private Request $request;

@ -1,17 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\net\Request;
use flight\net\Response;
use flight\util\Collection;
use PHPUnit\Framework\TestCase;
class ResponseTest extends PHPUnit\Framework\TestCase
class ResponseTest extends TestCase
{
protected function setUp(): void
{
@ -177,7 +173,7 @@ class ResponseTest extends PHPUnit\Framework\TestCase
'max-age=0',
]
];
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self
{
$this->test_sent_headers[] = $header_string;
return $this;
@ -216,7 +212,7 @@ class ResponseTest extends PHPUnit\Framework\TestCase
$response = new class extends Response {
protected $test_sent_headers = [];
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self
{
$this->test_sent_headers[] = $header_string;
return $this;

@ -1,17 +1,13 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2011, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
declare(strict_types=1);
use flight\core\Dispatcher;
use flight\net\Request;
use flight\net\Router;
use PHPUnit\Framework\TestCase;
class RouterTest extends PHPUnit\Framework\TestCase
class RouterTest extends TestCase
{
private Router $router;
@ -43,15 +39,14 @@ class RouterTest extends PHPUnit\Framework\TestCase
// Checks if a route was matched with a given output
public function check($str = '')
{
/*
$route = $this->router->route($this->request);
/*$route = $this->router->route($this->request);
$params = array_values($route->params);
$this->assertTrue(is_callable($route->callback));
call_user_func_array($route->callback, $params);
*/
call_user_func_array($route->callback, $params);*/
$this->routeRequest();
$this->expectOutputString($str);

@ -1,21 +1,17 @@
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
class VariableTest extends PHPUnit\Framework\TestCase
declare(strict_types=1);
use flight\Engine;
use PHPUnit\Framework\TestCase;
class VariableTest extends TestCase
{
/**
* @var \flight\Engine
*/
private $app;
private Engine $app;
protected function setUp(): void
{
$this->app = new \flight\Engine();
$this->app = new Engine();
}
// Set and get a variable

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use flight\template\View;
use PHPUnit\Framework\TestCase;
@ -117,7 +119,7 @@ class ViewTest extends TestCase
$this->assertEquals('&lt;script&gt;', $result);
}
public function testENoNeedToEscape()
public function testeNoNeedToEscape()
{
$this->expectOutputString('script');
$result = $this->view->e('script');

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
class Factory
{
// Cannot be instantiated

@ -1,13 +1,15 @@
<?php
declare(strict_types=1);
class Hello
{
public function sayHi()
public function sayHi(): string
{
return 'hello';
}
public static function sayBye()
public static function sayBye(): string
{
return 'goodbye';
}

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
class TesterClass
{
public $param1;

@ -1,10 +1,12 @@
<?php
declare(strict_types=1);
class User
{
public $name;
public string $name;
public function __construct($name = '')
public function __construct(string $name = '')
{
$this->name = $name;
}

@ -1,6 +1,9 @@
<?php
declare(strict_types=1);
$path = file_exists(__DIR__ . '/../vendor/autoload.php')
? __DIR__ . '/../vendor/autoload.php'
: __DIR__ . '/../flight/autoload.php';
require_once($path);

Loading…
Cancel
Save