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

Commit 38163c6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
# Conflicts: # src/Actions/ExecuteAction.php # src/JupyterBroker.php
2 parents ff4f5af + c229d47 commit 38163c6

23 files changed

+218
-192
lines changed

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2016 Litipk
3+
Copyright (c) 2015-2017 Litipk
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
"type": "project",
55
"license": "MIT",
66
"require": {
7-
"php": ">=5.5.9",
7+
"php": ">=7.0.0",
88
"ext-zmq": "*",
9-
"composer/composer": "^1.2.1",
10-
"monolog/monolog": "^1.9",
11-
"psy/psysh": "^0.7",
12-
"ramsey/uuid": "^3.2",
13-
"react/zmq": "^0.3.0",
14-
"symfony/polyfill-php70": "^1.1"
9+
"composer/composer": "^1.3.1",
10+
"monolog/monolog": "^1.22",
11+
"psy/psysh": "^0.8",
12+
"ramsey/uuid": "^3.5",
13+
"react/zmq": "^0.3.0"
1514
},
1615
"require-dev": {
1716

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

@@ -36,13 +44,7 @@ final class ExecuteAction implements Action
3644
/** @var int */
3745
private $execCount = 0;
3846

39-
/**
40-
* ExecuteAction constructor.
41-
* @param JupyterBroker $broker
42-
* @param SocketWrapper $iopubSocket
43-
* @param SocketWrapper $shellSocket
44-
* @param Shell $shellSoul
45-
*/
47+
4648
public function __construct(
4749
JupyterBroker $broker,
4850
SocketWrapper $iopubSocket,
@@ -74,8 +76,7 @@ public function call(array $header, array $content, $zmqId = null)
7476
);
7577
}
7678

77-
$closure = $this->getClosure();
78-
$closure();
79+
($this->getClosure())();
7980

8081
$replyContent = [
8182
'status' => 'ok',
@@ -89,10 +90,7 @@ public function call(array $header, array $content, $zmqId = null)
8990
$this->broker->send($this->iopubSocket, 'status', ['execution_state' => 'idle'], $this->header);
9091
}
9192

92-
/**
93-
* @param string $message
94-
*/
95-
public function notifyMessage($message)
93+
public function notifyMessage(string $message)
9694
{
9795
$this->broker->send($this->iopubSocket, 'stream', ['name' => 'stdout', 'text' => $message], $this->header);
9896
$this->broker->send(
@@ -103,10 +101,7 @@ public function notifyMessage($message)
103101
);
104102
}
105103

106-
/**
107-
* @return callable
108-
*/
109-
private function getClosure()
104+
private function getClosure(): callable
110105
{
111106
$closure = function () {
112107
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

@@ -17,12 +25,7 @@ final class KernelInfoAction implements Action
1725
/** @var SocketWrapper */
1826
private $iopubSocket;
1927

20-
/**
21-
* ExecuteAction constructor.
22-
* @param JupyterBroker $broker
23-
* @param SocketWrapper $shellSocket
24-
* @param SocketWrapper $iopubSocket
25-
*/
28+
2629
public function __construct(JupyterBroker $broker, SocketWrapper $shellSocket, SocketWrapper $iopubSocket)
2730
{
2831
$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

@@ -34,13 +42,7 @@ final class ShellMessagesHandler
3442
/** @var Logger */
3543
private $logger;
3644

37-
/**
38-
* ShellMessagesHandler constructor.
39-
* @param JupyterBroker $broker
40-
* @param SocketWrapper $iopubSocket
41-
* @param SocketWrapper $shellSocket
42-
* @param Logger $logger
43-
*/
45+
4446
public function __construct(
4547
JupyterBroker $broker,
4648
SocketWrapper $iopubSocket,
@@ -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: 10 additions & 28 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.
@@ -30,35 +30,21 @@ final class JupyterBroker
3030
private $hashAlgorithm;
3131

3232
/** @var UuidInterface */
33-
private $sesssionId;
33+
private $sessionId;
3434

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;
4842
$this->signatureScheme = $signatureScheme;
4943
$this->hashAlgorithm = preg_split('/-/', $signatureScheme)[1];
50-
$this->sesssionId = $sessionId;
44+
$this->sessionId = $sessionId;
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-
* @param string $zmqId
61-
*/
6248
public function send(
6349
SocketWrapper $stream,
6450
$msgType,
@@ -94,23 +80,19 @@ public function send(
9480
$stream->send($finalMsg);
9581
}
9682

97-
/**
98-
* @param string $msgType
99-
* @return array
100-
*/
101-
private function createHeader($msgType)
83+
private function createHeader(string $msgType): array
10284
{
10385
return [
104-
'date' => (new \DateTime('NOW'))->format('c'),
105-
'msg_id' => Uuid::uuid4()->toString(),
86+
'date' => (new \DateTime('NOW'))->format('c'),
87+
'msg_id' => Uuid::uuid4()->toString(),
10688
'username' => "kernel",
107-
'session' => $this->sesssionId->toString(),
89+
'session' => $this->sessionId->toString(),
10890
'msg_type' => $msgType,
109-
'version' => '5.0',
91+
'version' => '5.0',
11092
];
11193
}
11294

113-
private function sign(array $message_list)
95+
private function sign(array $message_list): string
11496
{
11597
$hm = hash_init(
11698
$this->hashAlgorithm,

0 commit comments

Comments
 (0)