Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit c229d47

Browse files
committed
Update code style
- Force PHP7 as minimum required version - Use PHP7's type hinting - Remove unnecessary phpdoc comments (due to PHP7's type hinting) - Add license header to all the files
1 parent 51ab1e5 commit c229d47

21 files changed

+206
-176
lines changed

src/Actions/Action.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Actions;
513

src/Actions/ExecuteAction.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Actions;
513

@@ -35,13 +43,7 @@ final class ExecuteAction implements Action
3543
/** @var int */
3644
private $execCount;
3745

38-
/**
39-
* ExecuteAction constructor.
40-
* @param JupyterBroker $broker
41-
* @param SocketWrapper $iopubSocket
42-
* @param SocketWrapper $shellSocket
43-
* @param Shell $shellSoul
44-
*/
46+
4547
public function __construct(
4648
JupyterBroker $broker, SocketWrapper $iopubSocket, SocketWrapper $shellSocket, Shell $shellSoul
4749
)
@@ -62,14 +64,10 @@ public function call(array $header, array $content)
6264
$this->execCount = isset($content->execution_count) ? $content->execution_count : 0;
6365
$this->code = $content['code'];
6466

65-
$closure = $this->getClosure();
66-
$closure();
67+
($this->getClosure())();
6768
}
6869

69-
/**
70-
* @param string $message
71-
*/
72-
public function notifyMessage($message)
70+
public function notifyMessage(string $message)
7371
{
7472
$this->broker->send($this->shellSocket, 'execute_reply', ['status' => 'ok'], $this->header);
7573
$this->broker->send($this->iopubSocket, 'stream', ['name' => 'stdout', 'data' => $message], $this->header);
@@ -82,10 +80,7 @@ public function notifyMessage($message)
8280
$this->broker->send($this->iopubSocket, 'status', ['execution_state' => 'idle'], $this->header);
8381
}
8482

