Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ public static function getWidth(int $default = 80): int
static::generateDimensions();
}

return static::$width ?: $default;
return static::$width ? static::$width : $default;
}

/**
Expand All @@ -749,7 +749,7 @@ public static function getHeight(int $default = 32): int
static::generateDimensions();
}

return static::$height ?: $default;
return static::$height ? static::$height : $default;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions system/Database/BasePreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ abstract public function _prepare(string $sql, array $options = []);
* Takes a new set of data and runs it against the currently
* prepared query. Upon success, will return a Results object.
*
* @param mixed ...$data
*
* @return bool|ResultInterface<TConnection, TResult>
*
* @throws DatabaseException
Expand Down
6 changes: 6 additions & 0 deletions system/Database/OCI8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Connection extends BaseConnection
'rownum',
];

/**
* @var list<string>
*/
protected $validDSNs = [
// TNS
'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/',
Expand Down Expand Up @@ -80,6 +83,9 @@ class Connection extends BaseConnection
* Used by storedProcedure() to prevent execute() from
* re-setting the statement ID.
*/
/**
* @var bool
*/
protected $resetStmtId = true;

/**
Expand Down
15 changes: 15 additions & 0 deletions system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,24 @@ class Connection extends BaseConnection
*/
public $escapeChar = '"';

/**
* @var int
*/
protected $connect_timeout;

/**
* @var string
*/
protected $options;

/**
* @var string
*/
protected $sslmode;

/**
* @var string
*/
protected $service;

/**
Expand Down
3 changes: 3 additions & 0 deletions system/Database/PreparedQueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ interface PreparedQueryInterface
*
* @return bool|ResultInterface<TConnection, TResult>
*/
/**
* @param mixed ...$data
*/
public function execute(...$data);

/**
Expand Down
4 changes: 1 addition & 3 deletions system/HTTP/Files/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ class UploadedFile extends File implements UploadedFileInterface
/**
* The error constant of the upload
* (one of PHP's UPLOADERRXXX constants)
*
* @var int
*/
protected $error;
protected ?int $error = null;

/**
* Whether the file has been moved already or not.
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Message implements MessageInterface
/**
* Protocol version
*
* @var string
* @var string|null
*/
protected $protocolVersion;

Expand Down
4 changes: 1 addition & 3 deletions system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ class URI implements Stringable

/**
* The name of any fragment.
*
* @var string
*/
protected $fragment = '';
protected ?string $fragment = null;

/**
* The query string.
Expand Down
2 changes: 1 addition & 1 deletion system/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function getCurrentPage(string $group = 'default'): int
{
$this->ensureGroup($group);

return $this->groups[$group]['currentPage'] ?: 1;
return $this->groups[$group]['currentPage'] ? $this->groups[$group]['currentPage'] : 1;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion system/Router/AutoRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function getRoute(string $uri, string $httpVerb): array
// If it doesn't, no biggie - the default method name
// has already been set.
if ($segments !== []) {
$this->method = array_shift($segments) ?: $this->method;
$method = array_shift($segments);
$this->method = $method ?: $this->method;
}

// Prevent access to initController method
Expand Down
4 changes: 2 additions & 2 deletions system/Test/FilterTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ trait FilterTestTrait
/**
* The active IncomingRequest or CLIRequest
*
* @var RequestInterface
* @var RequestInterface|null
*/
protected $request;

/**
* The active Response instance
*
* @var ResponseInterface
* @var ResponseInterface|null
*/
protected $response;

Expand Down
4 changes: 1 addition & 3 deletions system/Throttle/Throttler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ class Throttler implements ThrottlerInterface

/**
* Timestamp to use (during testing)
*
* @var int
*/
protected $testTime;
protected ?int $testTime = null;

/**
* Constructor.
Expand Down
3 changes: 2 additions & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,8 @@ protected function splitRules(string $rules): array
) {
// the pipe is inside the brackets causing the closing bracket to
// not be included. so, we adjust the rule to include that portion.
$pos = strpos($string, '|', $cursor + strlen($rule) + 1) ?: $length;
$pos = strpos($string, '|', $cursor + strlen($rule) + 1);
$pos = ($pos === false) ? $length : $pos;
$rule = substr($string, $cursor, $pos - $cursor);
}

Expand Down
8 changes: 6 additions & 2 deletions system/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
ob_start();
include $this->renderVars['file'];

return ob_get_clean() ?: '';
$result = ob_get_clean();

return $result ? $result : '';
})();

// Get back current vars
Expand Down Expand Up @@ -331,7 +333,9 @@ public function renderString(string $view, ?array $options = null, ?bool $saveDa
ob_start();
eval('?>' . $view);

return ob_get_clean() ?: '';
$result = ob_get_clean();

return $result ? $result : '';
})($view);

$this->logPerformance($start, microtime(true), $this->excerpt($view));
Expand Down
4 changes: 3 additions & 1 deletion tests/system/Commands/Generators/CellGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ protected function getFileContents(string $filepath): string
return '';
}

return file_get_contents($filepath) ?: '';
$contents = file_get_contents($filepath);

return $contents ? $contents : '';
}

public function testGenerateCell(): void
Expand Down
4 changes: 3 additions & 1 deletion tests/system/Commands/Generators/CommandGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ protected function getFileContents(string $filepath): string
return '';
}

return file_get_contents($filepath) ?: '';
$contents = file_get_contents($filepath);

return $contents ? $contents : '';
}

public function testGenerateCommand(): void
Expand Down
4 changes: 3 additions & 1 deletion tests/system/Commands/Generators/ControllerGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ protected function getFileContents(string $filepath): string
return '';
}

return file_get_contents($filepath) ?: '';
$contents = file_get_contents($filepath);

return $contents ? $contents : '';
}

public function testGenerateController(): void
Expand Down
4 changes: 3 additions & 1 deletion tests/system/Commands/Generators/ModelGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ private function getFileContent(string $filepath): string
return '';
}

return file_get_contents($filepath) ?: '';
$contents = file_get_contents($filepath);

return $contents ? $contents : '';
}

public function testGenerateModel(): void
Expand Down
4 changes: 3 additions & 1 deletion tests/system/Commands/Generators/ScaffoldGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ protected function getFileContents(string $filepath): string
return '';
}

return file_get_contents($filepath) ?: '';
$contents = file_get_contents($filepath);

return $contents ? $contents : '';
}

public function testCreateComponentProducesManyFiles(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@

class Dash_controller extends Controller
{
/**
* @param string $p1
*/
public function getSomemethod($p1 = ''): void
{
}

public function getDash_method($p1, $p2 = ''): void
/**
* @param string|null $p1
* @param string|null $p2
*/
public function getDash_method($p1, $p2 = null)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function getIndex(): void
{
}

public function getSomeMethod($first = ''): void
/**
* @param string|null $first
*/
public function getSomeMethod($first = null)
{
}
}
6 changes: 6 additions & 0 deletions tests/system/Config/FactoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ protected function setUp(): void
Factories::reset();
}

