Skip to content

Commit 8460d99

Browse files
committed
wip
1 parent 71e2671 commit 8460d99

32 files changed

+140
-3353
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/
2+
composer.phar
3+
composer.lock

api.php

Lines changed: 90 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,65 @@
77

88
namespace Tqdev\PhpCrudApi;
99

10-
// file: src/Psr/Http/Message/MessageInterface.php
10+
// file: vendor/psr/http-factory/src/RequestFactoryInterface.php
11+
12+
interface RequestFactoryInterface
13+
{
14+
15+
public function createRequest(string $method, $uri): RequestInterface;
16+
}
17+
18+
// file: vendor/psr/http-factory/src/ResponseFactoryInterface.php
19+
20+
interface ResponseFactoryInterface
21+
{
22+
23+
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface;
24+
}
25+
26+
// file: vendor/psr/http-factory/src/ServerRequestFactoryInterface.php
27+
28+
interface ServerRequestFactoryInterface
29+
{
30+
31+
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface;
32+
}
33+
34+
// file: vendor/psr/http-factory/src/StreamFactoryInterface.php
35+
36+
interface StreamFactoryInterface
37+
{
38+
39+
public function createStream(string $content = ''): StreamInterface;
40+
41+
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface;
42+
43+
public function createStreamFromResource($resource): StreamInterface;
44+
}
45+
46+
// file: vendor/psr/http-factory/src/UploadedFileFactoryInterface.php
47+
48+
interface UploadedFileFactoryInterface
49+
{
50+
51+
public function createUploadedFile(
52+
StreamInterface $stream,
53+
int $size = null,
54+
int $error = \UPLOAD_ERR_OK,
55+
string $clientFilename = null,
56+
string $clientMediaType = null
57+
): UploadedFileInterface;
58+
}
59+
60+
// file: vendor/psr/http-factory/src/UriFactoryInterface.php
61+
62+
interface UriFactoryInterface
63+
{
64+
65+
public function createUri(string $uri = ''): UriInterface;
66+
}
67+
68+
// file: vendor/psr/http-message/src/MessageInterface.php
1169

1270
interface MessageInterface
1371
{
@@ -35,15 +93,7 @@ public function getBody();
3593
public function withBody(StreamInterface $body);
3694
}
3795

38-
// file: src/Psr/Http/Message/RequestFactoryInterface.php
39-
40-
interface RequestFactoryInterface
41-
{
42-
43-
public function createRequest(string $method, $uri): RequestInterface;
44-
}
45-
46-
// file: src/Psr/Http/Message/RequestInterface.php
96+
// file: vendor/psr/http-message/src/RequestInterface.php
4797

4898
interface RequestInterface extends MessageInterface
4999
{
@@ -61,15 +111,7 @@ public function getUri();
61111
public function withUri(UriInterface $uri, $preserveHost = false);
62112
}
63113

64-
// file: src/Psr/Http/Message/ResponseFactoryInterface.php
65-
66-
interface ResponseFactoryInterface
67-
{
68-
69-
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface;
70-
}
71-
72-
// file: src/Psr/Http/Message/ResponseInterface.php
114+
// file: vendor/psr/http-message/src/ResponseInterface.php
73115

74116
interface ResponseInterface extends MessageInterface
75117
{
@@ -81,15 +123,7 @@ public function withStatus($code, $reasonPhrase = '');
81123
public function getReasonPhrase();
82124
}
83125

84-
// file: src/Psr/Http/Message/ServerRequestFactoryInterface.php
85-
86-
interface ServerRequestFactoryInterface
87-
{
88-
89-
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface;
90-
}
91-
92-
// file: src/Psr/Http/Message/ServerRequestInterface.php
126+
// file: vendor/psr/http-message/src/ServerRequestInterface.php
93127

94128
interface ServerRequestInterface extends RequestInterface
95129
{
@@ -121,19 +155,7 @@ public function withAttribute($name, $value);
121155
public function withoutAttribute($name);
122156
}
123157

124-
// file: src/Psr/Http/Message/StreamFactoryInterface.php
125-
126-
interface StreamFactoryInterface
127-
{
128-
129-
public function createStream(string $content = ''): StreamInterface;
130-
131-
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface;
132-
133-
public function createStreamFromResource($resource): StreamInterface;
134-
}
135-
136-
// file: src/Psr/Http/Message/StreamInterface.php
158+
// file: vendor/psr/http-message/src/StreamInterface.php
137159

