Skip to content

Commit

Permalink
Merge pull request #1255 from ulue/dev2
Browse files Browse the repository at this point in the history
Fix code style
  • Loading branch information
inhere authored Apr 15, 2020
2 parents b9a34a0 + b8f1e7a commit 211adea
Show file tree
Hide file tree
Showing 31 changed files with 120 additions and 93 deletions.
9 changes: 6 additions & 3 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'header_comment' => [
'commentType' => 'PHPDoc',
'header' => $header,
'separate' => 'none'
'comment_type' => 'PHPDoc',
'header' => $header,
'separate' => 'bottom'
],
'array_syntax' => [
'syntax' => 'short'
],
'encoding' => true, // MUST use only UTF-8 without BOM
'single_quote' => true,
'class_attributes_separation' => true,
'no_unused_imports' => true,
'global_namespace_import' => true,
'standardize_not_equals' => true,
'declare_strict_types' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ install:
- |
echo "no" | pecl install -f redis
- |
wget https://github.com/swoole/swoole-src/archive/v4.4.15.tar.gz -O swoole.tar.gz && mkdir -p swoole && tar -xf swoole.tar.gz -C swoole --strip-components=1 && rm swoole.tar.gz && cd swoole && phpize && ./configure && make -j$(nproc) && make install && cd - && rm -rf swoole
wget https://github.com/swoole/swoole-src/archive/v4.4.17.tar.gz -O swoole.tar.gz && mkdir -p swoole && tar -xf swoole.tar.gz -C swoole --strip-components=1 && rm swoole.tar.gz && cd swoole && phpize && ./configure && make -j$(nproc) && make install && cd - && rm -rf swoole
echo "extension = swoole.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- |
wget -O bin/php-cs-fixer "https://cs.symfony.com/download/php-cs-fixer-v2.phar"
chmod +x bin/php-cs-fixer
before_script:
- phpenv config-rm xdebug.ini
- bin/php-cs-fixer -V
- composer config -g process-timeout 900 && composer update
- composer require --dev phpstan/phpstan

script:
- composer cs-fix
- composer check-cs
- composer test
# - php bin/swoft dinfo:env
4 changes: 2 additions & 2 deletions app/Annotation/Parser/AlphaDashParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace App\Annotation\Parser;

use App\Annotation\Mapping\AlphaDash;
use ReflectionException;
use Swoft\Annotation\Annotation\Mapping\AnnotationParser;
use Swoft\Annotation\Annotation\Parser\Parser;
use App\Annotation\Mapping\AlphaDash;
use Swoft\Validator\Exception\ValidatorException;
use Swoft\Validator\ValidatorRegister;

