Skip to content

Commit eb9c6da

Browse files
committed
wip
1 parent 222f6ba commit eb9c6da

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

api.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public function withBody(StreamInterface $body): self
430430
return $new;
431431
}
432432

433-
private function setHeaders(array $headers): void
433+
private function setHeaders(array $headers) /*:void*/
434434
{
435435
foreach ($headers as $header => $value) {
436436
$value = $this->validateAndTrimHeader($header, $value);
@@ -580,7 +580,7 @@ public function withUri(UriInterface $uri, $preserveHost = false): self
580580
return $new;
581581
}
582582

583-
private function updateHostFromUri(): void
583+
private function updateHostFromUri() /*:void*/
584584
{
585585
if ('' === $host = $this->uri->getHost()) {
586586
return;
@@ -606,7 +606,7 @@ final class Response implements ResponseInterface
606606
{
607607
use MessageTrait;
608608

609-
private const PHRASES = [
609+
/*private*/ const PHRASES = [
610610
100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing',
611611
200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported',
612612
300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect',
@@ -820,7 +820,7 @@ final class Stream implements StreamInterface
820820

821821
private $size;
822822

823-
private const READ_WRITE_HASH = [
823+
/*private*/ const READ_WRITE_HASH = [
824824
'read' => [
825825
'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true,
826826
'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true,
@@ -884,7 +884,7 @@ public function __toString(): string
884884
}
885885
}
886886

887-
public function close(): void
887+
public function close() /*:void*/
888888
{
889889
if (isset($this->stream)) {
890890
if (\is_resource($this->stream)) {
@@ -908,7 +908,7 @@ public function detach()
908908
return $result;
909909
}
910910

911-
public function getSize(): ?int
911+
public function getSize() /*:?int*/
912912
{
913913
if (null !== $this->size) {
914914
return $this->size;
@@ -951,7 +951,7 @@ public function isSeekable(): bool
951951
return $this->seekable;
952952
}
953953

954-
public function seek($offset, $whence = \SEEK_SET): void
954+
public function seek($offset, $whence = \SEEK_SET) /*:void*/
955955
{
956956
if (!$this->seekable) {
957957
throw new \RuntimeException('Stream is not seekable');
@@ -962,7 +962,7 @@ public function seek($offset, $whence = \SEEK_SET): void
962962
}
963963
}
964964

965-
public function rewind(): void
965+
public function rewind() /*:void*/
966966
{
967967
$this->seek(0);
968968
}
@@ -1034,7 +1034,7 @@ public function getMetadata($key = null)
10341034

10351035
final class UploadedFile implements UploadedFileInterface
10361036
{
1037-
private const ERRORS = [
1037+
/*private*/ const ERRORS = [
10381038
\UPLOAD_ERR_OK => 1,
10391039
\UPLOAD_ERR_INI_SIZE => 1,
10401040
\UPLOAD_ERR_FORM_SIZE => 1,
@@ -1095,7 +1095,7 @@ public function __construct($streamOrFile, $size, $errorStatus, $clientFilename
10951095
}
10961096
}
10971097

1098-
private function validateActive(): void
1098+
private function validateActive() /*:void*/
10991099
{
11001100
if (\UPLOAD_ERR_OK !== $this->error) {
11011101
throw new \RuntimeException('Cannot retrieve stream due to upload error');
@@ -1119,7 +1119,7 @@ public function getStream(): StreamInterface
11191119
return Stream::create($resource);
11201120
}
11211121

1122-
public function moveTo($targetPath): void
1122+
public function moveTo($targetPath) /*:void*/
11231123
{
11241124
$this->validateActive();
11251125

@@ -1160,12 +1160,12 @@ public function getError(): int
11601160
return $this->error;
11611161
}
11621162

1163-
public function getClientFilename(): ?string
1163+
public function getClientFilename() /*:?string*/
11641164
{
11651165
return $this->clientFilename;
11661166
}
11671167

1168-
public function getClientMediaType(): ?string
1168+
public function getClientMediaType() /*:?string*/
11691169
{
11701170
return $this->clientMediaType;
11711171
}
@@ -1175,11 +1175,11 @@ public function getClientMediaType(): ?string
11751175

11761176
final class Uri implements UriInterface
11771177
{
1178-
private const SCHEMES = ['http' => 80, 'https' => 443];
1178+
/*private*/ const SCHEMES = ['http' => 80, 'https' => 443];
11791179

1180-
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
1180+
/*private*/ const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
11811181

1182-
private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
1182+
/*private*/ const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
11831183

11841184
private $scheme = '';
11851185

@@ -1253,7 +1253,7 @@ public function getHost(): string
12531253
return $this->host;
12541254
}
12551255

1256-
public function getPort(): ?int
1256+
public function getPort() /*:?int*/
12571257
{
12581258
return $this->port;
12591259
}
@@ -1412,7 +1412,7 @@ private static function isNonStandardPort(string $scheme, int $port): bool
14121412
return !isset(self::SCHEMES[$scheme]) || $port !== self::SCHEMES[$scheme];
14131413
}
14141414

1415-
private function filterPort($port): ?int
1415+
private function filterPort($port) /*:?int*/
14161416
{
14171417
if (null === $port) {
14181418
return null;
@@ -6571,7 +6571,7 @@ public function getType(string $table): string
65716571
return $this->reflection->getType($table);
65726572
}
65736573

6574-
public function create(string $tableName, /* object */ $record, array $params)
6574+
public function create(string $tableName, /* object */ $record, array $params) /*: ?int*/
65756575
{
65766576
$this->sanitizeRecord($tableName, $record, '');
65776577
$table = $this->reflection->getTable($tableName);
@@ -6593,21 +6593,21 @@ public function read(string $tableName, string $id, array $params) /*: ?object*/
65936593
return $records[0];
65946594
}
65956595

6596-
public function update(string $tableName, string $id, /* object */ $record, array $params)
6596+
public function update(string $tableName, string $id, /* object */ $record, array $params) /*: ?int*/
65976597
{
65986598
$this->sanitizeRecord($tableName, $record, $id);
65996599
$table = $this->reflection->getTable($tableName);
66006600
$columnValues = $this->columns->getValues($table, true, $record, $params);
66016601
return $this->db->updateSingle($table, $columnValues, $id);
66026602
}
66036603

6604-
public function delete(string $tableName, string $id, array $params)
6604+
public function delete(string $tableName, string $id, array $params) /*: ?int*/
66056605
{
66066606
$table = $this->reflection->getTable($tableName);
66076607
return $this->db->deleteSingle($table, $id);
66086608
}
66096609

6610-
public function increment(string $tableName, string $id, /* object */ $record, array $params)
6610+
public function increment(string $tableName, string $id, /* object */ $record, array $params) /*: ?int*/
66116611
{
66126612
$this->sanitizeRecord($tableName, $record, $id);
66136613
$table = $this->reflection->getTable($tableName);
@@ -6925,7 +6925,7 @@ private function setHabtmValues(ReflectedTable $t1, ReflectedTable $t2, array &$
69256925

69266926
// file: src/Tqdev/PhpCrudApi/Api.php
69276927

6928-
class Api
6928+
class Api implements RequestHandlerInterface
69296929
{
69306930
private $router;
69316931
private $responder;

build.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ function run(string $base, array $dirs, string $filename, array $ignore, array $
117117
'vendor/psr',
118118
];
119119

120-
if (!file_exists('composer.phar')) {
121-
$composer = file_get_contents('https://getcomposer.org/composer.phar');
122-
file_put_contents('composer.phar', $composer);
123-
exec('php composer.phar install');
124-
}
120+
exec('php test.php');
125121

126122
run(__DIR__, ['vendor', 'src'], 'api.php', $ignore, $priority);

test.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
use Tqdev\PhpCrudApi\RequestFactory;
66
use Tqdev\PhpCrudApi\ResponseUtils;
77

8+
if (!file_exists('composer.phar')) {
9+
$composer = file_get_contents('https://getcomposer.org/composer.phar');
10+
file_put_contents('composer.phar', $composer);
11+
}
12+
if (!file_exists('vendor')) {
13+
exec('php composer.phar install');
14+
}
15+
exec('php patch.php');
16+
817
require 'vendor/autoload.php';
918

1019
function runDir(Config $config, string $dir, array $matches, string $category): array

0 commit comments

Comments
 (0)