Quellcode durchsuchen

PSR-12 compatibility

Maurits van der Schee vor 5 Jahren
Ursprung
Commit
cfa24ddd40
1 geänderte Dateien mit 59 neuen und 81 gelöschten Zeilen
  1. 59
    81
      api.php

+ 59
- 81
api.php Datei anzeigen

@@ -3385,7 +3385,7 @@ namespace Tqdev\PhpCrudApi\Cache {
3385 3385
 
3386 3386
     class TempFileCache implements Cache
3387 3387
     {
3388
-        const SUFFIX = 'cache';
3388
+        public const SUFFIX = 'cache';
3389 3389
 
3390 3390
         private $path;
3391 3391
         private $segments;
@@ -3534,9 +3534,9 @@ namespace Tqdev\PhpCrudApi\Column\Reflection {
3534 3534
 
3535 3535
     class ReflectedColumn implements \JsonSerializable
3536 3536
     {
3537
-        const DEFAULT_LENGTH = 255;
3538
-        const DEFAULT_PRECISION = 19;
3539
-        const DEFAULT_SCALE = 4;
3537
+        public const DEFAULT_LENGTH = 255;
3538
+        public const DEFAULT_PRECISION = 19;
3539
+        public const DEFAULT_SCALE = 4;
3540 3540
 
3541 3541
         private $name;
3542 3542
         private $type;
@@ -3573,7 +3573,7 @@ namespace Tqdev\PhpCrudApi\Column\Reflection {
3573 3573
             return new ReflectedColumn($name, $type, $length, $precision, $scale, $nullable, $pk, $fk);
3574 3574
         }
3575 3575
 
3576
-        public static function fromJson( /* object */$json): ReflectedColumn
3576
+        public static function fromJson(/* object */$json): ReflectedColumn
3577 3577
         {
3578 3578
             $name = $json->name;
3579 3579
             $type = $json->type;
@@ -3727,7 +3727,7 @@ namespace Tqdev\PhpCrudApi\Column\Reflection {
3727 3727
             return new ReflectedDatabase($tableTypes);
3728 3728
         }
3729 3729
 
3730
-        public static function fromJson( /* object */$json): ReflectedDatabase
3730
+        public static function fromJson(/* object */$json): ReflectedDatabase
3731 3731
         {
3732 3732
             $tableTypes = (array) $json->tables;
3733 3733
             return new ReflectedDatabase($tableTypes);
@@ -3837,7 +3837,7 @@ namespace Tqdev\PhpCrudApi\Column\Reflection {
3837 3837
             return new ReflectedTable($name, $type, array_values($columns));
3838 3838
         }
3839 3839
 
3840
-        public static function fromJson( /* object */$json): ReflectedTable
3840
+        public static function fromJson(/* object */$json): ReflectedTable
3841 3841
         {
3842 3842
             $name = $json->name;
3843 3843
             $type = $json->type;
@@ -4020,7 +4020,7 @@ namespace Tqdev\PhpCrudApi\Column {
4020 4020
             return true;
4021 4021
         }
4022 4022
 
4023
-        public function addTable( /* object */$definition)
4023
+        public function addTable(/* object */$definition)
4024 4024
         {
4025 4025
             $newTable = ReflectedTable::fromJson($definition);
4026 4026
             if (!$this->db->definition()->addTable($newTable)) {
@@ -4077,7 +4077,6 @@ namespace Tqdev\PhpCrudApi\Column {
4077 4077
             }
4078 4078
             return true;
4079 4079
         }
4080
-
4081 4080
     }
4082 4081
 }
4083 4082
 
@@ -4213,7 +4212,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4213 4212
         {
4214 4213
             return $this->responder->success($this->cache->clear());
4215 4214
         }
4216
-
4217 4215
     }
4218 4216
 }
4219 4217
 
@@ -4440,7 +4438,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4440 4438
                 return $this->responder->success($response);
4441 4439
             }
4442 4440
         }
4443
-
4444 4441
     }
4445 4442
 }
4446 4443
 
