BenMakesGames / BenMakesGames/PoppySeedPets

update entity properties, getters, and setters to be strongly typed; use __construct to ensure entities are newed up in a valid state

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
good first issue tech debt
Dominant language
PHP
Stars
15
Forks
6
Avg merge
5m
Merged PRs (30d)
2

Description

**context:** the `make:entity` is pretty good for creating and updating entities, but it allows many properties to be `null`, even if they shouldn't be. this can lead to bugs.

to reduce the chance of bugs, aim for objects to always be in a valid state.

**todo:**
1. update entity properties, and related getter and setter, to be strongly-typed (including accounting for nullability)
2. ensure entities are always newed up in a valid state; possibilities:
1. add required properties to `__construct` - easy, works best when required properties are low
* this option will probably cover the majority of cases
3. make `__construct` private and create static factory methods - similar to above; preferable when there are multiple ways to construct an entity
4. create a builder class (preferably with a fluent API) that assists with creating the entity - appropriate only when newing up an entity is very complex

it's totally legit to upgrade just one entity or a small group of entities in a PR; this issue will be closed when all entities are updated.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the make:entity implementation and inspecting a generated entity, including its properties, getters, setters, and construction path. Define a manageable entity or small group to update first; done means its types account for nullability and it can only be created in a valid state, with the chosen construction approach documented by the resulting code.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
api, backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.