138160
interface StreamInterface
139161
{
@@ -169,21 +191,7 @@ public function getContents();
169191
public function getMetadata($key = null);
170192
}
171193

172-
// file: src/Psr/Http/Message/UploadedFileFactoryInterface.php
173-
174-
interface UploadedFileFactoryInterface
175-
{
176-
177-
public function createUploadedFile(
178-
StreamInterface $stream,
179-
int $size = null,
180-
int $error = \UPLOAD_ERR_OK,
181-
string $clientFilename = null,
182-
string $clientMediaType = null
183-
): UploadedFileInterface;
184-
}
185-
186-
// file: src/Psr/Http/Message/UploadedFileInterface.php
194+
// file: vendor/psr/http-message/src/UploadedFileInterface.php
187195

188196
interface UploadedFileInterface
189197
{
@@ -201,15 +209,7 @@ public function getClientFilename();
201209
public function getClientMediaType();
202210
}
203211

204-
// file: src/Psr/Http/Message/UriFactoryInterface.php
205-
206-
interface UriFactoryInterface
207-
{
208-
209-
public function createUri(string $uri = ''): UriInterface;
210-
}
211-
212-
// file: src/Psr/Http/Message/UriInterface.php
212+
// file: vendor/psr/http-message/src/UriInterface.php
213213

214214
interface UriInterface
215215
{
@@ -247,23 +247,23 @@ public function withFragment($fragment);
247247
public function __toString();
248248
}
249249

250-
// file: src/Psr/Http/Server/MiddlewareInterface.php
250+
// file: vendor/psr/http-server-handler/src/RequestHandlerInterface.php
251251

252-
interface MiddlewareInterface
252+
interface RequestHandlerInterface
253253
{
254254

255-
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface;
255+
public function handle(ServerRequestInterface $request): ResponseInterface;
256256
}
257257

258-
// file: src/Psr/Http/Server/RequestHandlerInterface.php
258+
// file: vendor/psr/http-server-middleware/src/MiddlewareInterface.php
259259

260-
interface RequestHandlerInterface
260+
interface MiddlewareInterface
261261
{
262262

263-
public function handle(ServerRequestInterface $request): ResponseInterface;
263+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface;
264264
}
265265

266-
// file: src/Nyholm/Psr7/Factory/Psr17Factory.php
266+
// file: vendor/nyholm/psr7/src/Factory/Psr17Factory.php
267267

268268
final class Psr17Factory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
269269
{
@@ -321,7 +321,7 @@ public function createServerRequest(string $method, $uri, array $serverParams =
321321
}
322322
}
323323

324-
// file: src/Nyholm/Psr7/MessageTrait.php
324+
// file: vendor/nyholm/psr7/src/MessageTrait.php
325325

326326
trait MessageTrait
327327
{
@@ -486,7 +486,7 @@ private function validateAndTrimHeader($header, $values): array
486486
}
487487
}
488488

489-
// file: src/Nyholm/Psr7/Request.php
489+
// file: vendor/nyholm/psr7/src/Request.php
490490

491491
final class Request implements RequestInterface
492492
{
@@ -514,7 +514,7 @@ public function __construct(string $method, $uri, array $headers = [], $body = n
514514
}
515515
}
516516

517-
// file: src/Nyholm/Psr7/RequestTrait.php
517+
// file: vendor/nyholm/psr7/src/RequestTrait.php
518518

519519
trait RequestTrait
520520
{
@@ -611,7 +611,7 @@ private function updateHostFromUri(): void
611611
}
612612
}
613613

614-
// file: src/Nyholm/Psr7/Response.php
614+
// file: vendor/nyholm/psr7/src/Response.php
615615

616616
final class Response implements ResponseInterface
617617
{
@@ -678,7 +678,7 @@ public function withStatus($code, $reasonPhrase = ''): self
678678
}
679679
}
680680

681-
// file: src/Nyholm/Psr7/ServerRequest.php
681+
// file: vendor/nyholm/psr7/src/ServerRequest.php
682682

683683
final class ServerRequest implements ServerRequestInterface
684684
{
@@ -815,7 +815,7 @@ public function withoutAttribute($attribute): self
815815
}
816816
}
817817

818-
// file: src/Nyholm/Psr7/Stream.php
818+
// file: vendor/nyholm/psr7/src/Stream.php
819819