Expand All @@ -25,7 +25,7 @@
class AlphaDashParser extends Parser
{
/**
* @param int $type
* @param int $type
* @param object $annotationObject
*
* @return array
Expand Down
2 changes: 1 addition & 1 deletion app/Aspect/BeanAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace App\Aspect;

use App\Common\MyBean;
use Swoft\Aop\Annotation\Mapping\Aspect;
use Swoft\Aop\Annotation\Mapping\Before;
use Swoft\Aop\Annotation\Mapping\PointBean;
use App\Common\MyBean;
use function vdump;

/**
Expand Down
8 changes: 8 additions & 0 deletions app/Common/MyBean.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace App\Common;

Expand Down
7 changes: 5 additions & 2 deletions app/Exception/ApiException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
Expand All @@ -7,13 +7,16 @@
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace App\Exception;

use Exception;

/**
* Class ApiException
*
* @since 2.0
*/
class ApiException extends \Exception
class ApiException extends Exception
{
}
2 changes: 1 addition & 1 deletion app/Helper/Functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
use Swoft\View\Renderer;
use Throwable;
use function bean;
use function context;

/**
Expand Down Expand Up @@ -79,6 +80,6 @@ public function wsTest(): Response
*/
public function dataConfig(): array
{
return \bean(GoodsData::class)->getConfig();
return bean(GoodsData::class)->getConfig();
}
}
2 changes: 1 addition & 1 deletion app/Http/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function get(): array
public function del(): array
{
$sess = HttpSession::current();
$ok = $sess->delete('testKey');
$ok = $sess->delete('testKey');

return ['delete' => $ok];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controller/TimerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

use App\Model\Entity\User;
use Exception;
use function random_int;
use Swoft\Http\Server\Annotation\Mapping\Controller;
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
use Swoft\Log\Helper\Log;
use Swoft\Redis\Redis;
use Swoft\Stdlib\Helper\JsonHelper;
use Swoft\Timer;
use function random_int;

/**
* Class TimerController
Expand Down
5 changes: 2 additions & 3 deletions app/Listener/RegisterServiceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Swoft\Event\EventHandlerInterface;
use Swoft\Event\EventInterface;
use Swoft\Http\Server\HttpServer;
use Swoft\Log\Helper\CLog;
use Swoft\Server\SwooleEvent;

/**
Expand Down Expand Up @@ -63,7 +62,7 @@ public function handle(EventInterface $event): void


// Register
// $this->agent->registerService($service);
// CLog::info('Swoft http register service success by consul!');
// $this->agent->registerService($service);
// CLog::info('Swoft http register service success by consul!');
}
}
8 changes: 8 additions & 0 deletions app/Model/Data/GoodsData.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace App\Model\Data;

Expand Down
4 changes: 2 additions & 2 deletions app/Model/Logic/MonitorLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function monitor(Process $process): void

// Database
$user = User::find(1)->toArray();
CLog::info('user='.json_encode($user));
CLog::info('user=' . json_encode($user));

// Redis
Redis::set('test', 'ok');
CLog::info('test='.Redis::get('test'));
CLog::info('test=' . Redis::get('test'));

Coroutine::sleep(3);
}
Expand Down
5 changes: 4 additions & 1 deletion app/Model/Logic/RequestBean.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
class RequestBean
{
/**
* @var array
*/
public $temp = [];

/**
Expand All @@ -36,7 +39,7 @@ public function getData(): array
*
* @return string
*/
public function getName(string $type):string
public function getName(string $type): string
{
return 'name';
}
Expand Down
6 changes: 3 additions & 3 deletions app/Process/Worker2Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public function run(Pool $pool, int $workerId): void

// Database
$user = User::find(1)->toArray();
CLog::info('user='.json_encode($user));
CLog::info('user=' . json_encode($user));

// Redis
Redis::set('test', 'ok');
CLog::info('test='.Redis::get('test'));
CLog::info('test=' . Redis::get('test'));

CLog::info('worker-' . $workerId.' context='.context()->getWorkerId());
CLog::info('worker-' . $workerId . ' context=' . context()->getWorkerId());

Coroutine::sleep(3);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Rpc/Lib/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getBigContent(): string;
/**
* @return void
*/
public function returnNull():void ;
public function returnNull(): void;

/**
* Exception
Expand Down
8 changes: 4 additions & 4 deletions app/Rpc/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use App\Rpc\Lib\UserInterface;
use Exception;
use RuntimeException;
use Swoft\Co;
use Swoft\Rpc\Server\Annotation\Mapping\Service;

Expand Down Expand Up @@ -51,25 +52,24 @@ public function delete(int $id): bool
*/
public function returnNull(): void
{
return;
}

/**
* @return string
*/
public function getBigContent(): string
{
$content = Co::readFile(__DIR__ . '/big.data');
return $content;
return Co::readFile(__DIR__ . '/big.data');
}

/**
* Exception
*
* @throws Exception
*/
public function exception(): void
{
throw new Exception('exception version');
throw new RuntimeException('exception version');
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Rpc/Service/UserServiceV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function getBigContent(): string

/**
* Exception
*
* @throws Exception
*/
public function exception(): void
Expand Down
2 changes: 1 addition & 1 deletion app/Task/Listener/FinishListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

namespace App\Task\Listener;

use function context;
use Swoft\Event\Annotation\Mapping\Listener;
use Swoft\Event\EventHandlerInterface;
use Swoft\Event\EventInterface;
use Swoft\Log\Helper\CLog;
use Swoft\Task\TaskEvent;
use function context;

/**
* Class FinishListener
Expand Down
2 changes: 1 addition & 1 deletion app/Tcp/Middleware/DemoMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Log\Helper\CLog;
use Swoft\Tcp\Server\Contract\RequestHandlerInterface;
use Swoft\Tcp\Server\Contract\MiddlewareInterface;
use Swoft\Tcp\Server\Contract\RequestHandlerInterface;
use Swoft\Tcp\Server\Contract\RequestInterface;
use Swoft\Tcp\Server\Contract\ResponseInterface;

Expand Down
2 changes: 1 addition & 1 deletion app/Tcp/Middleware/GlobalTcpMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Log\Helper\CLog;
use Swoft\Tcp\Server\Contract\RequestHandlerInterface;
use Swoft\Tcp\Server\Contract\MiddlewareInterface;
use Swoft\Tcp\Server\Contract\RequestHandlerInterface;
use Swoft\Tcp\Server\Contract\RequestInterface;
use Swoft\Tcp\Server\Contract\ResponseInterface;

Expand Down
2 changes: 1 addition & 1 deletion app/Validator/CustomerValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CustomerValidator implements ValidatorInterface
public function validate(array $data, array $params): array
{
$start = $data['start'] ?? null;
$end = $data['end'] ?? null;
$end = $data['end'] ?? null;
if ($start === null && $end === null) {
throw new ValidatorException('Start time and end time cannot be empty');
}
Expand Down
1 change: 0 additions & 1 deletion app/WebSocket/EchoModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Swoft\WebSocket\Server\Annotation\Mapping\WsModule;
use Swoole\WebSocket\Frame;
use Swoole\WebSocket\Server;
use function server;

/**
* Class EchoModule
Expand Down
1 change: 1 addition & 0 deletions app/WebSocket/Test/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function index(): void

/**
* Message command is: 'test.index'
*
* @param Message $msg
*
* @return void
Expand Down
Loading

0 comments on commit 211adea

Please sign in to comment.