first commit

This commit is contained in:
CHIEFSOFT\ameye
2025-11-22 09:54:51 -05:00
commit 07a07ab49f
722 changed files with 125787 additions and 0 deletions
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 thrown if a function is called in the wrong way, or the function
* does not exist.
*/
class BadFunctionCallException extends \BadFunctionCallException implements ExceptionInterface
{
}
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 thrown if a method is called in the wrong way, or the method
* does not exist.
*/
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
+36
View File
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 thrown if the value of the Config class is invalid or the type is
* incorrect.
*/
class ConfigException extends RuntimeException implements HasExitCodeInterface
{
use DebugTraceableTrait;
public function getExitCode(): int
{
return EXIT_CONFIG;
}
/**
* @return static
*/
public static function forDisabledMigrations()
{
return new static(lang('Migrations.disabled'));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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;
/**
* Error: Critical conditions, like component unavailable, etc.
*/
class CriticalError extends RuntimeException
{
}
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 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.
*/
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;
}
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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;
/**
* Class DownloadException
*/
class DownloadException extends RuntimeException
{
use DebugTraceableTrait;
/**
* @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'));
}
/**
* @deprecated Since v4.5.6
*
* @return static
*/
public static function forCannotSetCache()
{
return new static(lang('HTTP.cannotSetCache'));
}
/**
* @return static
*/
public static function forCannotSetStatusCode(int $code, string $reason)
{
return new static(lang('HTTP.cannotSetStatusCode', [$code, $reason]));
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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
{
}
+94
View File
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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;
/**
* Class FrameworkException
*
* A collection of exceptions thrown by the framework
* that can only be determined at run time.
*/
class FrameworkException extends RuntimeException
{
use DebugTraceableTrait;
/**
* @return static
*/
public static function forEnabledZlibOutputCompression()
{
return new static(lang('Core.enabledZlibOutputCompression'));
}
/**
* @return static
*/
public static function forInvalidFile(string $path)
{
return new static(lang('Core.invalidFile', [$path]));
}
/**
* @return static
*/
public static function forInvalidDirectory(string $path)
{
return new static(lang('Core.invalidDirectory', [$path]));
}
/**
* @return static
*/
public static function forCopyError(string $path)
{
return new static(lang('Core.copyError', [$path]));
}
/**
* @return static
*
* @deprecated 4.5.0 No longer used.
*/
public static function forMissingExtension(string $extension)
{
if (str_contains($extension, 'intl')) {
// @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);
}
/**
* @return static
*/
public static function forNoHandlers(string $class)
{
return new static(lang('Core.noHandlers', [$class]));
}
/**
* @return static
*/
public static function forFabricatorCreateFailed(string $table, string $reason)
{
return new static(lang('Fabricator.createFailed', [$table, $reason]));
}
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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;
/**
* Interface for Exceptions that has exception code as HTTP status code.
*/
interface HTTPExceptionInterface extends ExceptionInterface
{
}
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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;
/**
* Interface for Exceptions that has exception code as exit code.
*/
interface HasExitCodeInterface extends ExceptionInterface
{
/**
* Returns exit status code.
*/
public function getExitCode(): int;
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 thrown if an argument is not of the expected type.
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 that represents error in the program logic.
*/
class LogicException extends \LogicException implements ExceptionInterface
{
}
+44
View File
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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
{
/**
* @return static
*/
public static function forNoPrimaryKey(string $modelName)
{
return new static(lang('Database.noPrimaryKey', [$modelName]));
}
/**
* @return static
*/
public static function forNoDateFormat(string $modelName)
{
return new static(lang('Database.noDateFormat', [$modelName]));
}
/**
* @return static
*/
public static function forMethodNotAvailable(string $modelName, string $methodName)
{
return new static(lang('Database.methodNotAvailable', [$modelName, $methodName]));
}
}
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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;
class PageNotFoundException extends RuntimeException implements HTTPExceptionInterface
{
use DebugTraceableTrait;
/**
* HTTP status code
*
* @var int
*/
protected $code = 404;
/**
* @return static
*/
public static function forPageNotFound(?string $message = null)
{
return new static($message ?? self::lang('HTTP.pageNotFound'));
}
/**
* @return static
*/
public static function forEmptyController()
{
return new static(self::lang('HTTP.emptyController'));
}
/**
* @return static
*/
public static function forControllerNotFound(string $controller, string $method)
{
return new static(self::lang('HTTP.controllerNotFound', [$controller, $method]));
}
/**
* @return static
*/
public static function forMethodNotFound(string $method)
{
return new static(self::lang('HTTP.methodNotFound', [$method]));
}
/**
* @return static
*/
public static function forLocaleNotSupported(string $locale)
{
return new static(self::lang('HTTP.localeNotSupported', [$locale]));
}
/**
* Get translated system message
*
* Use a non-shared Language instance in the Services.
* If a shared instance is created, the Language will
* have the current locale, so even if users call
* `$this->request->setLocale()` in the controller afterwards,
* the Language locale will not be changed.
*/
private static function lang(string $line, array $args = []): string
{
$lang = service('language', null, false);
return $lang->getLine($line, $args);
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 thrown if an error which can only be found on runtime occurs.
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
/**
* This file is part of 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 thrown when there is an error with the test code.
*/
class TestException extends LogicException
{
use DebugTraceableTrait;
/**
* @return static
*/
public static function forInvalidMockClass(string $name)
{
return new static(lang('Test.invalidMockClass', [$name]));
}
}