BREAKING: Arrayable schemas, new Schema/* namespace, support schemas return raw arrays (#2)#46
Conversation
…return raw arrays (#2)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| public function description(): string | ||
| { | ||
| throw new BadMethodCallException(sprintf( | ||
| '%s::description() is not supported for support schemas.', | ||
| static::class | ||
| )); |
There was a problem hiding this comment.
Support schemas declare incompatible description() return type
The SupportSchemaTrait declares description(): string and just throws, but SchemaInterface now requires description(): ?string. Classes such as Schema/Support/MessageSchema and Schema/Support/ErrorsSchema use this trait without overriding the method, so their generated method signature is string, which is incompatible with the interface. Attempting to load any of those classes will trigger a fatal "Declaration must be compatible" error. The trait’s signature should be updated to ?string (or the classes should override it) so the codebase remains instantiable.
Useful? React with 👍 / 👎.
| foreach($properties as $propertyName => $property) { | ||
| $property = new Property( | ||
| $propertyName, | ||
| new Schema($property->toArray()), | ||
| in_array($property, $nullable, true), | ||
| in_array($property, $required, true) |
There was a problem hiding this comment.
Procedure input generator ignores nullable/required flags
When generating an input class for procedure schemas, each property is wrapped in Property with in_array($property, $nullable, true) and in_array($property, $required, true). The $nullable/$required arrays from ObjectSchema contain property names, not schema instances, so these strict comparisons always return false. As a result, every generated field is treated as non-nullable and optional even when the schema marks it required, which will produce incorrect client code. The checks should compare $propertyName against those arrays instead.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (75.13%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
🚀 New features to boost your workflow:
|
Summary
This pull request introduces full arrayable support across all schema-interface–based classes and ensures consistent test coverage for serialization behavior.
Tasks
toArray()method onSchemaIntegerSchemaInterface-based classes implement arrayable behaviortoArray) and consistency checksBreaking Changes
1.
SchemaInterfacecontract updateSchemaInterface::toArray(): array.→ Any external implementations must add this method.
2. Namespace & layout refactor
All schemas moved from
Blugen\Service\Lexicon\V1\TypeSpecificSchema\*→Blugen\Service\Lexicon\V1\Schema\*.New structure:
StringSchema,BooleanSchema)ArraySchema,ObjectSchema)RefSchema,UnionSchema,UnknownSchema,TokenSchema)InputSchema,OutputSchema,MessageSchema,ErrorsSchema)QuerySchema,ProcedureSchema,RecordSchema,SubscriptionSchema,HTTPAbstract)→ Any code importing old
TypeSpecificSchema\...namespaces will break.3. Support schemas –
type()anddescription()behaviorSupportSchemaTrait, which throwsBadMethodCallExceptionintype()(anddescription()unless overridden).→ Code calling
type()on support schemas will fail.4. InputSchema / OutputSchema return type changes
schema()now returns raw?arrayfromIOAbstract(was schema object).→ Callers expecting schema objects (e.g.,
ObjectSchema,UnionSchema,RefSchema) will break.5.
ErrorsSchemacollection semanticsNow yields
ErrorSchemaobjects instead of arrays.Implements read-only
ArrayAccess:offsetSet()/offsetUnset()throwBadMethodCallException.offsetGet()throwsOutOfBoundsExceptionfor invalid indexes.→ Previously it accepted arbitrary array access.
6.
ObjectSchema::properties()contract updateSchemaFactory) instead ofPropertyobjects.MissingRequiredFieldExceptionifpropertiesis invalid or missing.name,nullable,required) must now be derived via schema arrays.→ Code depending on
Propertyobjects will break.7. New core exception introduced
Blugen\Service\Lexicon\V1\Exceptions\MissingRequiredFieldException→ Thrown in
ObjectSchema::properties()and potentially other locations.8. Generator & factory updates
SchemaFactoryrefactored to point to newSchema\{Concrete,Container,Meta}classes.SchemaFactory.→ Any custom generator or class references to old
TypeSpecificSchemapaths must be updated.9. Legacy class removals
Deleted:
V1/TypeSpecificSchema/Support/{ErrorsSchema,InputSchema,MessageSchema,OutputSchema}V1/TypeSpecificSchema/Field/ObjectSchemaReplacements exist under new
V1/Schema/{Support,Container,...}but with changed behaviors above.10. Explicit breaking commit reference
16a45c4— BREAKING CHANGE: Refactor(TypeSpecificSchema/Support) to use traits and return raw schema arrays.