85-
/**
86-
* @return callable
87-
*/
88-
private function getClosure()
83+
private function getClosure(): callable
8984
{
9085
$closure = function () {
9186
extract($this->shellSoul->getScopeVariables());

src/Actions/HistoryAction.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Actions;
513

@@ -17,11 +25,6 @@ final class HistoryAction implements Action
1725
private $shellSocket;
1826

1927

20-
/**
21-
* ExecuteAction constructor.
22-
* @param JupyterBroker $broker
23-
* @param SocketWrapper $shellSocket
24-
*/
2528
public function __construct(JupyterBroker $broker, SocketWrapper $shellSocket)
2629
{
2730
$this->broker = $broker;

src/Actions/KernelInfoAction.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Actions;
513

@@ -19,12 +27,7 @@ final class KernelInfoAction implements Action
1927
/** @var SocketWrapper */
2028
private $iopubSocket;
2129

22-
/**
23-
* ExecuteAction constructor.
24-
* @param JupyterBroker $broker
25-
* @param SocketWrapper $shellSocket
26-
* @param SocketWrapper $iopubSocket
27-
*/
30+
2831
public function __construct(JupyterBroker $broker, SocketWrapper $shellSocket, SocketWrapper $iopubSocket)
2932
{
3033
$this->broker = $broker;

src/Actions/ShutdownAction.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Actions;
513

src/ConnectionSettings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of Jupyter-PHP.
55
*
6-
* (c) 2015-2016 Litipk
6+
* (c) 2015-2017 Litipk
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -17,7 +17,7 @@ final class ConnectionSettings
1717
/**
1818
* @return array[string]mixed
1919
*/
20-
public static function get()
20+
public static function get(): array
2121
{
2222
global $argv;
2323
if (!isset($argv) || empty($argv)) {
@@ -47,7 +47,7 @@ public static function get()
4747
* @param null|array $connectionSettings
4848
* @return array[string]string
4949
*/
50-
public static function getConnectionUris(array $connectionSettings = null)
50+
public static function getConnectionUris(array $connectionSettings = null): array
5151
{
5252
if (null === $connectionSettings) {
5353
$connectionSettings = self::get();

src/Handlers/HbErrorHandler.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Litipk\JupyterPHP\Handlers;
413

514

src/Handlers/HbMessagesHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Handlers;
513

src/Handlers/IOPubMessagesHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Handlers;
513

src/Handlers/ShellMessagesHandler.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file is part of Jupyter-PHP.
5+
*
6+
* (c) 2015-2017 Litipk
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
311

412
namespace Litipk\JupyterPHP\Handlers;
513

@@ -36,13 +44,7 @@ final class ShellMessagesHandler
3644
/** @var Logger */
3745
private $logger;
3846

39-
/**
40-
* ShellMessagesHandler constructor.
41-
* @param JupyterBroker $broker
42-
* @param SocketWrapper $iopubSocket
43-
* @param SocketWrapper $shellSocket
44-
* @param Logger $logger
45-
*/
47+
4648
public function __construct(
4749
JupyterBroker $broker, SocketWrapper $iopubSocket, SocketWrapper $shellSocket, Logger $logger
4850
)
@@ -63,9 +65,6 @@ public function __construct(
6365
$this->shellSoul->setOutput( new KernelOutput($this->executeAction, $this->logger->withName('KernelOutput')));
6466
}
6567

66-
/**
67-
* @param $msg
68-
*/
6968
public function __invoke(array $msg)
7069
{
7170
list($zmqId, $delim, $hmac, $header, $parentHeader, $metadata, $content) = $msg;

src/JupyterBroker.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of Jupyter-PHP.
55
*
6-
* (c) 2015-2016 Litipk
6+
* (c) 2015-2017 Litipk
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -35,13 +35,7 @@ final class JupyterBroker
3535
/** @var null|LoggerInterface */
3636
private $logger;
3737

38-
/**
39-
* JupyterBroker constructor.
40-
* @param string $key
41-
* @param string $signatureScheme
42-
* @param UuidInterface $sessionId
43-
* @param null|LoggerInterface $logger
44-
*/
38+
4539
public function __construct($key, $signatureScheme, UuidInterface $sessionId, LoggerInterface $logger = null)
4640
{
4741
$this->key = $key;
@@ -51,13 +45,6 @@ public function __construct($key, $signatureScheme, UuidInterface $sessionId, Lo
5145
$this->logger = $logger;
5246
}
5347

54-
/**
55-
* @param SocketWrapper $stream
56-
* @param string $msgType
57-
* @param array $content
58-
* @param array $parentHeader
59-
* @param array $metadata
60-
*/
6148
public function send(
6249
SocketWrapper $stream, $msgType, array $content = [], array $parentHeader = [], array $metadata = []
6350
)
@@ -83,11 +70,7 @@ public function send(
8370
$stream->send($finalMsg);
8471
}
8572

86-
/**
87-
* @param string $msgType
88-
* @return array
89-
*/
90-
private function createHeader($msgType)
73+
private function createHeader(string $msgType): array
9174
{
9275
return [
9376
'date' => (new \DateTime('NOW'))->format('c'),
@@ -98,7 +81,8 @@ private function createHeader($msgType)
9881
];
9982
}
10083

101-
private function sign(array $message_list) {
84+
private function sign(array $message_list): string
85+
{
10286
$hm = hash_init(
10387
$this->hashAlgorithm,
10488
HASH_HMAC,

src/KernelCore.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of Jupyter-PHP.
55
*
6-
* (c) 2015-2016 Litipk
6+
* (c) 2015-2017 Litipk
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -26,7 +26,6 @@
2626

2727
/**
2828
* Class KernelCore (no pun intended)
29-
* @package Litipk\JupyterPHP
3029
*/
3130
final class KernelCore
3231
{
@@ -50,12 +49,7 @@ final class KernelCore
5049
/** @var SocketWrapper|\ZMQSocket */
5150
private $shellSocket;
5251

53-
/**
54-
* KernelCore constructor.
55-
* @param JupyterBroker $jupyterBroker
56-
* @param array $connUris [string]string $connUris
57-
* @param Logger $logger
58-
*/
52+
5953
public function __construct(JupyterBroker $jupyterBroker, array $connUris, Logger $logger)
6054
{
6155
$this->broker = $jupyterBroker;
@@ -65,9 +59,6 @@ public function __construct(JupyterBroker $jupyterBroker, array $connUris, Logge
6559
$this->registerHandlers();
6660
}
6761

68-
/**
69-
*
70-
*/
7162
public function run()
7263
{
7364
$this->reactLoop->run();
@@ -100,9 +91,6 @@ private function initSockets(array $connUris)
10091
$this->shellSocket->bind($connUris['shell']);
10192
}
10293

103-
/**
104-
*
105-
*/
10694
private function registerHandlers()
10795
{
10896
$this->hbSocket->on(

0 commit comments

Comments
 (0)