mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-13 17:49:25 +00:00
Bump to PHP 8.0+
PHP 7.4 was end of life November 2022, it's time to bump to PHP 8 standard 🎉
- updated starting code to PHP 8 standard
- upgraded tooling (code quality, static analysis) to the latest versions
- tested with PHP 8.0, 8.1 and 8.2
- the fixture is working
- the example test is failing, as expected
- code quality is as expected
- static analysis is ok
This commit is contained in:
1 parent
f7a3312e6b
commit
081c69b864
11 files changed
+87
-4602
No files matched your search
+8
-10
@@ -7,13 +7,11 @@ namespace GildedRose;
|
||||
final class GildedRose
|
||||
{
|
||||
/**
|
||||
* @var Item[]
|
||||
* @param Item[] $items
|
||||
*/
|
||||
private $items;
|
||||
|
||||
public function __construct(array $items)
|
||||
{
|
||||
$this->items = $items;
|
||||
public function __construct(
|
||||
private array $items
|
||||
) {
|
||||
}
|
||||
|
||||
public function updateQuality(): void
|
||||
@@ -29,12 +27,12 @@ final class GildedRose
|
||||
if ($item->quality < 50) {
|
||||
$item->quality = $item->quality + 1;
|
||||
if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if ($item->sell_in < 11) {
|
||||
if ($item->sellIn < 11) {
|
||||
if ($item->quality < 50) {
|
||||
$item->quality = $item->quality + 1;
|
||||
}
|
||||
}
|
||||
if ($item->sell_in < 6) {
|
||||
if ($item->sellIn < 6) {
|
||||
if ($item->quality < 50) {
|
||||
$item->quality = $item->quality + 1;
|
||||
}
|
||||
@@ -44,10 +42,10 @@ final class GildedRose
|
||||
}
|
||||
|
||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
||||
$item->sell_in = $item->sell_in - 1;
|
||||
$item->sellIn = $item->sellIn - 1;
|
||||
}
|
||||
|
||||
if ($item->sell_in < 0) {
|
||||
if ($item->sellIn < 0) {
|
||||
if ($item->name != 'Aged Brie') {
|
||||
if ($item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if ($item->quality > 0) {
|
||||
|
||||
+7
-22
@@ -4,32 +4,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace GildedRose;
|
||||
|
||||
final class Item
|
||||
final class Item implements \Stringable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $sell_in;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $quality;
|
||||
|
||||
public function __construct(string $name, int $sell_in, int $quality)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->sell_in = $sell_in;
|
||||
$this->quality = $quality;
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public int $sellIn,
|
||||
public int $quality
|
||||
) {
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "{$this->name}, {$this->sell_in}, {$this->quality}";
|
||||
return (string) "{$this->name}, {$this->sellIn}, {$this->quality}";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user