Add attribute.stub.php: PHP OO API stubs for Pango text attributes - #8
Add attribute.stub.php: PHP OO API stubs for Pango text attributes#8MarcelBolten with Copilot wants to merge 13 commits into
Conversation
- Add Color class (readonly, 16-bit RGB with parse/toString) - Add AttrType enum with all PangoAttrType values and version guards - Add abstract Attribute base class with startIndex/endIndex and static factory methods for all attribute types - Add AttrString, AttrInt, AttrFloat, AttrColor, AttrSize, AttrFontDesc concrete attribute subclasses - Add Underline enum (with >= 1.50 cases) - Add Overline enum (>= 1.46) - Add ShowFlags abstract class with bitfield constants (>= 1.44) - Add BaselineShift, FontScale, TextTransform enums (>= 1.50) - Add AttrList class with insert/change/getAttributes/splice and update (>= 1.44), toString/fromString (>= 1.50)
- Fix grammar: 'what the display' -> 'the display' - Fix spelling: 'expect' -> 'except' (word() docblock) - Fix doc: 'underlined' -> 'overlined' in Overline::Single case - Clarify splice() documentation to accurately describe behavior
|
@copilot I don't like the mix of static methods for some attributes and the concrete class implementation for others. |
Done. All static factory methods have been removed from
Committed in 1e2acc4. |
…e where possible Renamed: - ColorAttribute -> Color - SizeAttribute -> Size - FontDescriptionAttribute -> FontDescription StringAttribute, IntAttribute, and FloatAttribute cannot be renamed as String, Int, and Float are reserved PHP type names.
…asses Remove StringAttribute, IntAttribute, FloatAttribute, Color, Size, and FontDescription generic classes. Add one concrete class per Type enum case: Language, Family, Style, Weight, Variant, Stretch, Size, AbsoluteSize, FontDesc, Foreground, Background, Underline, Strikethrough, Rise, Shape, Scale, Fallback, LetterSpacing, UnderlineColor, StrikethroughColor, Gravity, GravityHint, FontFeatures, ForegroundAlpha, BackgroundAlpha, AllowBreaks, Show, InsertHyphens, Overline, OverlineColor, LineHeight, AbsoluteLineHeight, TextTransform, Word, Sentence, BaselineShift, FontScale.
|
@copilot the Language attribute should not use a string in its constructor but a Language class that has yet to be implemented under the Pango namespace. only change the attribute and don't create the language class. |
Done. The |
|
@copilot the variant attribute should only accept the variant enum already in the codebase |
Done. The |
|
@copilot the style attributeshould only accept the style enum |
Done. The |
|
@copilot review all attributes and find all where a php enum could be used instead of int. show me a list before actually making any changes |
Here are all attributes currently using
Remaining
Shall I go ahead and apply the enum substitutions for all 9 in the table above? |
|
@copilot yes, go ahead and do the changes proposed in the last comment |
Done. All 9 attribute classes now use their corresponding enums: |
|
@copilot now also convert the boolen like attributes to accept only boolean values in the php api |
Done. |
Pango text attributes (
PangoAttrType,PangoAttribute,PangoAttrList, etc.) have no PHP representation yet. This adds the stub file that defines the object-oriented PHP API surface for all Pango attribute types.New file:
src/attribute.stub.phpValue types
Color—final readonly classfor 16-bit RGB;parse(string $spec): Color+toString(): stringAttrType— backedenum: intcovering allPANGO_ATTR_*values with#if PANGO_VERSIONguards for additions in 1.38 / 1.44 / 1.46 / 1.50Attribute hierarchy
Attribute— abstract base with$startIndex/$endIndexand static factory methods mapping 1:1 topango_attr_*_new()C functionsAttrString,AttrInt,AttrFloat,AttrColor,AttrSize,AttrFontDesc— concrete leaf classes holding the typed payloadSupporting enums / flag classes
UnderlineSingleLine/DoubleLine/ErrorLinein 1.50)OverlineShowFlags(abstract constants class)BaselineShift,FontScale,TextTransformAttrListFull API:
insert(),insertBefore(),change(),getAttributes(),equal(),splice(),update()(1.44),toString()/fromString()(1.50).Usage example