-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'github.com/main' into feature/scalar-to…
…-constfetch
- Loading branch information
Showing
34 changed files
with
513 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ts/Carbon/Rector/New_/DateTimeInstanceToCarbonRector/Fixture/datetime_now_add_sub.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeNowAddSub | ||
{ | ||
public function run() | ||
{ | ||
$addSeconds = new \DateTime('+5 seconds'); | ||
$addMinutes = new \DateTime('+5 minutes'); | ||
$addHours = new \DateTime('+5 hours'); | ||
$addDays = new \DateTime('+5 days'); | ||
$addWeeks = new \DateTime('+5 weeks'); | ||
$addMonths = new \DateTime('+5 months'); | ||
$addYears = new \DateTime('+5 years'); | ||
|
||
$subSeconds = new \DateTime('-5 seconds'); | ||
$subMinuts = new \DateTime('-5 minutes'); | ||
$subHours = new \DateTime('-5 hours'); | ||
$subDays = new \DateTime('-5 days'); | ||
$subWeeks = new \DateTime('-5 weeks'); | ||
$subMonths = new \DateTime('-5 months'); | ||
$subYears = new \DateTime('-5 years'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeNowAddSub | ||
{ | ||
public function run() | ||
{ | ||
$addSeconds = \Carbon\Carbon::now()->addSeconds(5); | ||
$addMinutes = \Carbon\Carbon::now()->addMinutes(5); | ||
$addHours = \Carbon\Carbon::now()->addHours(5); | ||
$addDays = \Carbon\Carbon::now()->addDays(5); | ||
$addWeeks = \Carbon\Carbon::now()->addWeeks(5); | ||
$addMonths = \Carbon\Carbon::now()->addMonths(5); | ||
$addYears = \Carbon\Carbon::now()->addYears(5); | ||
|
||
$subSeconds = \Carbon\Carbon::now()->subSeconds(5); | ||
$subMinuts = \Carbon\Carbon::now()->subMinutes(5); | ||
$subHours = \Carbon\Carbon::now()->subHours(5); | ||
$subDays = \Carbon\Carbon::now()->subDays(5); | ||
$subWeeks = \Carbon\Carbon::now()->subWeeks(5); | ||
$subMonths = \Carbon\Carbon::now()->subMonths(5); | ||
$subYears = \Carbon\Carbon::now()->subYears(5); | ||
} | ||
} | ||
|
||
?> |
31 changes: 31 additions & 0 deletions
31
rules-tests/Carbon/Rector/New_/DateTimeInstanceToCarbonRector/Fixture/datetime_parse.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeParse | ||
{ | ||
public function run() | ||
{ | ||
$date = new \DateTime('next week'); | ||
$exactDate = new \DateTime('2024-07-25'); | ||
$textualDate = new \DateTime('2 days ago'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeParse | ||
{ | ||
public function run() | ||
{ | ||
$date = \Carbon\Carbon::parse('next week'); | ||
$exactDate = \Carbon\Carbon::parse('2024-07-25'); | ||
$textualDate = \Carbon\Carbon::parse('2 days ago'); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...Carbon/Rector/New_/DateTimeInstanceToCarbonRector/Fixture/datetime_with_date_time.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeWithDateTime | ||
{ | ||
public function run() | ||
{ | ||
$date = new \DateTime('2024-07-30'); | ||
$time = new \DateTime('11:12:13'); | ||
$datetime = new \DateTime('2024-07-30 11:12:13'); | ||
|
||
$tomorrowTime = new \DateTime('tomorrow 12:00'); | ||
$yesterdayTime = new \DateTime('yesterday 12:00'); | ||
|
||
$dateNoon = new \DateTime('2024-07-30 noon'); | ||
$restStringToParse = new \DateTime('tomorrow noon'); | ||
|
||
$fullDate = new \DateTime('2024-07-30T11:12:13.000Z'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeWithDateTime | ||
{ | ||
public function run() | ||
{ | ||
$date = \Carbon\Carbon::parse('2024-07-30'); | ||
$time = \Carbon\Carbon::parse('11:12:13'); | ||
$datetime = \Carbon\Carbon::parse('2024-07-30 11:12:13'); | ||
|
||
$tomorrowTime = \Carbon\Carbon::parse('12:00 tomorrow'); | ||
$yesterdayTime = \Carbon\Carbon::parse('12:00 yesterday'); | ||
|
||
$dateNoon = \Carbon\Carbon::parse('2024-07-30 noon'); | ||
$restStringToParse = \Carbon\Carbon::parse('noon tomorrow'); | ||
|
||
$fullDate = \Carbon\Carbon::parse('2024-07-30T11:12:13.000Z'); | ||
} | ||
} | ||
|
||
?> |
39 changes: 0 additions & 39 deletions
39
...n/Rector/New_/DateTimeInstanceToCarbonRector/Fixture/datetime_with_today_sub_time.php.inc
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...ests/Carbon/Rector/New_/DateTimeInstanceToCarbonRector/Fixture/datetime_yesterday.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeYesterday | ||
{ | ||
public function run() | ||
{ | ||
$date = new \DateTime('yesterday'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Carbon\Rector\New_\DateTimeInstanceToCarbonRector\Fixture; | ||
|
||
final class DateTimeYesterday | ||
{ | ||
public function run() | ||
{ | ||
$date = \Carbon\Carbon::yesterday(); | ||
} | ||
} | ||
|
||
?> |
23 changes: 23 additions & 0 deletions
23
rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_assign_op.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\Fixture; | ||
|
||
final class SkipAssignOp | ||
{ | ||
private string $name; | ||
private int $count; | ||
|
||
public function __construct(string $name, bool $flag = false) | ||
{ | ||
$this->name = $name; | ||
|
||
if ($flag) { | ||
$this->name .= 'changed'; | ||
} | ||
|
||
$this->count = 0; | ||
if ($flag) { | ||
++$this->count; | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...sMethod/ReturnTypeFromReturnNewRector/Fixture/include_response_outside_controller.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
||
final class IncludeResponseOutsideController | ||
{ | ||
public function create() | ||
{ | ||
return new JsonResponse(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
||
final class IncludeResponseOutsideController | ||
{ | ||
public function create(): \Symfony\Component\HttpFoundation\JsonResponse | ||
{ | ||
return new JsonResponse(); | ||
} | ||
} | ||
|
||
?> |
20 changes: 20 additions & 0 deletions
20
...eclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector/Fixture/skip_response.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ResponseReturnTypeControllerActionRector; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
||
/** | ||
* Handled in another rule, @see ResponseReturnTypeControllerActionRector | ||
*/ | ||
class SkipResponse extends Controller | ||
{ | ||
public function create() | ||
{ | ||
return new JsonResponse(); | ||
} | ||
} |
Oops, something went wrong.