Skip to content

Commit 709a989

Browse files
authored
Merge pull request #7 from inhere/master
add some methods, code formatting
2 parents 4f4c9a8 + 214e9bb commit 709a989

13 files changed

Lines changed: 112 additions & 35 deletions

.php_cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of Swoft.
5+
6+
@link https://swoft.org
7+
@document https://doc.swoft.org
8+
@contact group@swoft.org
9+
@license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
10+
EOF;
11+
12+
return PhpCsFixer\Config::create()
13+
->setRiskyAllowed(true)
14+
->setRules([
15+
'@PSR2' => true,
16+
'header_comment' => [
17+
'commentType' => 'PHPDoc',
18+
'header' => $header,
19+
'separate' => 'none'
20+
],
21+
'array_syntax' => [
22+
'syntax' => 'short'
23+
],
24+
'single_quote' => true,
25+
'class_attributes_separation' => true,
26+
'no_unused_imports' => true,
27+
'standardize_not_equals' => true,
28+
])
29+
->setFinder(
30+
PhpCsFixer\Finder::create()
31+
->exclude('public')
32+
->exclude('resources')
33+
->exclude('config')
34+
->exclude('runtime')
35+
->exclude('vendor')
36+
->in(__DIR__)
37+
)
38+
->setUsingCache(false);

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
# Swoft Http-server
2-
Swoft Http-server Component
1+
# Swoft http server
2+
3+
Swoft Http server Component
34

45
# Install
56

7+
- composer command
8+
9+
```bash
10+
composer require swoft/http-server
11+
```
12+
613
# Document
714

15+
Please see [document site](https://doc.swoft.org)
16+
17+
# Unit testing
18+
19+
```bash
20+
phpunit
21+
```
22+
823
# LICENSE
9-
Swoft Http-server Component is open-sourced software licensed under the [Apache license](LICENSE).
24+
25+
The Component is open-sourced software licensed under the [Apache license](LICENSE).

src/Bean/Parser/ControllerParser.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88
use Swoft\Http\Server\Bean\Collector\ControllerCollector;
99

1010
/**
11-
* AutoController注解解析器
12-
*
13-
* @uses ControllerParser
14-
* @version 2017年09月03日
15-
* @author stelin <phpcrazy@126.com>
16-
* @copyright Copyright 2010-2016 swoft software
17-
* @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt}
11+
* Controller parser
1812
*/
1913
class ControllerParser extends AbstractParser
2014
{
2115
/**
22-
* AutoController注解解析
16+
* Parse @Controller annotation
2317
*
2418
* @param string $className
2519
* @param Controller $objectAnnotation

src/Bootstrap/CoreBean.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CoreBean implements BootBeanInterface
1818
/**
1919
* @return array
2020
*/
21-
public function beans()
21+
public function beans(): array
2222
{
2323
return [
2424
'serverDispatcher' => [
@@ -32,4 +32,4 @@ public function beans()
3232
],
3333
];
3434
}
35-
}
35+
}

src/Bootstrap/Listener/MasterStartListener.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<?php
2-
/**
3-
* Created by PhpStorm.
4-
* User: inhere
5-
* Date: 2018/3/19
6-
* Time: 上午11:32
7-
*/
82

93
namespace Swoft\Http\Server\Bootstrap\Listener;
104

@@ -30,7 +24,7 @@ public function onStart(Server $server)
3024

3125
// output a message before start
3226
if (!App::$server->isDaemonize()) {
33-
\output()->writeln('You can use <info>CTRL + C</info> to stop run.');
27+
\output()->writeln("You can use <info>CTRL + C</info> to stop run.\n");
3428
}
3529
}
3630
}

src/Command/ServerCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ServerCommand
2222
* @Example
2323
* {fullCommand}
2424
* {fullCommand} -d
25+
* @throws \InvalidArgumentException
2526
* @throws \Swoft\Exception\RuntimeException
2627
* @throws \RuntimeException
2728
*/
@@ -56,7 +57,7 @@ public function start()
5657
$tcpHost = $tcpStatus['host'];
5758
$tcpPort = $tcpStatus['port'];
5859
$tcpType = $tcpStatus['type'];
59-
$tcpEnable = $tcpEnable ? '<note>Enabled</note>' : '<warning>Disabled</warning>';
60+
$tcpEnable = $tcpEnable ? '<info>Enabled</info>' : '<warning>Disabled</warning>';
6061

6162
// 信息面板
6263
$lines = [
@@ -104,6 +105,7 @@ public function reload()
104105
*
105106
* @Usage {fullCommand}
106107
* @Example {fullCommand}
108+
* @throws \InvalidArgumentException
107109
* @throws \RuntimeException
108110
*/
109111
public function stop()
@@ -141,6 +143,7 @@ public function stop()
141143
* @Example
142144
* {fullCommand}
143145
* {fullCommand} -d
146+
* @throws \Swoft\Exception\RuntimeException
144147
* @throws \InvalidArgumentException
145148
* @throws \RuntimeException
146149
*/

src/Exception/UnauthorizedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Swoft\Http\Server\Exception;
44

55
/**
6-
* @uses UnanthenticatedException
6+
* @uses UnauthorizedException
77
* @version 2017-11-11
88
* @author huangzhhui <huangzhwork@gmail.com>
99
* @copyright Copyright 2010-2017 Swoft software

src/Middleware/AcceptTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ trait AcceptTrait
2323

2424
/**
2525
* @param \Psr\Http\Message\ServerRequestInterface $request
26-
* @param \Psr\Http\Message\ResponseInterface $response
26+
* @param \Psr\Http\Message\ResponseInterface $response
2727
* @return \Psr\Http\Message\ResponseInterface
28+
* @throws \InvalidArgumentException
2829
*/
2930
protected function handleAccept(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
3031
{

src/Middleware/HandlerAdapterMiddleware.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ class HandlerAdapterMiddleware implements MiddlewareInterface
2121
/**
2222
* execute action
2323
*
24-
* @param \Psr\Http\Message\ServerRequestInterface $request
24+
* @param \Psr\Http\Message\ServerRequestInterface $request
2525
* @param \Psr\Http\Server\RequestHandlerInterface $handler
2626
*
2727
* @return \Psr\Http\Message\ResponseInterface
28+
* @throws \Swoft\Http\Server\Exception\RouteNotFoundException
29+
* @throws \Swoft\Http\Server\Exception\MethodNotAllowedException
30+
* @throws \InvalidArgumentException
31+
* @throws \ReflectionException
2832
*/
2933
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
3034
{

src/Middleware/PoweredByMiddleware.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Swoft\Http\Message\Middleware\MiddlewareInterface;
1010

1111
/**
12-
* add powere by
12+
* add powered by
1313
*
1414
* @Bean()
1515
* @uses PoweredByMiddleware
@@ -20,7 +20,6 @@
2020
*/
2121
class PoweredByMiddleware implements MiddlewareInterface
2222
{
23-
2423
/**
2524
* Process an incoming server request and return a response, optionally delegating
2625
* response creation to a handler.

0 commit comments

Comments
 (0)