Skip to content
Closed
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
2 changes: 1 addition & 1 deletion app/Config/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Email
*
* @var integer
*/
public $wrapChars = 76;
public $wrapCharacters = 76;

/**
* Type of mail, either 'text' or 'html'
Expand Down
6 changes: 3 additions & 3 deletions app/Config/Mimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,15 @@ public static function guessExtensionFromType(string $type, ?string $proposed_ex
return $proposed_extension;
}

foreach (static::$mimes as $ext => $types)
foreach (static::$mimes as $extension => $types)
{
if (is_string($types) && $types === $type)
{
return $ext;
return $extension;
}
else if (is_array($types) && in_array($type, $types))
{
return $ext;
return $extension;
}
}

Expand Down
4 changes: 4 additions & 0 deletions app/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

use CodeIgniter\Controller;

/**
* Class BaseController
* @package App\Controllers
*/
class BaseController extends Controller
{

Expand Down
8 changes: 8 additions & 0 deletions app/Controllers/Home.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php namespace App\Controllers;

/**
* Class Home
* @package App\Controllers
*/
class Home extends BaseController
{

/**
* @return string
*/
public function index()
{
return view('welcome_message');
Expand Down
19 changes: 10 additions & 9 deletions system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,23 @@ protected function _escapeString(string $str): string
* additional "ESCAPE x" parameter for specifying the escape character
* in "LIKE" strings, and this handles those directly with a backslash.
*
* @param string|string[] $str Input string
* @param string|string[] $string Input string
*
* @return string|string[]
*/
public function escapeLikeStringDirect($str)
public function escapeLikeStringDirect($string)
{
if (is_array($str))
if (is_array($string))
{
foreach ($str as $key => $val)
foreach ($string as $key => $value)
{
$str[$key] = $this->escapeLikeStringDirect($val);
$string[$key] = $this->escapeLikeStringDirect($value);
}

return $str;
return $string;
}

$str = $this->_escapeString($str);
$string = $this->_escapeString($string);

// Escape LIKE condition wildcards
return str_replace([
Expand All @@ -422,10 +423,10 @@ public function escapeLikeStringDirect($str)
'\\' . $this->likeEscapeChar,
'\\' . '%',
'\\' . '_',
], $str
], $string
);

return $str;
return $string;
}

//--------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Email
* @see Email::$wordWrap
* @var integer
*/
public $wrapChars = 76;
public $wrapCharacters = 76;
/**
* Message format.
*
Expand Down Expand Up @@ -1002,7 +1002,7 @@ public function wordWrap($str, $charlim = null)
// Set the character limit, if not already present
if (empty($charlim))
{
$charlim = empty($this->wrapChars) ? 76 : $this->wrapChars;
$charlim = empty($this->wrapCharacters) ? 76 : $this->wrapCharacters;
}
// Standardize newlines
if (strpos($str, "\r") !== false)
Expand Down
2 changes: 1 addition & 1 deletion system/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private function castAsJson($value, bool $asArray = false)
$tmp = ! is_null($value) ? ($asArray ? [] : new \stdClass) : null;
if (function_exists('json_decode'))
{
if ((is_string($value) && strlen($value) > 1 && in_array($value{0}, ['[', '{', '"'])) || is_numeric($value))
if ((is_string($value) && strlen($value) > 1 && in_array($value[0], ['[', '{', '"'])) || is_numeric($value))
{
$tmp = json_decode($value, $asArray);

Expand Down
3 changes: 3 additions & 0 deletions system/Exceptions/CastException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class CastException extends CriticalError
*/
protected $code = 3;

/**
* @param int $error
*/
public static function forInvalidJsonFormatException(int $error)
{
switch($error)
Expand Down
20 changes: 20 additions & 0 deletions system/Exceptions/DownloadException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,46 @@
class DownloadException extends \RuntimeException implements ExceptionInterface
{

/**
* @param string $path
*
* @return static
*/
public static function forCannotSetFilePath(string $path)
{
return new static(lang('HTTP.cannotSetFilepath', [$path]));
}

/**
* @return static
*/
public static function forCannotSetBinary()
{
return new static(lang('HTTP.cannotSetBinary'));
}

/**
* @return static
*/
public static function forNotFoundDownloadSource()
{
return new static(lang('HTTP.notFoundDownloadSource'));
}

/**
* @return static
*/
public static function forCannotSetCache()
{
return new static(lang('HTTP.cannotSetCache'));
}

/**
* @param int $code
* @param string $reason
*
* @return static
*/
public static function forCannotSetStatusCode(int $code, string $reason)
{
return new static(lang('HTTP.cannotSetStatusCode', [$code, $reason]));
Expand Down
20 changes: 20 additions & 0 deletions system/Exceptions/FrameworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,41 @@
class FrameworkException extends \RuntimeException implements ExceptionInterface
{

/**
* @param string $path
*
* @return static
*/
public static function forInvalidFile(string $path)
{
return new static(lang('Core.invalidFile', [$path]));
}

/**
* @param string $path
*
* @return static
*/
public static function forCopyError(string $path)
{
return new static(lang('Core.copyError', [$path]));
}

/**
* @param string $extension
*
* @return static
*/
public static function forMissingExtension(string $extension)
{
return new static(lang('Core.missingExtension', [$extension]));
}

/**
* @param string $class
*
* @return static
*/
public static function forNoHandlers(string $class)
{
return new static(lang('Core.noHandlers', [$class]));
Expand Down
11 changes: 11 additions & 0 deletions system/Exceptions/ModelException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

class ModelException extends FrameworkException
{

/**
* @param string $modelName
*
* @return static
*/
public static function forNoPrimaryKey(string $modelName)
{
return new static(lang('Database.noPrimaryKey', [$modelName]));
}

/**
* @param string $modelName
*
* @return static
*/
public static function forNoDateFormat(string $modelName)
{
return new static(lang('Database.noDateFormat', [$modelName]));
Expand Down
23 changes: 23 additions & 0 deletions system/Exceptions/PageNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php namespace CodeIgniter\Exceptions;

/**
* Class PageNotFoundException
* @package CodeIgniter\Exceptions
*/
class PageNotFoundException extends \OutOfBoundsException implements ExceptionInterface
{
/**
Expand All @@ -9,21 +13,40 @@ class PageNotFoundException extends \OutOfBoundsException implements ExceptionIn
*/
protected $code = 404;

/**
* @param string|NULL $message
*
* @return static
*/
public static function forPageNotFound(string $message = null)
{
return new static($message ?? lang('HTTP.pageNotFound'));
}

/**
* @return static
*/
public static function forEmptyController()
{
return new static(lang('HTTP.emptyController'));
}

/**
* @param string $controller
* @param string $method
*
* @return static
*/
public static function forControllerNotFound(string $controller, string $method)
{
return new static(lang('HTTP.controllerNotFound', [$controller, $method]));
}

/**
* @param string $method
*
* @return static
*/
public static function forMethodNotFound(string $method)
{
return new static(lang('HTTP.methodNotFound', [$method]));
Expand Down
11 changes: 11 additions & 0 deletions system/Files/Exceptions/FileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

use CodeIgniter\Exceptions\ExceptionInterface;

/**
* Class FileException
* @package CodeIgniter\Files\Exceptions
*/
class FileException extends \RuntimeException implements ExceptionInterface
{

/**
* @param string|NULL $from
* @param string|NULL $to
* @param string|NULL $error
*
* @return static
*/
public static function forUnableToMove(string $from = null, string $to = null, string $error = null)
{
return new static(lang('Files.cannotMove', [$from, $to, $error]));
Expand Down
10 changes: 10 additions & 0 deletions system/Files/Exceptions/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

use CodeIgniter\Exceptions\ExceptionInterface;

/**
* Class FileNotFoundException
* @package CodeIgniter\Files\Exceptions
*/
class FileNotFoundException extends \RuntimeException implements ExceptionInterface
{

/**
* @param string $path
*
* @return static
*/
public static function forFileNotFound(string $path)
{
return new static(lang('Files.fileNotFound', [$path]));
Expand Down
Loading