@@ -4466,7 +4463,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4466 4463
         {
4467 4464
             return ResponseFactory::fromObject(ResponseFactory::OK, $result);
4468 4465
         }
4469
-
4470 4466
     }
4471 4467
 }
4472 4468
 
@@ -4494,7 +4490,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4494 4490
         {
4495 4491
             return $this->responder->success($this->openApi->get());
4496 4492
         }
4497
-
4498 4493
     }
4499 4494
 }
4500 4495
 
@@ -4675,7 +4670,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4675 4670
                 return $this->responder->success($this->service->increment($table, $id, $record, $params));
4676 4671
             }
4677 4672
         }
4678
-
4679 4673
     }
4680 4674
 }
4681 4675
 
@@ -4689,7 +4683,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4689 4683
         public function error(int $error, string $argument, $details = null): ResponseInterface;
4690 4684
 
4691 4685
         public function success($result): ResponseInterface;
4692
-
4693 4686
     }
4694 4687
 }
4695 4688
 
@@ -4755,7 +4748,6 @@ namespace Tqdev\PhpCrudApi\Database {
4755 4748
             }
4756 4749
             return $value;
4757 4750
         }
4758
-
4759 4751
     }
4760 4752
 }
4761 4753
 
@@ -4866,7 +4858,6 @@ namespace Tqdev\PhpCrudApi\Database {
4866 4858
             }
4867 4859
             return implode(',', $results);
4868 4860
         }
4869
-
4870 4861
     }
4871 4862
 }
4872 4863
 
