Skip to content

Commit 524eee8

Browse files
committed
Update for docblocks
1 parent 30d7c6a commit 524eee8

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

+464
-240
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
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
@@ -32,11 +32,17 @@ abstract class BaseModel
3232
protected const MAPPER_NAME = null;
3333
protected ?BaseModel $originalModel = null;
3434

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

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

Binary.php

Lines changed: 10 additions & 8 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,10 +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
220-
* @return bool
221+
* @param ReflectionMethod $method
221222
*/
222-
private function processCliMethods(\ReflectionMethod $method): bool
223+
private function processCliMethods(ReflectionMethod $method): void
223224
{
224225
$name = NameHelper::getMethodNameAsCallableAction($method->getName());
225226
$class = NameHelper::getControllerClassName($method->getDeclaringClass());
@@ -238,7 +239,6 @@ private function processCliMethods(\ReflectionMethod $method): bool
238239

239240
$this->terminal->message($actionItem->description);
240241
}
241-
return true;
242242
}
243243

244244
/**
@@ -259,12 +259,14 @@ private function analyzeFeast(array $classes = [
259259
{
260260
/** @var class-string $class */
261261
foreach ($classes as $class) {
262-
$this->processCliClass(new \ReflectionClass($class));
262+
$this->processCliClass(new ReflectionClass($class));
263263
}
264264
}
265265

266266
/**
267267
* Process all custom actions in the CLI module.
268+
*
269+
* @throws ReflectionException
268270
*/
269271
private function analyzeCli(): void
270272
{
@@ -278,7 +280,7 @@ private function analyzeCli(): void
278280
// Load class info
279281
/** @var class-string $className */
280282
$className = '\\Modules\\CLI\\Controllers\\' . substr($classFile, 0, -4);
281-
$class = new \ReflectionClass($className);
283+
$class = new ReflectionClass($className);
282284

283285
// Parse class and methods
284286
$this->processCliClass($class);
@@ -289,9 +291,9 @@ private function analyzeCli(): void
289291
/**
290292
* Parse all descriptions for a class and return if any methods had a description.
291293
*
292-
* @param \ReflectionClass $class
294+
* @param ReflectionClass $class
293295
*/
294-
private function processCliClass(\ReflectionClass $class): void
296+
private function processCliClass(ReflectionClass $class): void
295297
{
296298
$className = NameHelper::getControllerClassName($class);
297299
$this->terminal->command($className);

CliController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@
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
protected CliArguments $cliArguments;
3132

33+
/**
34+
* @throws NotFoundException
35+
*/
3236
public function __construct(
3337
ServiceContainer $di,
3438
?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)