820820
final class Stream implements StreamInterface
821821
{
@@ -1042,7 +1042,7 @@ public function getMetadata($key = null)
10421042
}
10431043
}
10441044

1045-
// file: src/Nyholm/Psr7/UploadedFile.php
1045+
// file: vendor/nyholm/psr7/src/UploadedFile.php
10461046

10471047
final class UploadedFile implements UploadedFileInterface
10481048
{
@@ -1184,7 +1184,7 @@ public function getClientMediaType(): ?string
11841184
}
11851185
}
11861186

1187-
// file: src/Nyholm/Psr7/Uri.php
1187+
// file: vendor/nyholm/psr7/src/Uri.php
11881188

11891189
final class Uri implements UriInterface
11901190
{
@@ -1463,7 +1463,7 @@ private static function rawurlencodeMatchZero(array $match): string
14631463
}
14641464
}
14651465

1466-
// file: src/Nyholm/Psr7Server/ServerRequestCreator.php
1466+
// file: vendor/nyholm/psr7-server/src/ServerRequestCreator.php
14671467

14681468
final class ServerRequestCreator implements ServerRequestCreatorInterface
14691469
{
@@ -1496,7 +1496,7 @@ public function fromGlobals(): ServerRequestInterface
14961496

14971497
$headers = \function_exists('getallheaders') ? getallheaders() : static::getHeadersFromServer($_SERVER);
14981498

1499-
return $this->fromArrays($server, $headers, $_COOKIE, $_GET, $_POST, $_FILES, \fopen('php://input', 'r') ?: null);
1499+
return $this->fromArrays($server, $headers, $_COOKIE, $_GET, $_POST, $_FILES, fopen('php://input', 'r') ?: null);
15001500
}
15011501

15021502
public function fromArrays(array $server, array $headers = [], array $cookie = [], array $get = [], array $post = [], array $files = [], $body = null): ServerRequestInterface
@@ -1649,20 +1649,16 @@ private function createUriFromArray(array $server): UriInterface
16491649
$uri = $uri->withScheme('on' === $server['HTTPS'] ? 'https' : 'http');
16501650
}
16511651

1652-
if (isset($server['SERVER_PORT'])) {
1653-
$uri = $uri->withPort($server['SERVER_PORT']);
1654-
}
1655-
16561652
if (isset($server['HTTP_HOST'])) {
1657-
if (1 === \preg_match('/^(.+)\:(\d+)$/', $server['HTTP_HOST'], $matches)) {
1658-
$uri = $uri->withHost($matches[1])->withPort($matches[2]);
1659-
} else {
1660-
$uri = $uri->withHost($server['HTTP_HOST']);
1661-
}
1653+
$uri = $uri->withHost($server['HTTP_HOST']);
16621654
} elseif (isset($server['SERVER_NAME'])) {
16631655
$uri = $uri->withHost($server['SERVER_NAME']);
16641656
}
16651657

1658+
if (isset($server['SERVER_PORT'])) {
1659+
$uri = $uri->withPort($server['SERVER_PORT']);
1660+
}
1661+
16661662
if (isset($server['REQUEST_URI'])) {
16671663
$uri = $uri->withPath(\current(\explode('?', $server['REQUEST_URI'])));
16681664
}
@@ -1675,7 +1671,7 @@ private function createUriFromArray(array $server): UriInterface
16751671
}
16761672
}
16771673

1678-
// file: src/Nyholm/Psr7Server/ServerRequestCreatorInterface.php
1674+
// file: vendor/nyholm/psr7-server/src/ServerRequestCreatorInterface.php
16791675

16801676
interface ServerRequestCreatorInterface
16811677
{
@@ -3466,7 +3462,7 @@ class GenericDB
34663462
private $columns;
34673463
private $converter;
34683464

3469-
private function getDsn(string $address, string $port, string $database): string
3465+
private function getDsn(string $address, int $port, string $database): string
34703466
{
34713467
switch ($this->driver) {
34723468
case 'mysql':return "$this->driver:host=$address;port=$port;dbname=$database;charset=utf8mb4";
@@ -3514,7 +3510,7 @@ private function getOptions(): array
35143510
}
35153511
}
35163512

3517-
public function __construct(string $driver, string $address, string $port, string $database, string $username, string $password)
3513+
public function __construct(string $driver, string $address, int $port, string $database, string $username, string $password)
35183514
{
35193515
$this->driver = $driver;
35203516
$this->database = $database;

0 commit comments

Comments
 (0)