@@ -5520,9 +5511,9 @@ namespace Tqdev\PhpCrudApi\Database {
5520 5511
             $type = $this->typeConverter->fromJdbc($column->getType());
5521 5512
             if ($column->hasPrecision() && $column->hasScale()) {
5522 5513
                 $size = '(' . $column->getPrecision() . ',' . $column->getScale() . ')';
5523
-            } else if ($column->hasPrecision()) {
5514
+            } elseif ($column->hasPrecision()) {
5524 5515
                 $size = '(' . $column->getPrecision() . ')';
5525
-            } else if ($column->hasLength()) {
5516
+            } elseif ($column->hasLength()) {
5526 5517
                 $size = '(' . $column->getLength() . ')';
5527 5518
             } else {
5528 5519
                 $size = '';
@@ -6516,7 +6507,7 @@ namespace Tqdev\PhpCrudApi\GeoJson {
6516 6507
             return [$lon, $lat];
6517 6508
         }
6518 6509
 
6519
-        private function convertRecordToFeature( /*object*/$record, string $primaryKeyColumnName, string $geometryColumnName)
6510
+        private function convertRecordToFeature(/*object*/$record, string $primaryKeyColumnName, string $geometryColumnName)
6520 6511
         {
6521 6512
             $id = null;
6522 6513
             if ($primaryKeyColumnName) {
@@ -6667,7 +6658,7 @@ namespace Tqdev\PhpCrudApi\Middleware\Communication {
6667 6658
 
6668 6659
     class VariableStore
6669 6660
     {
6670
-        static $values = array();
6661
+        public static $values = array();
6671 6662
 
6672 6663
         public static function get(string $key)
6673 6664
         {
@@ -6860,7 +6851,6 @@ namespace Tqdev\PhpCrudApi\Middleware\Router {
6860 6851
             }
6861 6852
             return $response;
6862 6853
         }
6863
-
6864 6854
     }
6865 6855
 }
6866 6856
 
@@ -7371,8 +7361,8 @@ namespace Tqdev\PhpCrudApi\Middleware {
7371 7361
     use Psr\Http\Message\ResponseInterface;
7372 7362
     use Psr\Http\Message\ServerRequestInterface;
7373 7363
     use Psr\Http\Server\RequestHandlerInterface;
7374
-    use Tqdev\PhpCrudApi\Column\ReflectionService;
7375 7364
     use Tqdev\PhpCrudApi\Column\Reflection\ReflectedTable;
7365
+    use Tqdev\PhpCrudApi\Column\ReflectionService;
7376 7366
     use Tqdev\PhpCrudApi\Controller\Responder;
7377 7367
     use Tqdev\PhpCrudApi\Middleware\Base\Middleware;
7378 7368
     use Tqdev\PhpCrudApi\Middleware\Router\Router;
@@ -7895,8 +7885,8 @@ namespace Tqdev\PhpCrudApi\Middleware {
7895 7885
     use Psr\Http\Message\ResponseInterface;
7896 7886
     use Psr\Http\Message\ServerRequestInterface;
7897 7887
     use Psr\Http\Server\RequestHandlerInterface;
7898
-    use Tqdev\PhpCrudApi\Column\ReflectionService;
7899 7888
     use Tqdev\PhpCrudApi\Column\Reflection\ReflectedTable;
7889
+    use Tqdev\PhpCrudApi\Column\ReflectionService;
7900 7890
     use Tqdev\PhpCrudApi\Controller\Responder;
7901 7891
     use Tqdev\PhpCrudApi\Middleware\Base\Middleware;
7902 7892
     use Tqdev\PhpCrudApi\Middleware\Router\Router;
@@ -7959,8 +7949,8 @@ namespace Tqdev\PhpCrudApi\Middleware {
7959 7949
     use Psr\Http\Message\ResponseInterface;
7960 7950
     use Psr\Http\Message\ServerRequestInterface;
7961 7951
     use Psr\Http\Server\RequestHandlerInterface;
7962
-    use Tqdev\PhpCrudApi\Column\ReflectionService;
7963 7952
     use Tqdev\PhpCrudApi\Column\Reflection\ReflectedTable;
7953
+    use Tqdev\PhpCrudApi\Column\ReflectionService;
7964 7954
     use Tqdev\PhpCrudApi\Controller\Responder;
7965 7955
     use Tqdev\PhpCrudApi\Middleware\Base\Middleware;
7966 7956
     use Tqdev\PhpCrudApi\Middleware\Router\Router;
@@ -8476,7 +8466,6 @@ namespace Tqdev\PhpCrudApi\OpenApi {
8476 8466
         {
8477 8467
             return $this->builder->build();
8478 8468
         }
8479
-
8480 8469
     }
8481 8470
 }
8482 8471
 
@@ -8618,7 +8607,6 @@ namespace Tqdev\PhpCrudApi\Record\Condition {
8618 8607
             }
8619 8608
             return $condition;
8620 8609
         }
8621
-
8622 8610
     }
8623 8611
 }
8624 8612
 
@@ -8641,7 +8629,6 @@ namespace Tqdev\PhpCrudApi\Record\Condition {
8641 8629
         {
8642 8630
             return $this;
8643 8631
         }
8644
-
8645 8632
     }
8646 8633
 }
8647 8634
 
@@ -8758,7 +8745,6 @@ namespace Tqdev\PhpCrudApi\Record\Document {
8758 8745
 
8759 8746
     class ListDocument implements \JsonSerializable
8760 8747
     {
8761
-
8762 8748
         private $records;
8763 8749
 
8764 8750
         private $results;
@@ -8803,14 +8789,19 @@ namespace Tqdev\PhpCrudApi\Record {
8803 8789
 
8804 8790
     class ColumnIncluder
8805 8791
     {
8806
-
8807 8792
         private function isMandatory(string $tableName, string $columnName, array $params): bool
8808 8793
         {
8809 8794
             return isset($params['mandatory']) && in_array($tableName . "." . $columnName, $params['mandatory']);
8810 8795
         }
8811 8796
 
8812
-        private function select(string $tableName, bool $primaryTable, array $params, string $paramName,
8813
-            array $columnNames, bool $include): array{
8797
+        private function select(
8798
+            string $tableName,
8799
+            bool $primaryTable,
8800
+            array $params,
8801
+            string $paramName,
8802
+            array $columnNames,
8803
+            bool $include
8804
+        ): array {
8814 8805
             if (!isset($params[$paramName])) {
8815 8806
                 return $columnNames;
8816 8807
             }
@@ -8860,7 +8851,6 @@ namespace Tqdev\PhpCrudApi\Record {
8860 8851
             }
8861 8852
             return $results;
8862 8853
         }
8863
-
8864 8854
     }
8865 8855
 }
8866 8856
 
@@ -8871,32 +8861,31 @@ namespace Tqdev\PhpCrudApi\Record {
8871 8861
 
8872 8862
     class ErrorCode
8873 8863
     {
8874
-
8875 8864
         private $code;
8876 8865
         private $message;
8877 8866
         private $status;
8878 8867
 
8879
-        const ERROR_NOT_FOUND = 9999;
8880
-        const ROUTE_NOT_FOUND = 1000;
8881
-        const TABLE_NOT_FOUND = 1001;
8882
-        const ARGUMENT_COUNT_MISMATCH = 1002;
8883
-        const RECORD_NOT_FOUND = 1003;
8884
-        const ORIGIN_FORBIDDEN = 1004;
8885
-        const COLUMN_NOT_FOUND = 1005;
8886
-        const TABLE_ALREADY_EXISTS = 1006;
8887
-        const COLUMN_ALREADY_EXISTS = 1007;
8888
-        const HTTP_MESSAGE_NOT_READABLE = 1008;
8889
-        const DUPLICATE_KEY_EXCEPTION = 1009;
8890
-        const DATA_INTEGRITY_VIOLATION = 1010;
8891
-        const AUTHENTICATION_REQUIRED = 1011;
8892
-        const AUTHENTICATION_FAILED = 1012;
8893
-        const INPUT_VALIDATION_FAILED = 1013;
8894
-        const OPERATION_FORBIDDEN = 1014;
8895
-        const OPERATION_NOT_SUPPORTED = 1015;
8896
-        const TEMPORARY_OR_PERMANENTLY_BLOCKED = 1016;
8897
-        const BAD_OR_MISSING_XSRF_TOKEN = 1017;
8898
-        const ONLY_AJAX_REQUESTS_ALLOWED = 1018;
8899
-        const PAGINATION_FORBIDDEN = 1019;
8868
+        public const ERROR_NOT_FOUND = 9999;
8869
+        public const ROUTE_NOT_FOUND = 1000;
8870
+        public const TABLE_NOT_FOUND = 1001;
8871
+        public const ARGUMENT_COUNT_MISMATCH = 1002;
8872
+        public const RECORD_NOT_FOUND = 1003;
8873
+        public const ORIGIN_FORBIDDEN = 1004;
8874
+        public const COLUMN_NOT_FOUND = 1005;
8875
+        public const TABLE_ALREADY_EXISTS = 1006;
8876
+        public const COLUMN_ALREADY_EXISTS = 1007;
8877
+        public const HTTP_MESSAGE_NOT_READABLE = 1008;
8878
+        public const DUPLICATE_KEY_EXCEPTION = 1009;
8879
+        public const DATA_INTEGRITY_VIOLATION = 1010;
8880
+        public const AUTHENTICATION_REQUIRED = 1011;
8881
+        public const AUTHENTICATION_FAILED = 1012;
8882
+        public const INPUT_VALIDATION_FAILED = 1013;
8883
+        public const OPERATION_FORBIDDEN = 1014;
8884
+        public const OPERATION_NOT_SUPPORTED = 1015;
8885
+        public const TEMPORARY_OR_PERMANENTLY_BLOCKED = 1016;
8886
+        public const BAD_OR_MISSING_XSRF_TOKEN = 1017;
8887
+        public const ONLY_AJAX_REQUESTS_ALLOWED = 1018;
8888
+        public const PAGINATION_FORBIDDEN = 1019;
8900 8889
 
8901 8890
         private $values = [
8902 8891
             9999 => ["%s", ResponseFactory::INTERNAL_SERVER_ERROR],
@@ -8946,7 +8935,6 @@ namespace Tqdev\PhpCrudApi\Record {
8946 8935
         {
8947 8936
             return $this->status;
8948 8937
         }
8949
-
8950 8938
     }
8951 8939
 }
8952 8940
 
@@ -8961,7 +8949,6 @@ namespace Tqdev\PhpCrudApi\Record {
8961 8949
 
8962 8950
     class FilterInfo
8963 8951
     {
8964
-
8965 8952
         private function addConditionFromFilterPath(PathTree $conditions, array $path, ReflectedTable $table, array $params)
8966 8953
         {
8967 8954
             $key = 'filter' . implode('', $path);
@@ -9004,7 +8991,6 @@ namespace Tqdev\PhpCrudApi\Record {
9004 8991
         {
9005 8992
             return $this->combinePathTreeOfConditions($this->getConditionsAsPathTree($table, $params));
9006 8993
         }
9007
-
9008 8994
     }
9009 8995
 }
9010 8996
 
@@ -9031,7 +9017,6 @@ namespace Tqdev\PhpCrudApi\Record {
9031 9017
 
9032 9018
     class OrderingInfo
9033 9019
     {
9034
-
9035 9020
         public function getColumnOrdering(ReflectedTable $table, array $params): array
9036 9021
         {
9037 9022
             $fields = array();
@@ -9078,7 +9063,6 @@ namespace Tqdev\PhpCrudApi\Record {
9078 9063
 
9079 9064
     class PaginationInfo
9080 9065
     {
9081
-
9082 9066
         public $DEFAULT_PAGE_SIZE = 20;
9083 9067
 
9084 9068
         public function hasPage(array $params): bool
@@ -9141,7 +9125,6 @@ namespace Tqdev\PhpCrudApi\Record {
9141 9125
             }
9142 9126
             return $pageLimit;
9143 9127
         }
9144
-
9145 9128
     }
9146 9129
 }
9147 9130
 
@@ -9150,11 +9133,11 @@ namespace Tqdev\PhpCrudApi\Record {
9150 9133
 
9151 9134
     class PathTree implements \JsonSerializable
9152 9135
     {
9153
-        const WILDCARD = '*';
9136
+        public const WILDCARD = '*';
9154 9137
 
9155 9138
         private $tree;
9156 9139
 
9157
-        public function __construct( /* object */&$tree = null)
9140
+        public function __construct(/* object */&$tree = null)
9158 9141
         {
9159 9142
             if (!$tree) {
9160 9143
                 $tree = $this->newTree();
@@ -9205,7 +9188,7 @@ namespace Tqdev\PhpCrudApi\Record {
9205 9188
             foreach ($path as $key) {
9206 9189
                 if (isset($tree->branches->$key)) {
9207 9190
                     $tree = &$tree->branches->$key;
9208
-                } else if (isset($tree->branches->$star)) {
9191
+                } elseif (isset($tree->branches->$star)) {
9209 9192
                     $tree = &$tree->branches->$star;
9210 9193
                 } else {
9211 9194
                     return [];
@@ -9214,7 +9197,7 @@ namespace Tqdev\PhpCrudApi\Record {
9214 9197
             return $tree->values;
9215 9198
         }
9216 9199
 
9217
-        public static function fromJson( /* object */$tree): PathTree
9200
+        public static function fromJson(/* object */$tree): PathTree
9218 9201
         {
9219 9202
             return new PathTree($tree);
9220 9203
         }
@@ -9353,8 +9336,8 @@ namespace Tqdev\PhpCrudApi\Record {
9353 9336
 // file: src/Tqdev/PhpCrudApi/Record/RelationJoiner.php
9354 9337
 namespace Tqdev\PhpCrudApi\Record {
9355 9338
 
9356
-    use Tqdev\PhpCrudApi\Column\ReflectionService;
9357 9339
     use Tqdev\PhpCrudApi\Column\Reflection\ReflectedTable;
9340
+    use Tqdev\PhpCrudApi\Column\ReflectionService;
9358 9341
     use Tqdev\PhpCrudApi\Database\GenericDB;
9359 9342
     use Tqdev\PhpCrudApi\Middleware\Communication\VariableStore;
9360 9343
     use Tqdev\PhpCrudApi\Record\Condition\ColumnCondition;
@@ -9362,7 +9345,6 @@ namespace Tqdev\PhpCrudApi\Record {
9362 9345
 
9363 9346
     class RelationJoiner
9364 9347
     {
9365
-
9366 9348
         private $reflection;
9367 9349
         private $ordering;
9368 9350
         private $columns;
@@ -9444,9 +9426,7 @@ namespace Tqdev\PhpCrudApi\Record {
9444 9426
 
9445 9427
         private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$records, array $params, GenericDB $db)
9446 9428
         {
9447
-
9448 9429
             foreach ($joins->getKeys() as $t2Name) {
9449
-
9450 9430
                 $t2 = $this->reflection->getTable($t2Name);
9451 9431
 
9452 9432
                 $belongsTo = count($t1->getFksTo($t2->getName())) > 0;
@@ -9673,9 +9653,9 @@ namespace Tqdev\PhpCrudApi {
9673 9653
     use Tqdev\PhpCrudApi\Middleware\IpAddressMiddleware;
9674 9654
     use Tqdev\PhpCrudApi\Middleware\JoinLimitsMiddleware;
9675 9655
     use Tqdev\PhpCrudApi\Middleware\JwtAuthMiddleware;
9676
-    use Tqdev\PhpCrudApi\Middleware\ReconnectMiddleware;
9677 9656
     use Tqdev\PhpCrudApi\Middleware\MultiTenancyMiddleware;
9678 9657
     use Tqdev\PhpCrudApi\Middleware\PageLimitsMiddleware;
9658
+    use Tqdev\PhpCrudApi\Middleware\ReconnectMiddleware;
9679 9659
     use Tqdev\PhpCrudApi\Middleware\Router\SimpleRouter;
9680 9660
     use Tqdev\PhpCrudApi\Middleware\SanitationMiddleware;
9681 9661
     use Tqdev\PhpCrudApi\Middleware\ValidationMiddleware;
@@ -10006,8 +9986,8 @@ namespace Tqdev\PhpCrudApi {
10006 9986
 // file: src/Tqdev/PhpCrudApi/RequestFactory.php
10007 9987
 namespace Tqdev\PhpCrudApi {
10008 9988
 
10009
-    use Nyholm\Psr7Server\ServerRequestCreator;
10010 9989
     use Nyholm\Psr7\Factory\Psr17Factory;
9990
+    use Nyholm\Psr7Server\ServerRequestCreator;
10011 9991
     use Psr\Http\Message\ServerRequestInterface;
10012 9992
 
10013 9993
     class RequestFactory
@@ -10143,7 +10123,6 @@ namespace Tqdev\PhpCrudApi {
10143 10123
             }
10144 10124
             return $allTableNames;
10145 10125
         }
10146
-
10147 10126
     }
10148 10127
 }
10149 10128
 
@@ -10155,14 +10134,14 @@ namespace Tqdev\PhpCrudApi {
10155 10134
 
10156 10135
     class ResponseFactory
10157 10136
     {
10158
-        const OK = 200;
10159
-        const UNAUTHORIZED = 401;
10160
-        const FORBIDDEN = 403;
10161
-        const NOT_FOUND = 404;
10162
-        const METHOD_NOT_ALLOWED = 405;
10163
-        const CONFLICT = 409;
10164
-        const UNPROCESSABLE_ENTITY = 422;
10165
-        const INTERNAL_SERVER_ERROR = 500;
10137
+        public const OK = 200;
10138
+        public const UNAUTHORIZED = 401;
10139
+        public const FORBIDDEN = 403;
10140
+        public const NOT_FOUND = 404;
10141
+        public const METHOD_NOT_ALLOWED = 405;
10142
+        public const CONFLICT = 409;
10143
+        public const UNPROCESSABLE_ENTITY = 422;
10144
+        public const INTERNAL_SERVER_ERROR = 500;
10166 10145
 
10167 10146
         public static function fromHtml(int $status, string $html): ResponseInterface
10168 10147
         {
@@ -10192,7 +10171,6 @@ namespace Tqdev\PhpCrudApi {
10192 10171
             $psr17Factory = new Psr17Factory();
10193 10172
             return $psr17Factory->createResponse($status);
10194 10173
         }
10195
-
10196 10174
     }
10197 10175
 }
10198 10176
 

Laden…
Abbrechen
Speichern