You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,23 @@
1
1
# CLAUDE.md
2
2
3
+
## Responding to review notes
4
+
5
+
When working through a list of review notes, critically evaluate each note before acting on it:
6
+
7
+
-**Is the note correct?** The reviewer may be mistaken about what the code does, or may be
8
+
operating on a false assumption. If the note is factually wrong, explain why and skip it.
9
+
-**Is the proposed fix better than the current approach?** The reviewer's suggestion is a
10
+
starting point, not a mandate. If a different solution is clearly superior, propose it.
11
+
-**Is there an even better solution?** Think beyond the note. If the reviewer flags a smell,
12
+
consider whether the right fix is the one they suggest or a deeper redesign.
13
+
-**Document the reasoning.** For each note, produce a summary of what action was taken and why
14
+
— including why any note was rejected or handled differently than suggested.
15
+
16
+
After tackling all notes, provide a summary table: one row per note, action taken, and brief
17
+
reasoning.
18
+
19
+
---
20
+
3
21
## Learning from reviews
4
22
5
23
After completing a task that involved responding to code review feedback, scan the reviewer's
@@ -73,7 +91,7 @@ composer update
73
91
./vendor/bin/phpunit --testdox
74
92
```
75
93
76
-
Tests write generated PHP classes to `sys_get_temp_dir()/PHPModelGeneratorTest/Models/` and dump failed classes to `./failed-classes/` (auto-cleaned on bootstrap).
94
+
Tests write generated PHP classes to a session-unique directory `sys_get_temp_dir()/PHPModelGeneratorTest_<id>/Models/`(defined as `MODEL_TEMP_PATH`; the base is `TEST_BASE_DIR`) and dump failed classes to `./failed-classes/` (auto-cleaned on bootstrap). The session directory is cleaned up automatically via a shutdown function when the PHP process exits.
// If setters are generated the setters also perform validations.
140
140
// Exception: 'Value for age must not be smaller than 0'
@@ -168,7 +168,7 @@ The library is tested via [PHPUnit](https://phpunit.de/).
168
168
169
169
After installing the dependencies of the library via `composer update` you can execute the tests with `./vendor/bin/phpunit` (Linux) or `vendor\bin\phpunit.bat` (Windows). The test names are optimized for the usage of the `--testdox` output. Most tests are atomic integration tests which will set up a JSON-Schema file and generate a class from the schema and test the behaviour of the generated class afterwards.
170
170
171
-
During the execution the tests will create a directory PHPModelGeneratorTest in tmp where JSON-Schema files and PHP classes will be written to.
171
+
During the execution the tests will create a session-unique directory `PHPModelGeneratorTest_<id>` in tmp where JSON-Schema files and PHP classes will be written to. The directory is removed automatically when the test process exits, so concurrent test sessions do not interfere with each other.
172
172
173
173
If a test which creates a PHP class from a JSON-Schema fails the JSON-Schema and the generated class(es) will be dumped to the directory `./failed-classes`
Copy file name to clipboardExpand all lines: docs/source/generator/builtin/additionalPropertiesAccessorPostProcessor.rst
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,27 +34,34 @@ Generated interface with the **AdditionalPropertiesAccessorPostProcessor**:
34
34
35
35
.. code-block:: php
36
36
37
-
public function getRawModelDataInput(): array;
38
-
39
37
public function setExample(float $example): static;
40
38
public function getExample(): float;
41
39
42
-
public function getAdditionalProperties(): array;
43
-
public function getAdditionalProperty(string $property): ?string;
44
-
public function setAdditionalProperty(string $property, string $value): static;
45
-
public function removeAdditionalProperty(string $property): bool;
40
+
public function meta(): Meta;
41
+
public function additionalProperties(): AdditionalPropertiesAccessor;
42
+
43
+
The ``additionalProperties()`` method returns an accessor object with the following interface:
44
+
45
+
.. code-block:: php
46
+
47
+
public function getAll(): array;
48
+
public function get(string $key): mixed;
49
+
public function set(string $key, mixed $value): void;
50
+
public function remove(string $key): bool;
46
51
47
52
.. note::
48
53
49
-
The methods **setAdditionalProperty** and **removeAdditionalProperty** are only added if the `immutable setting <../../gettingStarted.html#immutable-classes>`__ is set to false.
54
+
The methods **set** and **remove** on the accessor are only available if the `immutable setting <../../gettingStarted.html#immutable-classes>`__ is set to false.
55
+
56
+
When the ``additionalProperties`` keyword provides a schema that constrains the value type, a typed companion class ``{ModelName}AdditionalProperties`` is generated that narrows the return and parameter types of the accessor methods accordingly.
50
57
51
-
**getAdditionalProperties**: This method returns all additional properties which are currently part of the model as key-value pairs where the key is the property name and the value the current value stored in the model. All other properties which are part of the object (in this case the property *example*) will not be included. In opposite to the *getRawModelDataInput* the values provided via this method are the processed values. This means if the schema provides an object-schema for additional properties an array of object instances will be returned. If the additional properties schema contains `filter <../../nonStandardExtensions/filter.html>`__ the filtered (and in case of transforming filter transformed) values will be returned.
58
+
**getAll**: Returns all additional properties currently part of the model as key-value pairs. Properties defined in the schema (in this case *example*) are not included. Unlike ``meta()->rawInput()``, the values returned here are the processed values — if the schema defines an objectschema for additional properties, an array of object instances is returned; if a `filter <../../nonStandardExtensions/filter.html>`__ is applied, the filtered (and for transforming filters, transformed) values are returned.
52
59
53
-
**getAdditionalProperty**: Returns the current value of a single additional property. If the requested property doesn't exist null will be returned. Returns as well as *getAdditionalProperties* the processed values.
60
+
**get**: Returns the current value of a single additional property. Returns null if the requested property does not exist. Like ``getAll``, returns the processed value.
54
61
55
-
**setAdditionalProperty**: Adds or updates an additional property. Performs all necessary validations like property names or min and max properties validations. If the additional properties are processed via a transforming filter an already transformed value will be accepted. If a property which is regularly defined in the schema a *RegularPropertyAsAdditionalPropertyException* will be thrown. If the change is valid and performed also the output of *getRawModelDataInput* will be updated.
62
+
**set**: Adds or updates an additional property. Performs all necessary validations including property name constraints and min/max properties limits. If the additional properties are processed via a transforming filter an already transformed value will be accepted. Throws *RegularPropertyAsAdditionalPropertyException* if the key conflicts with a regularly-defined schema property.
56
63
57
-
**removeAdditionalProperty**: Removes an existing additional property from the model. Returns true if the additional property has been removed, false otherwise (if no additional property with the requested key exists). May throw a *MinPropertiesException* if the change would result in an invalid model state. If the change is valid and performed also the output of *getRawModelDataInput* will be updated.
64
+
**remove**: Removes an existing additional property from the model. Returns true if the property was removed, false if it did not exist. May throw a *MinPropertiesException* if removal would produce an invalid model state.
Copy file name to clipboardExpand all lines: docs/source/generator/builtin/enumPostProcessor.rst
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,3 +88,45 @@ If an enum which requires a mapping is found but no mapping is provided a **Sche
88
88
.. note::
89
89
90
90
By enabling the *$skipNonMappedEnums* option of the **EnumPostProcessor** you can skip enums which require a mapping but don't provide a mapping. Those enums will provide the default `enum <../../complexTypes/enum.html>`__ behaviour.
91
+
92
+
Enums inside compositions
93
+
~~~~~~~~~~~~~~~~~~~~~~~~~
94
+
95
+
Enum schemas are also discovered inside composition keywords (**oneOf**, **anyOf**, **allOf**, **if** / **then** / **else**) and inside array **items** schemas, including nested compositions. The generated enum class is added to the parent property's PHP type hint so the setter accepts the enum instance directly.
96
+
97
+
Consider a property that accepts either a single status or a list of statuses:
98
+
99
+
.. code-block:: json
100
+
101
+
{
102
+
"type": "object",
103
+
"properties": {
104
+
"status_filter": {
105
+
"oneOf": [
106
+
{ "$ref": "#/definitions/Status" },
107
+
{
108
+
"type": "array",
109
+
"items": { "$ref": "#/definitions/Status" }
110
+
}
111
+
]
112
+
}
113
+
},
114
+
"definitions": {
115
+
"Status": {
116
+
"type": "string",
117
+
"title": "Status",
118
+
"enum": ["active", "paused", "completed"]
119
+
}
120
+
}
121
+
}
122
+
123
+
The generated setter exposes the enum class in both the PHPDoc and the native type hint:
public function setStatusFilter(string|Status|array|null $statusFilter): static;
131
+
132
+
Branches under **not** are intentionally skipped — a value that fails an inner schema is not itself enum-typed and contributes no useful type information.
0 commit comments