Skip to content

Commit 9dcc853

Browse files
committed
Update for docblocks
1 parent ce30f16 commit 9dcc853

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+467
-235
lines changed

BaseMapper.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Feast\Interfaces\DatabaseFactoryInterface;
2929
use Feast\Interfaces\DatabaseInterface;
3030
use PDO;
31+
use stdClass;
3132

3233
/**
3334
* @psalm-consistent-constructor
@@ -42,6 +43,10 @@ abstract class BaseMapper
4243
final public const NOT_NULL = 'not_null';
4344
protected DatabaseInterface $connection;
4445

46+
/**
47+
* @throws ServiceContainer\NotFoundException
48+
* @throws ServerFailureException
49+
*/
4550
public function __construct()
4651
{
4752
$this->connection = di(DatabaseFactoryInterface::class)->getConnection((string)static::CONNECTION);
@@ -72,7 +77,7 @@ protected function map(array $row, array $dataTypes): BaseModel
7277
}
7378
$return->$key = match ($dataTypes[$key]) {
7479
Date::class => Date::createFromString((string)$val),
75-
\stdClass::class => (object)json_decode(
80+
stdClass::class => (object)json_decode(
7681
(string)$val
7782
),
7883
'int' => (int)$val,
@@ -221,18 +226,16 @@ public function fetchOne(Query $select = null): ?BaseModel
221226
$select = $select ?? $this->getQueryBase();
222227

223228
$select->limit(1);
224-
/** @var BaseModel|null $return */
225-
$return = $this->fetchAll($select)->first();
226-
227-
return $return;
229+
/** @var BaseModel|null */
230+
return $this->fetchAll($select)->first();
228231
}
229232

230233
/**
231234
* Fetch all record. Optionally, pass in query object to filter on.
232235
*
233236
* @param Query|null $select
234237
* @return Set
235-
* @throws ServerFailureException|ServiceContainer\NotFoundException
238+
* @throws ServerFailureException|ServiceContainer\NotFoundException|Exception
236239
*/
237240
public function fetchAll(Query $select = null): Set
238241
{
@@ -313,7 +316,7 @@ protected function buildFieldDataForSave(BaseModel|null $originalObject, array $
313316
$return = [];
314317
/**
315318
* @var string $field
316-
* @var int|string|Date|null|\stdClass|array $val
319+
* @var int|string|Date|null|stdClass|array $val
317320
*/
318321
foreach ($fields as $field => $val) {
319322
if ($originalObject !== null && $originalObject->$field === $val) {
@@ -322,7 +325,7 @@ protected function buildFieldDataForSave(BaseModel|null $originalObject, array $
322325
if ($val instanceof Date) {
323326
$val = $val->getFormattedDate();
324327
}
325-
if ($val instanceof \stdClass || is_array($val)) {
328+
if ($val instanceof stdClass || is_array($val)) {
326329
$val = json_encode($val);
327330
}
328331
$return[$field] = $val;
@@ -398,7 +401,7 @@ public function delete(BaseModel $record): int
398401
$recordPrimaryKey
399402
);
400403
$statement = $update->execute();
401-
404+
402405
$this->onDelete($record);
403406
return $statement->rowCount();
404407
}

BaseModel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ abstract class BaseModel
3333
protected const MAPPER_NAME = null;
3434
protected ?BaseModel $originalModel = null;
3535

36+
/**
37+
* @throws InvalidOptionException
38+
*/
3639
public function __set(string $name, mixed $value): void
3740
{
3841
throw new InvalidOptionException('Invalid option for model', ResponseCode::HTTP_CODE_500);
3942
}
4043

44+
/**
45+
* @throws InvalidOptionException
46+
*/
4147
public function __get(string $name): void
4248
{
4349
throw new InvalidOptionException('Invalid option for model', ResponseCode::HTTP_CODE_500);

Binary.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
use Feast\Controllers\TemplateController;
3131
use Feast\Exception\NotFoundException;
3232
use Feast\Interfaces\MainInterface;
33+
use ReflectionClass;
3334
use ReflectionException;
35+
use ReflectionMethod;
3436

3537
class Binary
3638
{
@@ -216,9 +218,9 @@ private function help(string $command): void
216218
/**
217219
* Process description attribute and return whether any methods were found.
218220
*
219-
* @param \ReflectionMethod $method
221+
* @param ReflectionMethod $method
220222
*/
221-
private function processCliMethods(\ReflectionMethod $method): void
223+
private function processCliMethods(ReflectionMethod $method): void
222224
{
223225
$name = NameHelper::getMethodNameAsCallableAction($method->getName());
224226
$class = NameHelper::getControllerClassName($method->getDeclaringClass());
@@ -258,12 +260,14 @@ private function analyzeFeast(
258260
): void {
259261
/** @var class-string $class */
260262
foreach ($classes as $class) {
261-
$this->processCliClass(new \ReflectionClass($class));
263+
$this->processCliClass(new ReflectionClass($class));
262264
}
263265
}
264266

265267
/**
266268
* Process all custom actions in the CLI module.
269+
*
270+
* @throws ReflectionException
267271
*/
268272
private function analyzeCli(): void
269273
{
@@ -277,7 +281,7 @@ private function analyzeCli(): void
277281
// Load class info
278282
/** @var class-string $className */
279283
$className = '\\Modules\\CLI\\Controllers\\' . substr($classFile, 0, -4);
280-
$class = new \ReflectionClass($className);
284+
$class = new ReflectionClass($className);
281285

282286
// Parse class and methods
283287
$this->processCliClass($class);
@@ -288,9 +292,9 @@ private function analyzeCli(): void
288292
/**
289293
* Parse all descriptions for a class and return if any methods had a description.
290294
*
291-
* @param \ReflectionClass $class
295+
* @param ReflectionClass $class
292296
*/
293-
private function processCliClass(\ReflectionClass $class): void
297+
private function processCliClass(ReflectionClass $class): void
294298
{
295299
$className = NameHelper::getControllerClassName($class);
296300
$this->terminal->command($className);

CliController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222

2323
use Feast\Interfaces\ConfigInterface;
2424
use Feast\Interfaces\ControllerInterface;
25+
use Feast\ServiceContainer\NotFoundException;
2526
use Feast\ServiceContainer\ServiceContainer;
2627

2728
abstract class CliController implements ControllerInterface
2829
{
2930
protected Terminal $terminal;
3031

32+
/**
33+
* @throws NotFoundException
34+
*/
3135
public function __construct(
3236
ServiceContainer $di,
3337
?ConfigInterface $config = null,

Collection/CollectionList.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020

2121
namespace Feast\Collection;
2222

23+
use ArrayAccess;
2324
use Feast\Exception\ServerFailureException;
2425

2526
/**
2627
* Class to interact with arrays as key=>value lists
2728
*
2829
* @package Feast\Collection
2930
*/
30-
class CollectionList implements \ArrayAccess,Collection
31+
class CollectionList implements ArrayAccess, Collection
3132
{
3233
use \Feast\Traits\Collection;
3334

@@ -48,7 +49,6 @@ public function __construct(protected string $type = 'mixed', array $values = []
4849
$this->addAll($values);
4950
}
5051

51-
5252
/**
5353
* Add or replace an element to/in the collection
5454
*
@@ -117,13 +117,10 @@ public function offsetExists($offset): bool
117117
*/
118118
public function offsetGet($offset): string|int|bool|float|object|array|null
119119
{
120-
/** @var string|int|bool|float|object|array|null $var */
121-
$var = $this->array[$offset] ?? null;
122-
123-
return $var;
120+
/** @var string|int|bool|float|object|array|null */
121+
return $this->array[$offset] ?? null;
124122
}
125123

126-
127124
/**
128125
* Set element by offset
129126
*
@@ -138,13 +135,12 @@ public function offsetSet($offset, $value): void
138135

139136
/**
140137
* Unset element (if it exists) by offset
141-
*
138+
*
142139
* @param string|int $offset
143140
*/
144141
public function offsetUnset($offset): void
145142
{
146143
unset($this->array[$offset]);
147144
}
148145

149-
150146
}

Collection/Set.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace Feast\Collection;
2222

23+
use ArrayAccess;
24+
use Countable;
2325
use Feast\Exception\InvalidOptionException;
2426
use Feast\Exception\ServerFailureException;
2527
use Feast\Exception\InvalidArgumentException;
@@ -30,7 +32,7 @@
3032
*
3133
* @package Feast\Set
3234
*/
33-
class Set implements Iterator, Collection, \ArrayAccess, \Countable
35+
class Set implements Iterator, Collection, ArrayAccess, Countable
3436
{
3537
use \Feast\Traits\Collection;
3638

@@ -55,7 +57,7 @@ public function __construct(
5557
}
5658
$this->addAll($values);
5759
}
58-
60+
5961
/**
6062
* Add a value to the set
6163
*
@@ -85,10 +87,10 @@ public function addAll(array $values): void
8587
$this->add($value);
8688
}
8789
}
88-
90+
8991
/**
9092
* Set element by offset (disabled)
91-
*
93+
*
9294
* @param string|int $offset
9395
* @param mixed $value
9496
* @throws ServerFailureException
@@ -111,9 +113,9 @@ public function offsetUnset($offset): void
111113

112114
/**
113115
* Merge two sets together
114-
*
116+
*
115117
* For a merge to be allowed, the type for the two sets MUST be the same.
116-
*
118+
*
117119
* @param Set $dataToMerge
118120
* @return static
119121
* @throws InvalidArgumentException
@@ -133,12 +135,12 @@ public function merge(Set $dataToMerge): static
133135

134136
/**
135137
* Get minimum value from set.
136-
*
138+
*
137139
* If key is passed and the collection type is not a scalar, then the value used is for the specified
138140
* key on the objects. If key is not passed, this will operate on float/int sets only. If key is passed
139-
* and the collection is not an object type, or no key is passed and it is an object type, an
141+
* and the collection is not an object type, or no key is passed and it is an object type, an
140142
* InvalidOptionException is thrown.
141-
*
143+
*
142144
* @param string|null $key
143145
* @return int|float|null
144146
* @throws InvalidOptionException
@@ -265,10 +267,8 @@ public function product(?string $key = null): float
265267
*/
266268
public function offsetGet($offset): string|int|bool|float|object|array|null
267269
{
268-
/** @var string|int|bool|float|object|array|null $var */
269-
$var = $this->array[$offset] ?? null;
270-
271-
return $var;
270+
/** @var string|int|bool|float|object|array|null */
271+
return $this->array[$offset] ?? null;
272272
}
273273

274274
/**

0 commit comments

Comments
 (0)