Skip to content

Commit

Permalink
Run cakephp/upgrade and rector over code.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Sep 22, 2023
1 parent 1c7e32f commit c4d4f52
Show file tree
Hide file tree
Showing 64 changed files with 130 additions and 135 deletions.
4 changes: 2 additions & 2 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@
Router::extensions(['json', 'xml', 'csv', 'rss', 'pdf']);

Time::setToStringFormat('yyyy-MM-dd HH:mm:ss'); // For any mutable DateTime
FrozenTime::setToStringFormat('yyyy-MM-dd HH:mm:ss'); // For any immutable DateTime
\Cake\I18n\DateTime::setToStringFormat('yyyy-MM-dd HH:mm:ss'); // For any immutable DateTime
Date::setToStringFormat('yyyy-MM-dd'); // For any mutable Date
FrozenDate::setToStringFormat('yyyy-MM-dd'); // For any immutable Date
\Cake\I18n\Date::setToStringFormat('yyyy-MM-dd'); // For any immutable Date

TypeFactory::build('time')
->setLocaleFormat('HH:mm:ss');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AuthSandboxControllerTest extends IntegrationTestCase {
/**
* @var array
*/
protected $fixtures = [
protected array $fixtures = [
'app.Users',
'app.Roles',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AuthSandboxControllerTest extends IntegrationTestCase {
/**
* @var array
*/
protected $fixtures = [
protected array $fixtures = [
'app.Users',
'app.Roles',
];
Expand Down
4 changes: 2 additions & 2 deletions plugins/Sandbox/src/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function _populateDemoData(array $options) {
$state = $this->States
->find()
->where(['code !=' => '', 'lat IS NOT' => null, 'lng IS NOT' => null])
->order($random)
->orderBy($random)
->firstOrFail();

$time = mktime(random_int(8, 22), 0, 0, $options['month'], random_int(1, 28), $options['year']);
Expand All @@ -95,7 +95,7 @@ protected function _populateDemoData(array $options) {
'lng' => $state->lng,
'location' => $state->name,
'description' => 'Some cool event @ ' . $state->code,
'beginning' => new FrozenTime($time),
'beginning' => new \Cake\I18n\DateTime($time),
]);
if (!$this->Events->save($event)) {
throw new InternalErrorException('Cannot save Event - ' . print_r($event->getErrors()));
Expand Down
6 changes: 2 additions & 4 deletions plugins/Sandbox/src/Controller/JqueryExamplesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public function maxlength() {
public function autocomplete() {
if ($this->request->is(['ajax'])) {
$this->loadModel('Sandbox.Animals');
$items = $this->Animals->find('list', [
'conditions' => [
$items = $this->Animals->find('list', conditions: [
'name LIKE' => '%' . (string)$this->request->getQuery('term') . '%',
],
]);
]);

$this->set('items', $items);
$this->set('_serialize', ['items']);
Expand Down
10 changes: 5 additions & 5 deletions plugins/Sandbox/src/Controller/QueueExamplesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ public function scheduleDemo() {
}

/**
* @param string $task
* @param \Cake\I18n\FrozenTime $notBefore
* @return bool
*/
protected function scheduleDelayedDemo(string $task, $notBefore) {
* @param string $task
* @param \Cake\I18n\DateTime $notBefore
* @return bool
*/
protected function scheduleDelayedDemo(string $task, $notBefore) {
// For the demo we bind it to the user session to avoid other people testing it to have side-effects :)
$sid = $this->request->getSession()->id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function table() {
// Make sure we can download all at once if we want to
$this->paginate['maxLimit'] = 999;

$query = $this->CountryRecords->find('search', ['search' => $this->request->getQuery()]);
$query = $this->CountryRecords->find('search', search: $this->request->getQuery());
$countries = $this->paginate($query)->toArray();

$this->set(compact('countries'));
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/src/Controller/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function search() {
$this->loadModel('Sandbox.SandboxPosts');
$this->ensurePostsDemoData();

$query = $this->SandboxPosts->find('search', ['search' => $this->request->getQuery()])->contain(['Tags']);
$query = $this->SandboxPosts->find('search', search: $this->request->getQuery())->contain(['Tags']);

$posts = $this->paginate($query)->toArray();

Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/src/Controller/ToolsExamplesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function bitmaskSearch() {
];
$this->BitmaskedRecords->behaviors()->load('Tools.Bitmasked', $config);

$query = $this->BitmaskedRecords->find('search', ['search' => $this->request->getQuery()]);
$query = $this->BitmaskedRecords->find('search', search: $this->request->getQuery());
$sql = (string)$query;

$bitmaskedRecords = $this->paginate($query)->toArray();
Expand Down
24 changes: 12 additions & 12 deletions plugins/Sandbox/src/Dto/Github/PullRequestDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @property string $title
* @property string $body
* @property \Sandbox\Dto\Github\UserDto $user
* @property \Cake\I18n\FrozenTime $createdAt
* @property \Cake\I18n\DateTime $createdAt
* @property \Sandbox\Dto\Github\LabelDto[] $labels
* @property \Sandbox\Dto\Github\HeadDto|null $head
* @property \Sandbox\Dto\Github\BaseDto|null $base
Expand Down Expand Up @@ -64,9 +64,9 @@ class PullRequestDto extends \CakeDto\Dto\AbstractDto {
protected $user;

/**
* @var \Cake\I18n\FrozenTime
*/
protected $createdAt;
* @var \Cake\I18n\DateTime
*/
protected $createdAt;

/**
* @var \Sandbox\Dto\Github\LabelDto[]
Expand Down Expand Up @@ -402,21 +402,21 @@ public function hasUser(): bool {
}

/**
* @param \Cake\I18n\FrozenTime $createdAt
*
* @return $this
*/
public function setCreatedAt(\Cake\I18n\FrozenTime $createdAt) {
* @param \Cake\I18n\DateTime $createdAt
*
* @return $this
*/
public function setCreatedAt(\Cake\I18n\DateTime $createdAt) {
$this->createdAt = $createdAt;
$this->_touchedFields[self::FIELD_CREATED_AT] = true;

return $this;
}

/**
* @return \Cake\I18n\FrozenTime
*/
public function getCreatedAt(): \Cake\I18n\FrozenTime {
* @return \Cake\I18n\DateTime
*/
public function getCreatedAt(): \Cake\I18n\DateTime {
return $this->createdAt;
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/Sandbox/src/Model/Entity/BitmaskedRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* @property string $name
* @property int|null $flag_optional
* @property int $flag_required
* @property \Cake\I18n\FrozenTime $created
* @property \Cake\I18n\FrozenTime $modified
* @property \Cake\I18n\DateTime $created
* @property \Cake\I18n\DateTime $modified
*/
class BitmaskedRecord extends Entity {

Expand All @@ -26,7 +26,7 @@ class BitmaskedRecord extends Entity {
*
* @var array<string, bool>
*/
protected $_accessible = [
protected array $_accessible = [
'*' => true,
'id' => false,
];
Expand Down
16 changes: 8 additions & 8 deletions plugins/Sandbox/src/Model/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
* @property float|null $lat
* @property float|null $lng
* @property string $description
* @property \Cake\I18n\FrozenTime|null $beginning
* @property \Cake\I18n\FrozenTime|null $end
* @property \Cake\I18n\DateTime|null $beginning
* @property \Cake\I18n\DateTime|null $end
* @method int getIdOrFail()
* @method string getTitleOrFail()
* @method string getLocationOrFail()
* @method float getLatOrFail()
* @method float getLngOrFail()
* @method string getDescriptionOrFail()
* @method \Cake\I18n\FrozenTime getBeginningOrFail()
* @method \Cake\I18n\FrozenTime getEndOrFail()
* @method \Cake\I18n\DateTime getBeginningOrFail()
* @method \Cake\I18n\DateTime getEndOrFail()
* @property-read string|null $coordinates
* @method string getCoordinatesOrFail()
* @method $this setIdOrFail(int $value)
Expand All @@ -31,8 +31,8 @@
* @method $this setLatOrFail(float $value)
* @method $this setLngOrFail(float $value)
* @method $this setDescriptionOrFail(string $value)
* @method $this setBeginningOrFail(\Cake\I18n\FrozenTime $value)
* @method $this setEndOrFail(\Cake\I18n\FrozenTime $value)
* @method $this setBeginningOrFail(\Cake\I18n\DateTime $value)
* @method $this setEndOrFail(\Cake\I18n\DateTime $value)
* @method $this setCoordinatesOrFail(string $value)
*/
class Event extends Entity {
Expand All @@ -46,15 +46,15 @@ class Event extends Entity {
*
* @var array<string, bool>
*/
protected $_accessible = [
protected array $_accessible = [
'*' => true,
'id' => false,
];

/**
* @var array<string>
*/
protected $_virtual = [
protected array $_virtual = [
'coordinates',
];

Expand Down
6 changes: 3 additions & 3 deletions plugins/Sandbox/src/Model/Entity/ExposedUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* @property int $id
* @property string $uuid
* @property string $name
* @property \Cake\I18n\FrozenTime $created
* @property \Cake\I18n\FrozenTime $modified
* @property \Cake\I18n\DateTime $created
* @property \Cake\I18n\DateTime $modified
*/
class ExposedUser extends Entity {

Expand All @@ -25,7 +25,7 @@ class ExposedUser extends Entity {
*
* @var array<string, bool>
*/
protected $_accessible = [
protected array $_accessible = [
'*' => true,
'uuid' => false,
'id' => false,
Expand Down
14 changes: 7 additions & 7 deletions plugins/Sandbox/src/Model/Entity/SandboxCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
* @property int|null $status
* @property int|null $lft
* @property int|null $rght
* @property \Cake\I18n\FrozenTime|null $created
* @property \Cake\I18n\FrozenTime|null $modified
* @property \Cake\I18n\DateTime|null $created
* @property \Cake\I18n\DateTime|null $modified
* @method int getIdOrFail()
* @method int getParentIdOrFail()
* @method string getNameOrFail()
* @method string getDescriptionOrFail()
* @method int getStatusOrFail()
* @method int getLftOrFail()
* @method int getRghtOrFail()
* @method \Cake\I18n\FrozenTime getCreatedOrFail()
* @method \Cake\I18n\FrozenTime getModifiedOrFail()
* @method \Cake\I18n\DateTime getCreatedOrFail()
* @method \Cake\I18n\DateTime getModifiedOrFail()
* @method $this setIdOrFail(int $value)
* @method $this setParentIdOrFail(int $value)
* @method $this setNameOrFail(string $value)
* @method $this setDescriptionOrFail(string $value)
* @method $this setStatusOrFail(int $value)
* @method $this setLftOrFail(int $value)
* @method $this setRghtOrFail(int $value)
* @method $this setCreatedOrFail(\Cake\I18n\FrozenTime $value)
* @method $this setModifiedOrFail(\Cake\I18n\FrozenTime $value)
* @method $this setCreatedOrFail(\Cake\I18n\DateTime $value)
* @method $this setModifiedOrFail(\Cake\I18n\DateTime $value)
*/
class SandboxCategory extends Entity {

Expand All @@ -44,7 +44,7 @@ class SandboxCategory extends Entity {
*
* @var array<string, bool>
*/
protected $_accessible = [
protected array $_accessible = [
'*' => true,
'id' => false,
];
Expand Down
14 changes: 7 additions & 7 deletions plugins/Sandbox/src/Model/Entity/SandboxPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* @property string $content
* @property int $rating_count
* @property int $rating_sum
* @property \Cake\I18n\FrozenTime|null $created
* @property \Cake\I18n\FrozenTime|null $modified
* @property \Cake\I18n\DateTime|null $created
* @property \Cake\I18n\DateTime|null $modified
* @property array<\Tags\Model\Entity\Tagged> $tagged
* @property array<\Tags\Model\Entity\Tag> $tags
* @property string $tag_list !
Expand All @@ -20,17 +20,17 @@
* @method string getContentOrFail()
* @method int getRatingCountOrFail()
* @method int getRatingSumOrFail()
* @method \Cake\I18n\FrozenTime getCreatedOrFail()
* @method \Cake\I18n\FrozenTime getModifiedOrFail()
* @method \Cake\I18n\DateTime getCreatedOrFail()
* @method \Cake\I18n\DateTime getModifiedOrFail()
* @method array<\Tags\Model\Entity\Tagged> getTaggedOrFail()
* @method array<\Tags\Model\Entity\Tag> getTagsOrFail()
* @method $this setIdOrFail(int $value)
* @method $this setTitleOrFail(string $value)
* @method $this setContentOrFail(string $value)
* @method $this setRatingCountOrFail(int $value)
* @method $this setRatingSumOrFail(int $value)
* @method $this setCreatedOrFail(\Cake\I18n\FrozenTime $value)
* @method $this setModifiedOrFail(\Cake\I18n\FrozenTime $value)
* @method $this setCreatedOrFail(\Cake\I18n\DateTime $value)
* @method $this setModifiedOrFail(\Cake\I18n\DateTime $value)
* @method $this setTaggedOrFail(array $value)
* @method $this setTagsOrFail(array $value)
*/
Expand All @@ -45,7 +45,7 @@ class SandboxPost extends Entity {
*
* @var array<string, bool>
*/
protected $_accessible = [
protected array $_accessible = [
'*' => true,
'id' => false,
];
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/src/Model/Table/SandboxPostsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function searchManager() {
if ($args['tag'] === '-1') {
$query->find('untagged');
} else {
$query->find('tagged', ['slug' => $args['tag']]);
$query->find('tagged', slug: $args['tag']);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/src/View/Helper/MediaEmbedBbcodeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MediaEmbedBbcodeHelper extends Helper {
/**
* @var array<mixed>
*/
protected $helpers = [
protected array $helpers = [
'Text',
];

Expand Down
4 changes: 2 additions & 2 deletions plugins/Sandbox/templates/QueueExamples/scheduling.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<?php
echo $this->Form->control('job_task', ['options' => $tasks]);

echo '<p>Current (server) time: ' . (new \Cake\I18n\FrozenTime()) . '</>';
echo '<p>Current (server) time: ' . (new \Cake\I18n\DateTime()) . '</>';

echo $this->Form->control('notbefore', ['type' => 'text', 'default' => (new \Cake\I18n\FrozenTime())->addMinutes(5)]);
echo $this->Form->control('notbefore', ['type' => 'text', 'default' => (new \Cake\I18n\DateTime())->addMinutes(5)]);

?>
</fieldset>
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/tests/Fixture/EventsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EventsFixture extends TestFixture {
*
* @var array
*/
public $records = [
public array $records = [
[
'id' => 1,
'title' => 'Lorem ipsum dolor sit amet',
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/tests/Fixture/SandboxAnimalsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SandboxAnimalsFixture extends TestFixture {
*
* @var array
*/
public $records = [
public array $records = [
[
'id' => 1,
'name' => 'Lorem ipsum dolor sit amet',
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/tests/Fixture/SandboxCategoriesFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SandboxCategoriesFixture extends TestFixture {
*
* @var array
*/
public $records = [
public array $records = [
[
'id' => 1,
'parent_id' => 1,
Expand Down
2 changes: 1 addition & 1 deletion plugins/Sandbox/tests/Fixture/SandboxPostsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SandboxPostsFixture extends TestFixture {
*
* @var array
*/
public $records = [
public array $records = [
[
'title' => 'Lorem ipsum dolor sit amet',
'slug' => 'Lorem ipsum dolor sit amet',
Expand Down

0 comments on commit c4d4f52

Please sign in to comment.