Skip to content

Releases: magicsunday/xmlmapper

4.0.0

Choose a tag to compare

@magicsunday magicsunday released this 05 Oct 12:57
4.0.0
15f5f99

⚠️ Breaking changes

  • A new encoder is strict by default. new XmlEncoder($extractor) now throws UnmappableValueException for a value it cannot map, instead of dropping it without a signal. The message names the property path and the type of the value. A null stays empty and a Stringable object is written as its text in both modes.
  • Raised the PHP floor to ^8.4. PHP 8.3 is no longer supported.
  • XmlEncoder::$nameConverter is private and read-only. It was protected. A subclass that read the property has to change.
  • CamelCasePropertyNameConverter is a final read-only class. It can no longer be extended. Implement PropertyNameConverterInterface instead.

🔧 Internal

  • Property hooks are read through the reflection API directly, the PHP 8.3 fallbacks are gone.
  • A property with a stored value and a get hook is pinned by a test, the encoder writes what the hook returns.
  • Copy-paste detection runs through the shared workflow, with jscpd pinned in package.json. Run npm ci once before the local ci:test.

🧭 Migration

  • To keep dropping an unmappable value silently, pass false as the third constructor argument: new XmlEncoder($extractor, $nameConverter, false).
  • Move to PHP 8.4 or newer.
  • Replace a subclass of the converter by an implementation of the interface.

The 3.x line (PHP 8.3, lenient default) is maintained on the 3.x branch.

3.2.0

Choose a tag to compare

@magicsunday magicsunday released this 05 Oct 07:05
3.2.0
a789fbb

Added

  • Opt-in strict mode. new XmlEncoder($extractor, $nameConverter, true) throws UnmappableValueException for a value it cannot map instead of dropping it without a signal. The message names the property path and the type of the value.
  • UnmappableValueException, a RuntimeException with named constructors for a value that is neither scalar nor Stringable and for a collection value that cannot be iterated.

The default stays lenient, so an existing encoder behaves exactly as before. A null stays empty and a Stringable object is written as its text in both modes.

Documentation

  • The API reference and the recipes describe which values a lenient encoder drops and what a strict encoder does instead. This covers an unresolved array, a nested object without the marker interface, a marker on a collection and a collection converter that returns no iterable.

3.1.0

Choose a tag to compare

@magicsunday magicsunday released this 04 Oct 22:16
3.1.0

Added

  • #[XmlIgnore] keeps a property out of the XML. It is checked before the property is read, so neither the field nor a custom type converter is touched.
  • addType() accepts a fully qualified class or interface name and matches it before the object catch-all, so a converter can target one value object.
  • CircularReferenceException: map() stops with it on a cyclic object graph instead of recursing without bound. The message names the property path that closes the cycle.
  • InvalidXmlValueException: map() refuses a value that XML 1.0 cannot carry (a character below the space other than tab, line feed and carriage return, U+FFFE, U+FFFF, or a string that is not valid UTF-8). The message names the property path.

Fixed

  • Values containing an ampersand are no longer corrupted when written through the element path.
  • map() is repeatable. Every call builds a fresh document.
  • A typed property that was never assigned is skipped like a null value instead of raising an Error.
  • A write-only virtual property (PHP 8.4, a set hook without a get hook) is skipped instead of raising an Error.
  • A static property is no longer encoded as state of the object.
  • Documentation corrected where it described behaviour the code does not implement. The documented extractor setup now lists both extractors for the types.

Changed

  • Dropped the unused symfony/property-access requirement. A project that uses it directly must require it itself.
  • Behaviour to be aware of: a string that contains a character XML 1.0 forbids, or that is not valid UTF-8, now raises InvalidXmlValueException instead of producing a document that cannot be parsed. A public static property that used to appear in the XML no longer does.

Internal

  • Development tooling moved to the shared magicsunday/coding-standard ruleset, including the Deptrac architecture layers.

3.0.1

Choose a tag to compare

@magicsunday magicsunday released this 08 Jul 14:44

Fixed

  • Updated GitHub Actions workflow pins and version comments for the latest released action tags.
  • Removed redundant PHPDoc so Rector dry-runs remain clean.

Internal

  • Kept CI and security workflows aligned with the shared repository setup.
  • Sorted development dependencies and refreshed dependency automation metadata.

3.0.0

Choose a tag to compare

@magicsunday magicsunday released this 12 Jun 08:46
64ef902

⚠️ Breaking changes

  • Dropped the Doctrine docblock-annotation marker support. The property markers XmlAttribute, XmlNodeValue and XmlCDataSection are now recognised only as native PHP attributes (#[XmlAttribute], #[XmlNodeValue], #[XmlCDataSection]). The legacy @XmlAttribute / @XmlNodeValue / @XmlCDataSection PHPDoc syntax is no longer read.
  • Removed the doctrine/annotations dependency (it was abandoned and only powered the docblock path).
  • Raised the PHP floor to ^8.3 — PHP 8.2 is no longer supported.

🔧 Internal

  • Marker resolution reads a property's attributes in a single reflection pass (exact name match, since the marker classes are final).
  • Tested against PHPUnit 12 / 13 (PHP 8.3 → 12, 8.4/8.5 → 13); Rector raised to the PHP 8.3 level.

🧭 Migration

  • Replace docblock markers with the native attribute form: @XmlAttribute → #[XmlAttribute], etc.
  • Move to PHP 8.3 or newer.

The 2.x line (Doctrine docblock annotations, PHP 8.2) is maintained on the 2.x branch.

2.0.0

Choose a tag to compare

@magicsunday magicsunday released this 12 Jun 07:24
2c11fd3

⚠️ Breaking changes

  • Dropped Symfony 6 support. symfony/property-info and symfony/property-access now require ^7.3 || ^8.0.
  • Added symfony/type-info as a required dependency — the encoder was migrated from the legacy type resolution to symfony/type-info.
  • The supported PHP range is now open-ended (^8.2), covering PHP 8.5.

✨ Features

  • Native PHP 8 attribute syntax for the property markers: #[XmlAttribute], #[XmlNodeValue], #[XmlCDataSection] — usable interchangeably with the existing Doctrine docblock annotations (@XmlAttribute, …).

🐛 Fixes

  • Correctly encode collections whose value type is a union of object types (and mixed scalar/object unions) by routing each entry on its runtime value instead of the static union type.

⚡ Performance

  • Memoize the resolved property markers per class property and cache the Doctrine annotation reader across property checks, eliminating redundant reflection and docblock parsing.

🔧 Maintenance

  • PHPStan raised to max level (no baseline).
  • Tested against PHPUnit 11 / 12 / 13 (PHP 8.2 → 11, 8.3 → 12, 8.4/8.5 → 13).
  • Development tooling aligned with magicsunday/jsonmapper (jscpd copy-paste gate, centralised caches); CI extended to PHP 8.5.

1.2.0

Choose a tag to compare

@magicsunday magicsunday released this 03 Feb 13:39

Full Changelog: 1.1.0...1.2.0

1.1.0

Choose a tag to compare

@magicsunday magicsunday released this 23 Apr 11:11

Full Changelog: 1.0.1...1.1.0

1.0.1

Choose a tag to compare

@magicsunday magicsunday released this 03 Mar 13:45

Full Changelog: 1.0.0...1.0.1

1.0.0

Choose a tag to compare

@magicsunday magicsunday released this 25 Jan 08:00
  • Initial Release