mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #4793 from jeromegamez/constants-vs-methods
Use constants instead of functions
This commit is contained in:
commit
6edfdeb131
@ -389,7 +389,7 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Displayed at <?= esc(date('H:i:sa')) ?> —
|
Displayed at <?= esc(date('H:i:sa')) ?> —
|
||||||
PHP: <?= esc(phpversion()) ?> —
|
PHP: <?= esc(PHP_VERSION) ?> —
|
||||||
CodeIgniter: <?= esc(\CodeIgniter\CodeIgniter::CI_VERSION) ?>
|
CodeIgniter: <?= esc(\CodeIgniter\CodeIgniter::CI_VERSION) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -1202,7 +1202,7 @@ abstract class BaseModel
|
|||||||
|
|
||||||
if (empty($this->allowedFields))
|
if (empty($this->allowedFields))
|
||||||
{
|
{
|
||||||
throw DataException::forInvalidAllowedFields(get_class($this));
|
throw DataException::forInvalidAllowedFields(static::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_keys($data) as $key)
|
foreach (array_keys($data) as $key)
|
||||||
|
@ -448,7 +448,7 @@ class CLI
|
|||||||
*/
|
*/
|
||||||
public static function isWindows(): bool
|
public static function isWindows(): bool
|
||||||
{
|
{
|
||||||
return stripos(PHP_OS, 'WIN') === 0;
|
return PHP_OS_FAMILY === 'Windows';
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@ -707,7 +707,7 @@ abstract class BaseConnection implements ConnectionInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// query is not write-type, so it must be read-type query; return QueryResult
|
// query is not write-type, so it must be read-type query; return QueryResult
|
||||||
$resultClass = str_replace('Connection', 'Result', get_class($this));
|
$resultClass = str_replace('Connection', 'Result', static::class);
|
||||||
return new $resultClass($this->connID, $this->resultID);
|
return new $resultClass($this->connID, $this->resultID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,7 +965,7 @@ abstract class BaseConnection implements ConnectionInterface
|
|||||||
throw new DatabaseException('You must set the database table to be used with your query.');
|
throw new DatabaseException('You must set the database table to be used with your query.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$className = str_replace('Connection', 'Builder', get_class($this));
|
$className = str_replace('Connection', 'Builder', static::class);
|
||||||
|
|
||||||
return new $className($tableName, $this);
|
return new $className($tableName, $this);
|
||||||
}
|
}
|
||||||
@ -1009,7 +1009,7 @@ abstract class BaseConnection implements ConnectionInterface
|
|||||||
$sql = $sql->getOriginalQuery();
|
$sql = $sql->getOriginalQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = str_ireplace('Connection', 'PreparedQuery', get_class($this));
|
$class = str_ireplace('Connection', 'PreparedQuery', static::class);
|
||||||
/**
|
/**
|
||||||
* @var BasePreparedQuery $class
|
* @var BasePreparedQuery $class
|
||||||
*/
|
*/
|
||||||
|
@ -143,7 +143,7 @@ abstract class BasePreparedQuery implements PreparedQueryInterface
|
|||||||
Events::trigger('DBQuery', $query);
|
Events::trigger('DBQuery', $query);
|
||||||
|
|
||||||
// Return a result object
|
// Return a result object
|
||||||
$resultClass = str_replace('PreparedQuery', 'Result', get_class($this));
|
$resultClass = str_replace('PreparedQuery', 'Result', static::class);
|
||||||
|
|
||||||
$resultID = $this->_getResult();
|
$resultID = $this->_getResult();
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ class Config
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'ciVersion' => CodeIgniter::CI_VERSION,
|
'ciVersion' => CodeIgniter::CI_VERSION,
|
||||||
'phpVersion' => phpversion(),
|
'phpVersion' => PHP_VERSION,
|
||||||
'phpSAPI' => php_sapi_name(),
|
'phpSAPI' => PHP_SAPI,
|
||||||
'environment' => ENVIRONMENT,
|
'environment' => ENVIRONMENT,
|
||||||
'baseURL' => $config->baseURL,
|
'baseURL' => $config->baseURL,
|
||||||
'timezone' => app_timezone(),
|
'timezone' => app_timezone(),
|
||||||
|
@ -410,7 +410,7 @@ class Email
|
|||||||
$config = get_object_vars($config);
|
$config = get_object_vars($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_keys(get_class_vars(get_class($this))) as $key)
|
foreach (array_keys(get_class_vars(static::class)) as $key)
|
||||||
{
|
{
|
||||||
if (property_exists($this, $key) && isset($config[$key]))
|
if (property_exists($this, $key) && isset($config[$key]))
|
||||||
{
|
{
|
||||||
|
@ -485,7 +485,7 @@ trait ResponseTrait
|
|||||||
|
|
||||||
// Per spec, MUST be sent with each request, if possible.
|
// Per spec, MUST be sent with each request, if possible.
|
||||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
|
||||||
if (! isset($this->headers['Date']) && php_sapi_name() !== 'cli-server')
|
if (! isset($this->headers['Date']) && PHP_SAPI !== 'cli-server')
|
||||||
{
|
{
|
||||||
$this->setDate(DateTime::createFromFormat('U', (string) time()));
|
$this->setDate(DateTime::createFromFormat('U', (string) time()));
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class ImageMagickHandler extends BaseHandler
|
|||||||
$destination = $this->getResourcePath();
|
$destination = $this->getResourcePath();
|
||||||
|
|
||||||
$escape = '\\';
|
$escape = '\\';
|
||||||
if (stripos(PHP_OS, 'WIN') === 0)
|
if (PHP_OS_FAMILY === 'Windows')
|
||||||
{
|
{
|
||||||
$escape = '';
|
$escape = '';
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class MockConnection extends BaseConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// query is not write-type, so it must be read-type query; return QueryResult
|
// query is not write-type, so it must be read-type query; return QueryResult
|
||||||
$resultClass = str_replace('Connection', 'Result', get_class($this));
|
$resultClass = str_replace('Connection', 'Result', static::class);
|
||||||
return new $resultClass($this->connID, $this->resultID);
|
return new $resultClass($this->connID, $this->resultID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ final class CodeIgniter4 extends AbstractRuleset
|
|||||||
],
|
],
|
||||||
'blank_line_after_namespace' => true,
|
'blank_line_after_namespace' => true,
|
||||||
'blank_line_after_opening_tag' => true,
|
'blank_line_after_opening_tag' => true,
|
||||||
|
'function_to_constant' => true,
|
||||||
'indentation_type' => true,
|
'indentation_type' => true,
|
||||||
'line_ending' => true,
|
'line_ending' => true,
|
||||||
'static_lambda' => true,
|
'static_lambda' => true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user