kriswallsmith/assetic — pull request #348 by sdboyer (2013-01-03 20:32:04+00:00)
Title: Convert all private members on Assetic\Asset\* classes to protected.

i'm making this request as part of the overall attempt to shift Drupal to using Assetic. see https://drupal.org/node/1871596, but especially https://drupal.org/node/1871596#comment-6884638 .

we have to subclass Assetic's assets classes in order to accommodate some additional metadata layers (we have to deal with asset reordering in a way that Assetic does not appear to be built for). so it's really quite important that we be able to mutate, or at *least* access, these various properties. BaseAsset provides getters for most of the properties, but HttpAsset, for example, provides no getter for $sourceUrl. even with getters for everything, though, the code would be awkward and verbose to do all such assignments/accessings via methods, as well as slightly less performant.

the alternative is simply writing our own BaseAsset class, which would be pretty awful - i'd like us to keep things DRY.

i certainly understand not wanting the properties public, but i don't see any obvious reason to not make them protected. i haven't spent a TON of time looking at the AssetInterface family tree to figure out any implicit contracts there, but nothing has jumped out at me so far that really necessitates restricting access to those members by subclasses.

i realize there's a somewhat similar issue over at \#236, but that deals with members on the writer classes, on which @schmittjoh's comments about the use of composition seem more applicable. in this case, i'd prefer to avoid composition because it would make serialization (something else we'll likely need to do) more complex, make the class structure itself more complex in general, and all without a use case for utilizing the swappability composition brings.