first commit

This commit is contained in:
Olu Amey
2021-09-13 06:53:04 -04:00
commit 32eb3ab418
3602 changed files with 875408 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
use Error;
/**
* Error: Action must be taken immediately (system/db down, etc)
*/
class AlertError extends Error
{
}
+50
View File
@@ -0,0 +1,50 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
/**
* Cast Exceptions.
*
* @deprecated use CodeIgniter\Entity\Exceptions\CastException instead.
*
* @codeCoverageIgnore
*/
class CastException extends CriticalError
{
use DebugTraceableTrait;
/**
* Error code
*
* @var integer
*/
protected $code = 3;
public static function forInvalidJsonFormatException(int $error)
{
switch ($error)
{
case JSON_ERROR_DEPTH:
return new static(lang('Cast.jsonErrorDepth'));
case JSON_ERROR_STATE_MISMATCH:
return new static(lang('Cast.jsonErrorStateMismatch'));
case JSON_ERROR_CTRL_CHAR:
return new static(lang('Cast.jsonErrorCtrlChar'));
case JSON_ERROR_SYNTAX:
return new static(lang('Cast.jsonErrorSyntax'));
case JSON_ERROR_UTF8:
return new static(lang('Cast.jsonErrorUtf8'));
default:
return new static(lang('Cast.jsonErrorUnknown'));
}
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
/**
* Exception for automatic logging.
*/
class ConfigException extends CriticalError
{
use DebugTraceableTrait;
/**
* Error code
*
* @var integer
*/
protected $code = 3;
public static function forDisabledMigrations()
{
return new static(lang('Migrations.disabled'));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
use Error;
/**
* Error: Critical conditions, like component unavailable, etc.
*/
class CriticalError extends Error
{
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace CodeIgniter\Exceptions;
use Throwable;
/**
* This trait provides framework exceptions the ability to pinpoint
* accurately where the exception was raised rather than instantiated.
*
* This is used primarily for factory-instantiated exceptions.
*/
trait DebugTraceableTrait
{
/**
* Tweaks the exception's constructor to assign the file/line to where
* it is actually raised rather than were it is instantiated.
*
* @param string $message
* @param integer $code
* @param Throwable|null $previous
*/
final public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$trace = $this->getTrace()[0];
if (isset($trace['class']) && $trace['class'] === static::class)
{
[
'line' => $this->line,
'file' => $this->file,
] = $trace;
}
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
use RuntimeException;
/**
* Class DownloadException
*/
class DownloadException extends RuntimeException implements ExceptionInterface
{
use DebugTraceableTrait;
public static function forCannotSetFilePath(string $path)
{
return new static(lang('HTTP.cannotSetFilepath', [$path]));
}
public static function forCannotSetBinary()
{
return new static(lang('HTTP.cannotSetBinary'));
}
public static function forNotFoundDownloadSource()
{
return new static(lang('HTTP.notFoundDownloadSource'));
}
public static function forCannotSetCache()
{
return new static(lang('HTTP.cannotSetCache'));
}
public static function forCannotSetStatusCode(int $code, string $reason)
{
return new static(lang('HTTP.cannotSetStatusCode', [$code, $reason]));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
use Error;
/**
* Error: system is unusable
*/
class EmergencyError extends Error
{
}
+23
View File
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
/**
* Provides a domain-level interface for broad capture
* of all framework-related exceptions.
*
* catch (\CodeIgniter\Exceptions\ExceptionInterface) { ... }
*/
interface ExceptionInterface
{
}
+69
View File
@@ -0,0 +1,69 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
use RuntimeException;
/**
* Class FrameworkException
*
* A collection of exceptions thrown by the framework
* that can only be determined at run time.
*/
class FrameworkException extends RuntimeException implements ExceptionInterface
{
use DebugTraceableTrait;
public static function forEnabledZlibOutputCompression()
{
return new static(lang('Core.enabledZlibOutputCompression'));
}
public static function forInvalidFile(string $path)
{
return new static(lang('Core.invalidFile', [$path]));
}
public static function forCopyError(string $path)
{
return new static(lang('Core.copyError', [$path]));
}
public static function forMissingExtension(string $extension)
{
if (strpos($extension, 'intl') !== false)
{
// @codeCoverageIgnoreStart
$message = sprintf(
'The framework needs the following extension(s) installed and loaded: %s.',
$extension
);
// @codeCoverageIgnoreEnd
}
else
{
$message = lang('Core.missingExtension', [$extension]);
}
return new static($message);
}
public static function forNoHandlers(string $class)
{
return new static(lang('Core.noHandlers', [$class]));
}
public static function forFabricatorCreateFailed(string $table, string $reason)
{
return new static(lang('Fabricator.createFailed', [$table, $reason]));
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
/**
* Model Exceptions.
*/
class ModelException extends FrameworkException
{
public static function forNoPrimaryKey(string $modelName)
{
return new static(lang('Database.noPrimaryKey', [$modelName]));
}
public static function forNoDateFormat(string $modelName)
{
return new static(lang('Database.noDateFormat', [$modelName]));
}
}
@@ -0,0 +1,46 @@
<?php
/**
* This file is part of the CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CodeIgniter\Exceptions;
use OutOfBoundsException;
class PageNotFoundException extends OutOfBoundsException implements ExceptionInterface
{
use DebugTraceableTrait;
/**
* Error code
*
* @var integer
*/
protected $code = 404;
public static function forPageNotFound(string $message = null)
{
return new static($message ?? lang('HTTP.pageNotFound'));
}
public static function forEmptyController()
{
return new static(lang('HTTP.emptyController'));
}
public static function forControllerNotFound(string $controller, string $method)
{
return new static(lang('HTTP.controllerNotFound', [$controller, $method]));
}
public static function forMethodNotFound(string $method)
{
return new static(lang('HTTP.methodNotFound', [$method]));
}
}