Completed
Branch 2.0 (13c62b)
by Anton
09:07
created
tests/bootstrap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,4 +9,4 @@
 block discarded – undo
9 9
 ini_set('display_errors', true);
10 10
 
11 11
 //Composer
12
-require dirname(__DIR__) . '/vendor/autoload.php';
13 12
\ No newline at end of file
13
+require dirname(__DIR__).'/vendor/autoload.php';
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/HttpDispatcher.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
         $http = $this->container->get(HttpCore::class);
59 59
         $emitter = $this->container->get(EmitterInterface::class);
60 60
 
61
-        try {
61
+        try{
62 62
             $response = $http->handle($this->initRequest());
63 63
             $emitter->emit($response);
64
-        } catch (\Throwable $e) {
64
+        }catch (\Throwable $e){
65 65
             $this->handleException($emitter, $e);
66 66
         }
67 67
     }
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $handler = new HtmlHandler(HtmlHandler::INVERTED);
84 84
 
85
-        try {
85
+        try{
86 86
             /** @var SnapshotInterface $snapshot */
87 87
             $this->container->get(SnapshotterInterface::class)->register($e);
88
-        } catch (\Throwable|ContainerExceptionInterface $se) {
88
+        }catch (\Throwable | ContainerExceptionInterface $se){
89 89
             // nothing to report
90 90
         }
91 91
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,10 +58,13 @@  discard block
 block discarded – undo
58 58
         $http = $this->container->get(HttpCore::class);
59 59
         $emitter = $this->container->get(EmitterInterface::class);
60 60
 
61
-        try {
61
+        try
62
+        {
62 63
             $response = $http->handle($this->initRequest());
63 64
             $emitter->emit($response);
64
-        } catch (\Throwable $e) {
65
+        }
66
+        catch (\Throwable $e)
67
+        {
65 68
             $this->handleException($emitter, $e);
66 69
         }
67 70
     }
@@ -82,10 +85,13 @@  discard block
 block discarded – undo
82 85
     {
83 86
         $handler = new HtmlHandler(HtmlHandler::INVERTED);
84 87
 
85
-        try {
88
+        try
89
+        {
86 90
             /** @var SnapshotInterface $snapshot */
87 91
             $this->container->get(SnapshotterInterface::class)->register($e);
88
-        } catch (\Throwable|ContainerExceptionInterface $se) {
92
+        }
93
+        catch (\Throwable|ContainerExceptionInterface $se)
94
+        {
89 95
             // nothing to report
90 96
         }
91 97
 
Please login to merge, or discard this patch.
src/Session/Middleware/SessionMiddleware.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         HttpConfig $httpConfig,
51 51
         SessionFactory $factory,
52 52
         ScopeInterface $scope
53
-    ) {
53
+    ){
54 54
         $this->config = $config;
55 55
         $this->httpConfig = $httpConfig;
56 56
         $this->factory = $factory;
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
         Request $request,
91 91
         Response $response
92 92
     ): Response {
93
-        if (!$session->isStarted()) {
93
+        if (!$session->isStarted()){
94 94
             return $response;
95 95
         }
96 96
 
97 97
         $session->commit();
98 98
 
99 99
         //SID changed
100
-        if ($this->fetchID($request) != $session->getID()) {
100
+        if ($this->fetchID($request) != $session->getID()){
101 101
             return $this->withCookie($request, $response, $session->getID());
102 102
         }
103 103
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     protected function fetchID(Request $request): ?string
116 116
     {
117 117
         $cookies = $request->getCookieParams();
118
-        if (empty($cookies[$this->config->getCookie()])) {
118
+        if (empty($cookies[$this->config->getCookie()])){
119 119
             return null;
120 120
         }
121 121
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
     protected function clientSignature(Request $request): string
151 151
     {
152 152
         $signature = '';
153
-        foreach (static::SIGNATURE_HEADERS as $header) {
154
-            $signature .= $request->getHeaderLine($header) . ';';
153
+        foreach (static::SIGNATURE_HEADERS as $header){
154
+            $signature .= $request->getHeaderLine($header).';';
155 155
         }
156 156
 
157 157
         return hash('sha256', $signature);
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -70,7 +70,8 @@  discard block
 block discarded – undo
70 70
 
71 71
         $response = $this->scope->runScope(
72 72
             [SessionInterface::class => $session],
73
-            function () use ($session, $request, $handler) {
73
+            function () use ($session, $request, $handler)
74
+            {
74 75
                 return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session));
75 76
             }
76 77
         );
@@ -90,14 +91,16 @@  discard block
 block discarded – undo
90 91
         Request $request,
91 92
         Response $response
92 93
     ): Response {
93
-        if (!$session->isStarted()) {
94
+        if (!$session->isStarted())
95
+        {
94 96
             return $response;
95 97
         }
96 98
 
97 99
         $session->commit();
98 100
 
99 101
         //SID changed
100
-        if ($this->fetchID($request) != $session->getID()) {
102
+        if ($this->fetchID($request) != $session->getID())
103
+        {
101 104
             return $this->withCookie($request, $response, $session->getID());
102 105
         }
103 106
 
@@ -115,7 +118,8 @@  discard block
 block discarded – undo
115 118
     protected function fetchID(Request $request): ?string
116 119
     {
117 120
         $cookies = $request->getCookieParams();
118
-        if (empty($cookies[$this->config->getCookie()])) {
121
+        if (empty($cookies[$this->config->getCookie()]))
122
+        {
119 123
             return null;
120 124
         }
121 125
 
@@ -150,7 +154,8 @@  discard block
 block discarded – undo
150 154
     protected function clientSignature(Request $request): string
151 155
     {
152 156
         $signature = '';
153
-        foreach (static::SIGNATURE_HEADERS as $header) {
157
+        foreach (static::SIGNATURE_HEADERS as $header)
158
+        {
154 159
             $signature .= $request->getHeaderLine($header) . ';';
155 160
         }
156 161
 
Please login to merge, or discard this patch.
functions.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @author    Anton Titov (Wolfy-J)
7 7
  */
8 8
 
9
-if (!function_exists('bind')) {
9
+if (!function_exists('bind')){
10 10
     /**
11 11
      * Shortcut to container Autowire definition.
12 12
      *
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@
 block discarded – undo
6 6
  * @author    Anton Titov (Wolfy-J)
7 7
  */
8 8
 
9
-if (!function_exists('bind')) {
9
+if (!function_exists('bind'))
10
+{
10 11
     /**
11 12
      * Shortcut to container Autowire definition.
12 13
      *
Please login to merge, or discard this patch.
src/Snapshots/FileSnapshotter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         int $verbosity,
48 48
         HandlerInterface $handler,
49 49
         FilesInterface $files
50
-    ) {
50
+    ){
51 51
         $this->directory = $directory;
52 52
         $this->maxFiles = $maxFiles;
53 53
         $this->verbosity = $verbosity;
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
     protected function rotateSnapshots()
92 92
     {
93 93
         $finder = new Finder();
94
-        $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) {
94
+        $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b){
95 95
             return $b->getMTime() - $a->getMTime();
96 96
         });
97 97
 
98 98
         $count = 0;
99
-        foreach ($finder as $file) {
99
+        foreach ($finder as $file){
100 100
             $count++;
101
-            if ($count > $this->maxFiles) {
102
-                try {
101
+            if ($count > $this->maxFiles){
102
+                try{
103 103
                     $this->files->delete($file->getRealPath());
104
-                } catch (FilesException $e) {
104
+                }catch (FilesException $e){
105 105
 
106 106
                 }
107 107
             }
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,17 +91,23 @@
 block discarded – undo
91 91
     protected function rotateSnapshots()
92 92
     {
93 93
         $finder = new Finder();
94
-        $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) {
94
+        $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b)
95
+        {
95 96
             return $b->getMTime() - $a->getMTime();
96 97
         });
97 98
 
98 99
         $count = 0;
99
-        foreach ($finder as $file) {
100
+        foreach ($finder as $file)
101
+        {
100 102
             $count++;
101
-            if ($count > $this->maxFiles) {
102
-                try {
103
+            if ($count > $this->maxFiles)
104
+            {
105
+                try
106
+                {
103 107
                     $this->files->delete($file->getRealPath());
104
-                } catch (FilesException $e) {
108
+                }
109
+                catch (FilesException $e)
110
+                {
105 111
 
106 112
                 }
107 113
             }
Please login to merge, or discard this patch.
src/Console/ConsoleDispatcher.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
         /** @var ConsoleCore $core */
64 64
         $core = $this->container->get(ConsoleCore::class);
65 65
 
66
-        try {
66
+        try{
67 67
             $core->start(new ArgvInput(), $output);
68
-        } catch (\Throwable $e) {
68
+        }catch (\Throwable $e){
69 69
             $this->handleException($e, $output);
70
-        } finally {
70
+        }finally{
71 71
             $listener->disable();
72 72
         }
73 73
     }
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
      */
79 79
     protected function handleException(\Throwable $e, OutputInterface $output)
80 80
     {
81
-        try {
81
+        try{
82 82
             $this->container->get(SnapshotterInterface::class)->register($e);
83
-        } catch (\Throwable|ContainerExceptionInterface $se) {
83
+        }catch (\Throwable | ContainerExceptionInterface $se){
84 84
             // no need to notify when unable to register an exception
85 85
         }
86 86
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
      */
96 96
     private function mapVerbosity(OutputInterface $output): int
97 97
     {
98
-        if ($output->isDebug()) {
98
+        if ($output->isDebug()){
99 99
             return ConsoleHandler::VERBOSITY_DEBUG;
100 100
         }
101 101
 
102
-        if ($output->isVerbose() || $output->isVeryVerbose()) {
102
+        if ($output->isVerbose() || $output->isVeryVerbose()){
103 103
             return ConsoleHandler::VERBOSITY_VERBOSE;
104 104
         }
105 105
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,11 +63,16 @@  discard block
 block discarded – undo
63 63
         /** @var ConsoleCore $core */
64 64
         $core = $this->container->get(ConsoleCore::class);
65 65
 
66
-        try {
66
+        try
67
+        {
67 68
             $core->start(new ArgvInput(), $output);
68
-        } catch (\Throwable $e) {
69
+        }
70
+        catch (\Throwable $e)
71
+        {
69 72
             $this->handleException($e, $output);
70
-        } finally {
73
+        }
74
+        finally
75
+        {
71 76
             $listener->disable();
72 77
         }
73 78
     }
@@ -78,9 +83,12 @@  discard block
 block discarded – undo
78 83
      */
79 84
     protected function handleException(\Throwable $e, OutputInterface $output)
80 85
     {
81
-        try {
86
+        try
87
+        {
82 88
             $this->container->get(SnapshotterInterface::class)->register($e);
83
-        } catch (\Throwable|ContainerExceptionInterface $se) {
89
+        }
90
+        catch (\Throwable|ContainerExceptionInterface $se)
91
+        {
84 92
             // no need to notify when unable to register an exception
85 93
         }
86 94
 
@@ -95,11 +103,13 @@  discard block
 block discarded – undo
95 103
      */
96 104
     private function mapVerbosity(OutputInterface $output): int
97 105
     {
98
-        if ($output->isDebug()) {
106
+        if ($output->isDebug())
107
+        {
99 108
             return ConsoleHandler::VERBOSITY_DEBUG;
100 109
         }
101 110
 
102
-        if ($output->isVerbose() || $output->isVeryVerbose()) {
111
+        if ($output->isVerbose() || $output->isVeryVerbose())
112
+        {
103 113
             return ConsoleHandler::VERBOSITY_VERBOSE;
104 114
         }
105 115
 
Please login to merge, or discard this patch.
src/Console/Logger/DebugListener.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __invoke(LogEvent $event)
50 50
     {
51
-        if (empty($this->output)) {
51
+        if (empty($this->output)){
52 52
             return;
53 53
         }
54 54
 
55 55
 
56
-        if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE) {
56
+        if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE){
57 57
             return;
58 58
         }
59 59
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function enable(): self
91 91
     {
92
-        if (!empty($this->logs)) {
92
+        if (!empty($this->logs)){
93 93
             $this->logs->addListener($this);
94 94
         }
95 95
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function disable(): self
105 105
     {
106
-        if (!empty($this->logs)) {
106
+        if (!empty($this->logs)){
107 107
             $this->logs->removeListener($this);
108 108
         }
109 109
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     private function getChannel(string $channel): string
129 129
     {
130
-        if (!class_exists($channel, false)) {
130
+        if (!class_exists($channel, false)){
131 131
             return "[{$channel}]";
132 132
         }
133 133
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      */
144 144
     private function getMessage(bool $decorated, string $message)
145 145
     {
146
-        if (!$decorated) {
146
+        if (!$decorated){
147 147
             return $message;
148 148
         }
149 149
 
150
-        return Color::GRAY . $message . Color::RESET;
150
+        return Color::GRAY.$message.Color::RESET;
151 151
     }
152 152
 }
153 153
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,12 +48,14 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __invoke(LogEvent $event)
50 50
     {
51
-        if (empty($this->output)) {
51
+        if (empty($this->output))
52
+        {
52 53
             return;
53 54
         }
54 55
 
55 56
 
56
-        if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE) {
57
+        if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE)
58
+        {
57 59
             return;
58 60
         }
59 61
 
@@ -89,7 +91,8 @@  discard block
 block discarded – undo
89 91
      */
90 92
     public function enable(): self
91 93
     {
92
-        if (!empty($this->logs)) {
94
+        if (!empty($this->logs))
95
+        {
93 96
             $this->logs->addListener($this);
94 97
         }
95 98
 
@@ -103,7 +106,8 @@  discard block
 block discarded – undo
103 106
      */
104 107
     public function disable(): self
105 108
     {
106
-        if (!empty($this->logs)) {
109
+        if (!empty($this->logs))
110
+        {
107 111
             $this->logs->removeListener($this);
108 112
         }
109 113
 
@@ -127,7 +131,8 @@  discard block
 block discarded – undo
127 131
      */
128 132
     private function getChannel(string $channel): string
129 133
     {
130
-        if (!class_exists($channel, false)) {
134
+        if (!class_exists($channel, false))
135
+        {
131 136
             return "[{$channel}]";
132 137
         }
133 138
 
@@ -143,7 +148,8 @@  discard block
 block discarded – undo
143 148
      */
144 149
     private function getMessage(bool $decorated, string $message)
145 150
     {
146
-        if (!$decorated) {
151
+        if (!$decorated)
152
+        {
147 153
             return $message;
148 154
         }
149 155
 
Please login to merge, or discard this patch.
src/Console/Sequence/RuntimeDirectory.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
 
44 44
         $runtimeDirectory = $this->directories->get('runtime');
45 45
 
46
-        if (!$this->files->exists($runtimeDirectory)) {
46
+        if (!$this->files->exists($runtimeDirectory)){
47 47
             $this->files->ensureDirectory($runtimeDirectory);
48 48
             $output->writeln("<comment>created</comment>");
49 49
             return;
50
-        } else {
50
+        }else{
51 51
             $output->writeln("<info>exists</info>");
52 52
         }
53 53
 
54
-        foreach ($this->files->getFiles($runtimeDirectory) as $filename) {
55
-            try {
54
+        foreach ($this->files->getFiles($runtimeDirectory) as $filename){
55
+            try{
56 56
                 $this->files->setPermissions($filename, FilesInterface::RUNTIME);
57 57
                 $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME);
58
-            } catch (\Throwable $e) {
58
+            }catch (\Throwable $e){
59 59
                 $output->writeln(sprintf(
60 60
                     "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>",
61 61
                     $this->files->relativePath($filename, $runtimeDirectory),
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                 continue;
65 65
             }
66 66
 
67
-            if ($output->isVerbose()) {
67
+            if ($output->isVerbose()){
68 68
                 $output->writeln(sprintf(
69 69
                     "<fg=green>[updated]</fg=green> `%s`",
70 70
                     $this->files->relativePath($filename, $runtimeDirectory)
Please login to merge, or discard this patch.
Braces   +14 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,19 +43,26 @@  discard block
 block discarded – undo
43 43
 
44 44
         $runtimeDirectory = $this->directories->get('runtime');
45 45
 
46
-        if (!$this->files->exists($runtimeDirectory)) {
46
+        if (!$this->files->exists($runtimeDirectory))
47
+        {
47 48
             $this->files->ensureDirectory($runtimeDirectory);
48 49
             $output->writeln("<comment>created</comment>");
49 50
             return;
50
-        } else {
51
+        }
52
+        else
53
+        {
51 54
             $output->writeln("<info>exists</info>");
52 55
         }
53 56
 
54
-        foreach ($this->files->getFiles($runtimeDirectory) as $filename) {
55
-            try {
57
+        foreach ($this->files->getFiles($runtimeDirectory) as $filename)
58
+        {
59
+            try
60
+            {
56 61
                 $this->files->setPermissions($filename, FilesInterface::RUNTIME);
57 62
                 $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME);
58
-            } catch (\Throwable $e) {
63
+            }
64
+            catch (\Throwable $e)
65
+            {
59 66
                 $output->writeln(sprintf(
60 67
                     "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>",
61 68
                     $this->files->relativePath($filename, $runtimeDirectory),
@@ -64,7 +71,8 @@  discard block
 block discarded – undo
64 71
                 continue;
65 72
             }
66 73
 
67
-            if ($output->isVerbose()) {
74
+            if ($output->isVerbose())
75
+            {
68 76
                 $output->writeln(sprintf(
69 77
                     "<fg=green>[updated]</fg=green> `%s`",
70 78
                     $this->files->relativePath($filename, $runtimeDirectory)
Please login to merge, or discard this patch.
src/Console/ConsoleConfigurator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
      */
78 78
     private function sequencePatch(string $target, $sequence, string $header, string $footer, array $options)
79 79
     {
80
-        if (is_array($sequence)) {
80
+        if (is_array($sequence)){
81 81
             return new AppendPatch($target, null, new CallableSequence($sequence, $options, $header, $footer));
82 82
         }
83 83
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,8 @@
 block discarded – undo
77 77
      */
78 78
     private function sequencePatch(string $target, $sequence, string $header, string $footer, array $options)
79 79
     {
80
-        if (is_array($sequence)) {
80
+        if (is_array($sequence))
81
+        {
81 82
             return new AppendPatch($target, null, new CallableSequence($sequence, $options, $header, $footer));
82 83
         }
83 84
 
Please login to merge, or discard this patch.