/**
* @param scalar ...$params
*/
protected function getFactoriesStaticProperty(...$params): mixed
{
// First parameter is the actual property
Expand Down Expand Up @@ -87,6 +90,9 @@ public function testUsesConfigOptions(): void
{
// Simulate having a $widgets property in App\Config\Factory
$config = new class () extends Factory {
/**
* @var array<string, string>
*/
public $widgets = ['bar' => 'bam'];
};
Factories::injectMock('config', Factory::class, $config);
Expand Down
7 changes: 7 additions & 0 deletions tests/system/Config/fixtures/RegistrarConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@

class RegistrarConfig extends BaseConfig
{
/**
* @var string
*/
public $foo = 'bar';

/**
* @var array
*/
public $bar = [
'baz',
];
Expand Down
10 changes: 10 additions & 0 deletions tests/system/Config/fixtures/SimpleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ class SimpleConfig extends BaseConfig
{
public $QZERO;
public $QZEROSTR;

/**
* @var string
*/
public $QEMPTYSTR;

public $QFALSE;
public $first = 'foo';
public $second = 'bar';

/**
* @var string
*/
public $FOO;

public $onedeep;
public $default = [
'name' => null,
Expand Down
11 changes: 11 additions & 0 deletions tests/system/Database/Live/ConnectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,19 @@ final class ConnectTest extends CIUnitTestCase
{
use DatabaseTestTrait;

/**
* @var array<string, mixed>
*/
private $group1;

/**
* @var array<string, mixed>
*/
private $group2;

/**
* @var array<string, mixed>
*/
private $tests;

protected function setUp(): void
Expand Down
27 changes: 27 additions & 0 deletions tests/system/Database/Live/GetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,39 @@ public function testGetRowWithReturnType(): void
public function testGetRowWithCustomReturnType(): void
{
$testClass = new class () {
/**
* @var int|null
*/
public $id;

/**
* @var string|null
*/
public $name;

/**
* @var string|null
*/
public $email;

/**
* @var string|null
*/
public $country;

/**
* @var string|null
*/
public $created_at;

/**
* @var string|null
*/
public $updated_at;

/**
* @var string|null
*/
public $deleted_at;
};

Expand Down
Loading