docs(readme): document what the parser returns - #20
Merged
Merged
Conversation
The README showed which methods exist but never what they give back, so the only way to learn the shape of a placemark, a style or the GeoJSON output was to run the parser and print it. It also said nothing about which KML elements are supported, which matters more now that MultiGeometry, LineStyle, PolyStyle and SimpleData landed: users had no way to know those work, or that Folder and NetworkLink do not. Adds a supported elements table, the exact array shape of every getter, the accepted namespaces, the exception hierarchy, and notes on the parts that surprise people: MultiGeometry has geometries instead of coordinates, absent style keys are not defaults, colours stay in KML aabbggrr order, and the facade binding is scoped rather than a singleton. Also adds the missing CONTRIBUTING.md, which the README has linked to since the first release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The README listed the methods and stopped there:
It never said what comes back. The only way to find out the shape of a placemark, a style, or a GeoJSON feature was to run the parser and
dd()it. There are no DTOs and no return-type information beyondarray, so nothing else fills that gap either.It also never said which parts of KML are actually handled. That was already a problem, and the recent work made it worse:
MultiGeometry,LineStyle,PolyStyleandSchemaData/SimpleDataall landed, and nobody reading the README would know. MeanwhileFolder,NetworkLinkand the overlays still do nothing, and nobody would know that either. The failure mode is someone downloading the package, feeding it a file whose data quietly does not come back, and giving up.What was added
getPlacemarks()for each geometry type,getStyles(),getStyleMaps(),toGeoJson().KmlExceptionso one catch covers it.extractAllFiles()writes whatever the archive holds.The parts people get wrong
Called out explicitly, because each one is a plausible source of a bug in calling code:
MultiGeometryplacemark hasgeometries, notcoordinates. Reaching for$placemark['coordinates']without checkingtypefirst is now an undefined index rather than a missing feature.aabbggrrstring. Alpha first, blue before red. Handing that to a CSS colour function gives you the wrong colour, not an error.scoped, so a laterKmlParser::getPlacemarks()does not necessarily see what an earlier separate call loaded. Chain the calls or hold the instance.One inaccuracy found while writing this
altitudecomes back as afloatwhen the coordinate declares it and as anint0when it does not:The docblock on
parsePointCoordinates()claimsaltitude: float. The README documents the current behaviour (0, not0.0) rather than the intended one. Not fixed here to keep this PR to documentation. Small follow-up.CONTRIBUTING.md
The README has linked to
CONTRIBUTING.mdsince the first release and the file has never existed. Added, covering how to report a bug with a reproducing document, how to ask for a KML element, the three commands CI runs, and the request to write the failing test first and to call out array-shape changes since those break callers without breaking tests.Verification
Every shape in the README was produced by running the parser on a document exercising all of it, not written from memory. Claims about requirements, config keys and composer scripts checked against
composer.jsonandconfig/kml-parser.php. Suite still 62 passing.