Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove constructs that deprecate with PHP 8.4 #75

Merged
merged 2 commits into from
Jul 24, 2024
Merged
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 lib/Cake/Console/Command/Task/FixtureTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function bake($model, $useTable = false, $importOptions = array()) {
$this->_Schema = new CakeSchema();
$data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection));
if (!isset($data['tables'][$useTable])) {
$this->err("<warning>Warning:</warning> Could not find the '${useTable}' table for ${model}.");
$this->err("<warning>Warning:</warning> Could not find the '{$useTable}' table for {$model}.");
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function inOptions($options, $prompt = null, $default = null) {
while (!$valid) {
$len = strlen(count($options) + 1);
foreach ($options as $i => $option) {
$this->out(sprintf("%${len}d. %s", $i + 1, $option));
$this->out(sprintf("%{$len}d. %s", $i + 1, $option));
}
if (empty($prompt)) {
$prompt = __d('cake_console', 'Make a selection from the choices above');
Expand Down Expand Up @@ -901,7 +901,7 @@ public function listAll($useDbConfig = null) {
$this->out(__d('cake_console', 'Possible Models based on your current database:'));
$len = strlen($count + 1);
for ($i = 0; $i < $count; $i++) {
$this->out(sprintf("%${len}d. %s", $i + 1, $this->_modelNames[$i]));
$this->out(sprintf("%{$len}d. %s", $i + 1, $this->_modelNames[$i]));
}
}
return $this->_tables;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Auth/BaseAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ abstract public function authorize($user, CakeRequest $request);
* @return mixed
* @throws CakeException
*/
public function controller(Controller $controller = null) {
public function controller(?Controller $controller = null) {
if ($controller) {
if (!$controller instanceof Controller) {
throw new CakeException(__d('cake_dev', '$controller needs to be an instance of Controller'));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Auth/ControllerAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ControllerAuthorize extends BaseAuthorize {
* @return mixed
* @throws CakeException
*/
public function controller(Controller $controller = null) {
public function controller(?Controller $controller = null) {
if ($controller) {
if (!method_exists($controller, 'isAuthorized')) {
throw new CakeException(__d('cake_dev', '$controller does not implement an %s method.', 'isAuthorized()'));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/AuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ protected function _setDefaults() {
* @param CakeRequest|null $request The request to authenticate for. If empty, the current request will be used.
* @return bool True if $user is authorized, otherwise false
*/
public function isAuthorized($user = null, CakeRequest $request = null) {
public function isAuthorized($user = null, ?CakeRequest $request = null) {
if (empty($user) && !$this->user()) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Component/SecurityComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function requireAuth() {
* @link https://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks
* @throws BadRequestException
*/
public function blackHole(Controller $controller, $error = '', SecurityException $exception = null) {
public function blackHole(Controller $controller, $error = '', ?SecurityException $exception = null) {
if (!$this->blackHoleCallback) {
$this->_throwException($exception);
}
Expand Down Expand Up @@ -822,7 +822,7 @@ protected function _expireTokens($tokens) {
* @param string $method Method to execute
* @param array $params Parameters to send to method
* @return mixed Controller callback method's response
* @throws BadRequestException When a the blackholeCallback is not callable.
* @throws BadRequestException When the blackholeCallback is not callable.
*/
protected function _callback(Controller $controller, $method, $params = array()) {
if (!is_callable(array($controller, $method))) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Error/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class PrivateActionException extends CakeException {
protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';

//@codingStandardsIgnoreStart
public function __construct($message, $code = 404, Exception $previous = null) {
public function __construct($message, $code = 404, ?Exception $previous = null) {
parent::__construct($message, $code, $previous);
}
//@codingStandardsIgnoreEnd
Expand Down
14 changes: 7 additions & 7 deletions lib/Cake/Model/Datasource/DboSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ protected function _execute($sql, $params = array(), $prepareOptions = array())
* @param PDOStatement $query the query to extract the error from if any
* @return string Error message with error number
*/
public function lastError(PDOStatement $query = null) {
public function lastError(?PDOStatement $query = null) {
if ($query) {
$error = $query->errorInfo();
} else {
Expand Down Expand Up @@ -2761,7 +2761,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote =
* @param Model $Model A reference to the Model instance making the query
* @return string SQL fragment
*/
public function conditions($conditions, $quoteValues = true, $where = true, Model $Model = null) {
public function conditions($conditions, $quoteValues = true, $where = true, ?Model $Model = null) {
$clause = $out = '';

if ($where) {
Expand Down Expand Up @@ -2804,7 +2804,7 @@ public function conditions($conditions, $quoteValues = true, $where = true, Mode
* @param Model $Model A reference to the Model instance making the query
* @return string SQL fragment
*/
public function conditionKeysToString($conditions, $quoteValues = true, Model $Model = null) {
public function conditionKeysToString($conditions, $quoteValues = true, ?Model $Model = null) {
$out = array();
$data = $columnType = null;

Expand Down Expand Up @@ -2909,7 +2909,7 @@ public function conditionKeysToString($conditions, $quoteValues = true, Model $M
* @param Model $Model Model object initiating the query
* @return string
*/
protected function _parseKey($key, $value, Model $Model = null) {
protected function _parseKey($key, $value, ?Model $Model = null) {
$operatorMatch = '/^(((' . implode(')|(', $this->_sqlOps);
$operatorMatch .= ')\\x20?)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is';
$bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false));
Expand Down Expand Up @@ -3083,7 +3083,7 @@ public function limit($limit, $offset = null) {
* @param Model $Model Model reference (used to look for virtual field)
* @return string ORDER BY clause
*/
public function order($keys, $direction = 'ASC', Model $Model = null) {
public function order($keys, $direction = 'ASC', ?Model $Model = null) {
if (!is_array($keys)) {
$keys = array($keys);
}
Expand Down Expand Up @@ -3166,7 +3166,7 @@ public function order($keys, $direction = 'ASC', Model $Model = null) {
* @param Model $Model The model to get group by fields for.
* @return string Group By clause or null.
*/
public function group($fields, Model $Model = null) {
public function group($fields, ?Model $Model = null) {
if (empty($fields)) {
return null;
}
Expand Down Expand Up @@ -3196,7 +3196,7 @@ public function group($fields, Model $Model = null) {
* @param Model $Model A reference to the Model instance making the query
* @return string|null HAVING clause or null
*/
public function having($fields, $quoteValues = true, Model $Model = null) {
public function having($fields, $quoteValues = true, ?Model $Model = null) {
if (!$fields) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3913,7 +3913,7 @@ protected function _clearCache($type = null) {
* If null a new ModelValidator instance will be made using current model object
* @return ModelValidator
*/
public function validator(ModelValidator $instance = null) {
public function validator(?ModelValidator $instance = null) {
if ($instance) {
$this->_validator = $instance;
} elseif (!$this->_validator) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/ShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public function testCreateFileNonInteractive() {

$this->Shell->interactive = false;

$contents = "<?php{$eol}echo 'test';${eol}\$te = 'st';{$eol}";
$contents = "<?php{$eol}echo 'test';{$eol}\$te = 'st';{$eol}";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/JsonView.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class JsonView extends View {
*
* @param Controller $controller Controller instance.
*/
public function __construct(Controller $controller = null) {
public function __construct(?Controller $controller = null) {
parent::__construct($controller);
if (isset($controller->response) && $controller->response instanceof CakeResponse) {
$controller->response->type('json');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class View extends CakeObject {
*
* @param Controller $controller A controller object to pull View::_passedVars from.
*/
public function __construct(Controller $controller = null) {
public function __construct(?Controller $controller = null) {
if (is_object($controller)) {
$count = count($this->_passedVars);
for ($j = 0; $j < $count; $j++) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/XmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class XmlView extends View {
*
* @param Controller $controller Controller instance.
*/
public function __construct(Controller $controller = null) {
public function __construct(?Controller $controller = null) {
parent::__construct($controller);

if (isset($controller->response) && $controller->response instanceof CakeResponse) {
Expand Down
Loading