Skip to content

Commit

Permalink
fix docs bug & reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Prasetyo committed Aug 13, 2015
1 parent bc1b9ab commit 2b106b9
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function periodic($interval, callable $callback)
*/
public function isServerExist()
{
if (! $this->container->offsetExists('Server')) {
if (!$this->container->offsetExists('Server')) {
throw new \RuntimeException('server must be set in container');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Events/BeforeRouteEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Vinnige\Events;

use Symfony\Component\EventDispatcher\Event;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\EventDispatcher\Event;

/**
* Class BeforeRouteEvent
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Container/LaravelContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(Container $container)

/**
* @param array|string $abstract
* @param callable|\Closure|null $concrete
* @param string|\Closure|null $concrete
*/
public function bind($abstract, $concrete = null)
{
Expand All @@ -35,7 +35,7 @@ public function bind($abstract, $concrete = null)

/**
* @param array|string $abstract
* @param null $concrete
* @param string|\Closure|null $concrete
*/
public function singleton($abstract, $concrete = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Http/Exceptions/GoneHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class GoneHttpException extends HttpException
*/
public function __construct($message = '', $code = 0, \Exception $previous = null)
{
parent::__construct(410, $message, $code, $previous);
parent::__construct(410, $message, [], $code, $previous);
}
}
2 changes: 1 addition & 1 deletion src/Lib/Http/Exceptions/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HttpException extends \RuntimeException
private $headers = [];

/**
* @param string $statusCode
* @param int $statusCode
* @param string $message
* @param array $headers
* @param int $code
Expand Down
8 changes: 4 additions & 4 deletions src/Lib/Logger/Handler/AsyncRotatingFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class AsyncRotatingFileHandler extends AbstractProcessingHandler
private $logDir;

/**
* @param int $logDir
* @param string $logDir
* @param bool|int $level
* @param bool|true $bubble
*/
public function __construct($logDir, $level = Logger::DEBUG, $bubble = true)
{
$this->logDir = $logDir;

parent::__construct($level, $bubble);
parent::__construct((int)$level, $bubble);
}

/**
Expand All @@ -35,13 +35,13 @@ public function __construct($logDir, $level = Logger::DEBUG, $bubble = true)
*/
protected function write(array $record)
{
if (! is_dir($this->logDir)) {
if (!is_dir($this->logDir)) {
$this->createDir();
}

$filename = $this->logDir . '/' . date('Y-m-d') . '.log';

swoole_async_write($filename, (string) $record['formatted'], -1);
swoole_async_write($filename, (string)$record['formatted'], -1);
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/Lib/Server/Swoole/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
*/
class Server implements ServerInterface
{
/**
* @var ContainerInterface
*/
private $app;

/**
* @var \swoole_http_server
*/
public $server;
/**
* @var ContainerInterface
*/
private $app;

/**
* @param ContainerInterface $app
Expand Down
8 changes: 4 additions & 4 deletions src/Middlewares/RoutingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
use Vinnige\Contracts\ClassBasedRoutingHandlerInterface;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\MiddlewareInterface;
use Vinnige\Lib\Http\Exceptions\InternalErrorHttpException;
use Vinnige\Lib\Http\Exceptions\MethodNotAllowedHttpException;
use Vinnige\Lib\Http\Exceptions\NotFoundHttpException;
use Vinnige\Events\BeforeDispatchRouteEvent;
use Vinnige\Events\BeforeRouteEvent;
use Vinnige\Events\VinnigeEvents;
use Vinnige\Lib\Http\Exceptions\InternalErrorHttpException;
use Vinnige\Lib\Http\Exceptions\MethodNotAllowedHttpException;
use Vinnige\Lib\Http\Exceptions\NotFoundHttpException;

/**
* Class RoutingMiddleware
Expand Down Expand Up @@ -91,7 +91,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
} else {
$controller = $this->app[$info[1]];

if (! $controller instanceof ClassBasedRoutingHandlerInterface) {
if (!$controller instanceof ClassBasedRoutingHandlerInterface) {
throw new InternalErrorHttpException(
sprintf('class %s must implement %s', $info[1], ClassBasedRoutingHandlerInterface::class)
);
Expand Down
12 changes: 6 additions & 6 deletions src/Providers/KernelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Vinnige\Providers;

use PHPixie\HTTP;
use PHPixie\Slice;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\EventSubscriberInterface;
use Vinnige\Contracts\ServiceProviderInterface;
use PHPixie\HTTP;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

/**
* Class KernelServiceProvider
Expand Down Expand Up @@ -86,7 +86,7 @@ function () {
$class,
function () use ($class, $args) {
$stream = (new \ReflectionClass($class))->newInstance($args);
if (! $stream instanceof StreamInterface) {
if (!$stream instanceof StreamInterface) {
throw new \RuntimeException(
sprintf('Http response stream must be instance of %s', StreamInterface::class)
);
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/MiddlewareDispatcherServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace Vinnige\Providers;

use Vinnige\Application;
use Relay\RelayBuilder;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\MiddlewareInterface;
use Vinnige\Contracts\ServiceProviderInterface;
use Relay\RelayBuilder;

/**
* Class MiddlewareDispatcherServiceProvider
Expand Down Expand Up @@ -56,7 +55,7 @@ public function middlewareResolver($class)

$concrete = $this->app[$class];

if (! $concrete instanceof MiddlewareInterface) {
if (!$concrete instanceof MiddlewareInterface) {
$message = printf('middleware %s must be instance of %s', $class, MiddlewareInterface::class);

// TODO: log this error
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/MonologServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Monolog\Formatter\FormatterInterface;
use Monolog\Handler\HandlerInterface;
use Monolog\Logger;
use Psr\Log\InvalidArgumentException;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\ServiceProviderInterface;
use Monolog\Logger;

/**
* Class MonologServiceProvider
Expand Down
9 changes: 4 additions & 5 deletions src/Providers/RoutingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Vinnige\Providers;

use FastRoute\RouteParser\Std as RouteParser;
use FastRoute\RouteParser as RouteParserInterface;
use FastRoute\DataGenerator\GroupCountBased as DataGenerator;
use FastRoute\DataGenerator as DataGeneratorInterface;
use FastRoute\RouteCollector;
use FastRoute\DataGenerator\GroupCountBased as DataGenerator;
use FastRoute\Dispatcher\GroupCountBased as RouteDispatcher;
use Vinnige\Application;
use FastRoute\RouteCollector;
use FastRoute\RouteParser as RouteParserInterface;
use FastRoute\RouteParser\Std as RouteParser;
use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\ServiceProviderInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/SwooleServerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Vinnige\Providers;

use Vinnige\Contracts\ContainerInterface;
use Vinnige\Contracts\ServiceProviderInterface;
use Vinnige\Contracts\ServerInterface;
use Vinnige\Contracts\ServerRequestHandlerInterface;
use Vinnige\Contracts\ServerResponderInterface;
use Vinnige\Contracts\ServiceProviderInterface;
use Vinnige\Lib\Server\Swoole\Server;
use Vinnige\Lib\Server\Swoole\ServerRequestHandler;
use Vinnige\Lib\Server\Swoole\ServerResponder;
Expand Down

0 comments on commit 2b106b9

Please sign in to comment.