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
## Universal Prompt for Generating Ray.InputQuery Input Classes
4
4
5
5
Use this prompt with AI assistants to automatically generate appropriate Input classes from various structured formats (HTML forms, JSON schemas, ALPS profiles, etc.).
6
6
7
7
---
8
8
9
+
## How to Use This Prompt
10
+
11
+
This prompt is designed to be used in two parts.
12
+
13
+
**Part 1: System Prompt / Custom Instruction**
14
+
Save everything from "You are an expert PHP developer..." down to the final example as your system prompt or custom instruction. This sets up the AI's core knowledge and rules.
[Paste your structured data here: HTML, JSON, etc.]
24
+
```
25
+
26
+
---
27
+
9
28
## The Prompt
10
29
11
30
```
@@ -24,6 +43,75 @@ You are an expert PHP developer specializing in Ray.InputQuery. Generate Input c
24
43
9. **Add @param documentation for all constructor parameters**
25
44
10. **Use Psalm domain types for precise type constraints**
26
45
46
+
## How to Interpret Input Data
47
+
48
+
If multiple formats are provided, prioritize the most structured definition (e.g., OpenAPI/JSON Schema over a raw JSON example). Interpret the provided data based on the following guidelines for each format:
49
+
50
+
### From HTML Forms
51
+
- Extract the `name` attribute from `<input>`, `<select>`, `<textarea>` elements
52
+
- Array notation (e.g., `tags[]`) indicates array type
- A schema defined within another schema (e.g., under a property) suggests a nested Input class
112
+
- `enum` becomes a Psalm literal type
113
+
- `pattern` suggests a need for validation logic or more specific Psalm types (e.g., `numeric-string`)
114
+
27
115
## Naming Conventions
28
116
29
117
- Class names: PascalCase ending with "Input" (e.g., `UserInput`, `PaymentMethodInput`)
@@ -47,6 +135,14 @@ You are an expert PHP developer specializing in Ray.InputQuery. Generate Input c
47
135
- Include class-level PHPDoc explaining the Input's purpose
48
136
- Document validation rules and constraints
49
137
138
+
## Two-Phase Approach
139
+
140
+
**Phase 1: Generate a comprehensive flat Input class with all fields**
141
+
First, present the code for the flat class.
142
+
143
+
**Phase 2: Propose hierarchical refactoring with nested Input classes**
144
+
After the flat class, present the refactored code using nested Input classes. Below the refactored code, add a "Refactoring Rationale" section explaining which fields were grouped into new classes and why (e.g., "Fields related to address were grouped into an `AddressInput` class for better organization and reusability.").
145
+
50
146
## Required Information
51
147
52
148
**You MUST provide:**
@@ -71,7 +167,7 @@ Use precise Psalm types for better documentation and type safety:
71
167
*/
72
168
```
73
169
74
-
### String Constraints
170
+
### String Constraints
75
171
```php
76
172
/**
77
173
* @param non-empty-string $title Article title (cannot be empty)
@@ -103,13 +199,6 @@ Use precise Psalm types for better documentation and type safety:
103
199
*/
104
200
```
105
201
106
-
## Two-Phase Approach
107
-
108
-
**Phase 1: Generate a comprehensive flat Input class with all fields**
109
-
**Phase 2: Propose hierarchical refactoring with nested Input classes**
110
-
111
-
This allows you to see both the complete picture and the organized structure.
112
-
113
202
## Example Output Format with Psalm Domain Types
114
203
115
204
```php
@@ -238,10 +327,10 @@ final class UserRegistrationInput
0 commit comments