Skip to content

Commit

Permalink
Merge pull request #183 from frank9999/php83
Browse files Browse the repository at this point in the history
PHP 8.3 improvements
  • Loading branch information
frank9999 authored Jan 2, 2024
2 parents cc12e3b + 9467ed7 commit e7c60a6
Show file tree
Hide file tree
Showing 24 changed files with 218 additions and 239 deletions.
308 changes: 154 additions & 154 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<arg name="colors"/>
<arg name="extensions" value="php"/>

<rule ref="PSR12"/>

<rule ref="PSR12">
<exclude name="Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase" />
</rule>
<file>config/</file>
<file>public/</file>
<file>src/</file>
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/GameResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class GameResource
{
public const GAME_RESOURCE_CASH = 'cash';
public const GAME_RESOURCE_FOOD = 'food';
public const GAME_RESOURCE_WOOD = 'wood';
public const GAME_RESOURCE_STEEL = 'steel';
public const string GAME_RESOURCE_CASH = 'cash';
public const string GAME_RESOURCE_FOOD = 'food';
public const string GAME_RESOURCE_WOOD = 'wood';
public const string GAME_RESOURCE_STEEL = 'steel';

public static function isValid(string $gameResource): bool
{
Expand Down
10 changes: 5 additions & 5 deletions src/Entity/GameUnitType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

class GameUnitType
{
public const GAME_UNIT_TYPE_BUILDINGS = 1;
public const GAME_UNIT_TYPE_DEFENCE_BUILDINGS = 2;
public const GAME_UNIT_TYPE_SPECIAL_BUILDINGS = 3;
public const GAME_UNIT_TYPE_UNITS = 4;
public const GAME_UNIT_TYPE_SPECIAL_UNITS = 5;
public const int GAME_UNIT_TYPE_BUILDINGS = 1;
public const int GAME_UNIT_TYPE_DEFENCE_BUILDINGS = 2;
public const int GAME_UNIT_TYPE_SPECIAL_BUILDINGS = 3;
public const int GAME_UNIT_TYPE_UNITS = 4;
public const int GAME_UNIT_TYPE_SPECIAL_UNITS = 5;

private ?int $id;
private string $name;
Expand Down
11 changes: 2 additions & 9 deletions src/Entity/MarketItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@

class MarketItem
{
/**
* @var string
*/
public const TYPE_BUY = 'buy';

/**
* @var string
*/
public const TYPE_SELL = 'sell';
public const string TYPE_BUY = 'buy';
public const string TYPE_SELL = 'sell';

private ?int $id;
private int $amount;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class Message
{
public const MESSAGE_STATUS_NEW = 0;
public const MESSAGE_STATUS_READ = 1;
public const int MESSAGE_STATUS_NEW = 0;
public const int MESSAGE_STATUS_READ = 1;

private ?int $id;
private Player $fromPlayer;
Expand Down
23 changes: 4 additions & 19 deletions src/Entity/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,10 @@

class Player
{
/**
* @var int
*/
private const PRICE_PER_REGION = 10000;

/**
* @var int
*/
public const FEDERATION_HIERARCHY_RECRUIT = 1;

/**
* @var int
*/
public const FEDERATION_HIERARCHY_CAPTAIN = 3;

/**
* @var int
*/
public const FEDERATION_HIERARCHY_GENERAL = 10;
private const int PRICE_PER_REGION = 10000;
public const int FEDERATION_HIERARCHY_RECRUIT = 1;
public const int FEDERATION_HIERARCHY_CAPTAIN = 3;
public const int FEDERATION_HIERARCHY_GENERAL = 10;

private ?int $id;
private string $name;
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class Report
{
public const TYPE_ATTACKED = 1;
public const TYPE_GENERAL = 2;
public const TYPE_MARKET = 4;
public const TYPE_AID = 5;
public const int TYPE_ATTACKED = 1;
public const int TYPE_GENERAL = 2;
public const int TYPE_MARKET = 4;
public const int TYPE_AID = 5;

private ?int $id;
private int $type;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

class User implements UserInterface, PasswordAuthenticatedUserInterface, EquatableInterface, Serializable
{
private const ROLE_DEFAULT = 'ROLE_USER';
public const ROLE_ADMIN = 'ROLE_ADMIN';
private const string ROLE_DEFAULT = 'ROLE_USER';
public const string ROLE_ADMIN = 'ROLE_ADMIN';

private ?int $id;
private string $username = '';
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/World.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

class World
{
private const STATUS_CREATED = 0;
private const STATUS_RUNNING = 1;
private const STATUS_FINISHED = 2;
private const int STATUS_CREATED = 0;
private const int STATUS_RUNNING = 1;
private const int STATUS_FINISHED = 2;

private ?int $id;
private string $name = '';
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/WorldRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

class WorldRegion
{
public const TYPE_WATER = 'water';
public const TYPE_BEACH = 'beach';
public const TYPE_FORREST = 'forrest';
public const TYPE_MOUNTAIN = 'mountain';
public const string TYPE_WATER = 'water';
public const string TYPE_BEACH = 'beach';
public const string TYPE_FORREST = 'forrest';
public const string TYPE_MOUNTAIN = 'mountain';

private ?int $id;
private int $x;
Expand Down
6 changes: 3 additions & 3 deletions src/Service/BattleEngine/BattlePhase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

abstract class BattlePhase implements IBattlePhase
{
public const AIR_PHASE = 'air';
public const SEA_PHASE = 'sea';
public const GROUND_PHASE = 'ground';
public const string AIR_PHASE = 'air';
public const string SEA_PHASE = 'sea';
public const string GROUND_PHASE = 'ground';

protected string $name;

Expand Down
4 changes: 2 additions & 2 deletions src/Service/OperationEngine/OperationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

abstract class OperationProcessor implements OperationInterface
{
protected const GAME_UNIT_SPECIAL_OPS_ID = 401;
protected const GAME_UNIT_GUARD_ID = 400;
protected const int GAME_UNIT_SPECIAL_OPS_ID = 401;
protected const int GAME_UNIT_GUARD_ID = 400;
protected WorldRegion $region;
protected Operation $operation;
protected WorldRegion $playerRegion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class AdvancedSpy extends OperationProcessor
{
protected const GAME_UNIT_SPY_ID = 407;
protected const int GAME_UNIT_SPY_ID = 407;

public function getFormula(): float
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class AdvancedSpy2 extends OperationProcessor
{
protected const GAME_UNIT_SPY_ID = 407;
protected const int GAME_UNIT_SPY_ID = 407;

public function getFormula(): float
{
Expand Down
10 changes: 5 additions & 5 deletions src/Service/OperationEngine/OperationProcessor/DestroyCash.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

final class DestroyCash extends OperationProcessor
{
protected const RESEARCH_DESTROY_CASH_LEVEL_1 = 600;
protected const RESEARCH_DESTROY_CASH_LEVEL_2 = 601;
protected const RESEARCH_DESTROY_CASH_LEVEL_3 = 602;
protected const RESEARCH_DESTROY_CASH_LEVEL_4 = 603;
protected const RESEARCH_DESTROY_CASH_LEVEL_5 = 604;
protected const int RESEARCH_DESTROY_CASH_LEVEL_1 = 600;
protected const int RESEARCH_DESTROY_CASH_LEVEL_2 = 601;
protected const int RESEARCH_DESTROY_CASH_LEVEL_3 = 602;
protected const int RESEARCH_DESTROY_CASH_LEVEL_4 = 603;
protected const int RESEARCH_DESTROY_CASH_LEVEL_5 = 604;


public function getFormula(): float
Expand Down
10 changes: 5 additions & 5 deletions src/Service/OperationEngine/OperationProcessor/DestroyFood.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

final class DestroyFood extends OperationProcessor
{
protected const RESEARCH_DESTROY_FOOD_LEVEL_1 = 605;
protected const RESEARCH_DESTROY_FOOD_LEVEL_2 = 606;
protected const RESEARCH_DESTROY_FOOD_LEVEL_3 = 607;
protected const RESEARCH_DESTROY_FOOD_LEVEL_4 = 608;
protected const RESEARCH_DESTROY_FOOD_LEVEL_5 = 609;
protected const int RESEARCH_DESTROY_FOOD_LEVEL_1 = 605;
protected const int RESEARCH_DESTROY_FOOD_LEVEL_2 = 606;
protected const int RESEARCH_DESTROY_FOOD_LEVEL_3 = 607;
protected const int RESEARCH_DESTROY_FOOD_LEVEL_4 = 608;
protected const int RESEARCH_DESTROY_FOOD_LEVEL_5 = 609;

public function getFormula(): float
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

final class SniperAttack extends OperationProcessor
{
protected const GAME_UNIT_SOLDIER_ID = 300;
protected const GAME_UNIT_SNIPER_ID = 402;
protected const int GAME_UNIT_SOLDIER_ID = 300;
protected const int GAME_UNIT_SNIPER_ID = 402;

protected const SOLDIERS_KILLED_PER_SNIPER = 5;
protected const int SOLDIERS_KILLED_PER_SNIPER = 5;

public function getFormula(): float
{
Expand Down
2 changes: 1 addition & 1 deletion src/Service/OperationEngine/OperationProcessor/Spy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

final class Spy extends OperationProcessor
{
protected const GAME_UNIT_SPY_ID = 407;
protected const int GAME_UNIT_SPY_ID = 407;

public function getFormula(): float
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

final class StealthBomberAttack extends OperationProcessor
{
protected const BUILDINGS_DESTROYED_PER_BOMBER = 5;
protected const GAME_UNIT_STEALTH_BOMBER_ID = 404;
protected const int BUILDINGS_DESTROYED_PER_BOMBER = 5;
protected const int GAME_UNIT_STEALTH_BOMBER_ID = 404;

public function getFormula(): float
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

final class SubmarineAttack extends OperationProcessor
{
protected const GAME_UNIT_SUBMARINE_ID = 403;
protected const GAME_UNIT_SHIP_ID = 303;
protected const SHIPS_KILLED_PER_SUBMARINE = 1;
protected const int GAME_UNIT_SUBMARINE_ID = 403;
protected const int GAME_UNIT_SHIP_ID = 303;
protected const int SHIPS_KILLED_PER_SUBMARINE = 1;

public function getFormula(): float
{
Expand Down
4 changes: 2 additions & 2 deletions src/Util/AbstractPlayerCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
abstract class AbstractPlayerCalculator
{
protected const ABSTRACT_GAME_RESOURCES_UPKEEP = 'upkeep';
protected const ABSTRACT_GAME_RESOURCES_INCOME = 'income';
protected const string ABSTRACT_GAME_RESOURCES_UPKEEP = 'upkeep';
protected const string ABSTRACT_GAME_RESOURCES_INCOME = 'income';

protected AbstractGameResources $abstractGameResources;

Expand Down
2 changes: 1 addition & 1 deletion src/Util/NetworthCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

final class NetworthCalculator
{
public const NETWORTH_CALCULATOR_REGION = 1000;
public const int NETWORTH_CALCULATOR_REGION = 1000;

private WorldRegionUnitRepository $worldRegionUnitRepository;

Expand Down
4 changes: 2 additions & 2 deletions templates/game/fleetList.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{ fleet.worldRegion.x }}, {{ fleet.worldRegion.y }}
</td>
<td>
{{ fleet.targetWorldRegion.x }}, {{ fleet.targetWorldRegion.y }}: {{ fleet.targetWorldRegion.region }}
{{ fleet.targetWorldRegion.x }}, {{ fleet.targetWorldRegion.y }}
</td>
<td>
{% if player.federation != null and player.federation.id == fleet.targetWorldRegion.player.federation.id %}
Expand All @@ -51,7 +51,7 @@
{% if timestampLeft == 0 %}
<td><b>Arrived!</b></td>
{% else %}
<td><span class="timer">{{ timestampLeft|date('H:i:s', '+00:00 GMT') }}</span></td>
<td><span class="timer">{{ timestampLeft|date('H:i:s') }}</span></td>
{% endif %}

<td>
Expand Down

0 comments on commit e7c60a6

Please sign in to comment.