Conceptually, I see @event being very similar to @throw.
@throw is intended to inform the consumer that a particular method/function MAY throw a particular exception.
Likewise, @event is intended to inform the consumer that a particular method/function may/will trigger a particular event type. By coupling an extension, it allows package authors to more clearly articulate to consumers which event hooks are exposed, allowing them to customize behavior as appropriate.
And to be fair, annotations are no more a first-class citizen in PHP than events are. :)
Additionally, for the sake of discussion, what is the purpose of the PHPDoc spec? Is it:
* To determine which patterns are native vs. userland? Or...
* To enable developers to provide the best possible documentation experience for their users?
I'll be the first to show my bias in favor of the latter. The event pattern in PHP may be a userland solution, but so was namespacing until 5.4. What I'm suggesting is that if this is an identified pattern being used by PHP developers, then there should be a way to document it for end-users. My suggestion is an @event tag.
To me, it makes sense that we should establish a pattern now in order to avoid a [Doc tools * Event libraries] matrix. By establishing a common pattern for documenting events (i.e., an identified design pattern that developers are already using *today*), we can avoid establishing this in the future when we have more inconsistency to tame.
Thoughts?
Introducing an @event tag would dictate the way event handling
software are to function and as such do not document but dictate
behaviour.
On Tuesday, October 9, 2012 5:13:53 PM UTC+1, Ryan Parman wrote:
What I'm suggesting is that if this is an identified pattern being used by PHP developers, then there should be a way to document it for end-users. My suggestion is an @event tag.How exactly are we identifying this pattern?
To me, it makes sense that we should establish a pattern now in order to avoid a [Doc tools * Event libraries] matrix. By establishing a common pattern for documenting events (i.e., an identified design pattern that developers are already using *today*), we can avoid establishing this in the future when we have more inconsistency to tame.
Thoughts?I agree with this argument. Based on the conversation so far, I'm generally in favor of having an @event tag.But you repeatedly mention that event-driven systems are an "identified pattern". Identified by who? What are the characteristics of an "event pattern"? Is there a formal definition somewhere? Since there's no standard implementation of events in PHP, how do we determine where an @event tag is or is not appropriate?
My concern is that people will have differing expectations of what constitues an event, and therefore will use and interpret @event tags in different ways. This has the potential to cause confusion. As you said, the purpose of a documentation spec should be to provide the best documentation experience for users. That won't happen if there isn't a clear definition and solid understanding among developers of what each documentation tag relates to.
Introducing an @event tag would dictate the way event handling
software are to function and as such do not document but dictate
behaviour.
I personally believe that a separate initiative should be started to
have interoperability between event handling software, such as
Symfony2's Event Dispatcher. This initiative could create a PSR that
allows for their own tags and annotations as a form of DSL; the PHPDoc
Standard supports these additions/extensions.
Ryan, regarding your question; it is beyond doubt that the goal is to
enable developers to write the best documentation out there.
But
please keep in mind that that does not mean all patterns should be
included in the core standard.
For example:
Logging is done far more often than event handling; should a @log be
added to indicate this method outputs a log? What about sending
e-mails? Should @email be added?
Where do you draw the line? By adding @event we add responsibility for
governing this and all effects related.
Regarding:
@api
@author
@deprecated
@global
@internal
@package
@since
@todo
None of the above define what the current syntactical element *does*,
only meta-information.
I will be the first to admit that selecting which tags to include is
hard but I honestly believe this is too specific for a core
specification.
On Oct 9, 2012, at 10:52 AM, Patrick Mulvey wrote:
On Tuesday, October 9, 2012 5:13:53 PM UTC+1, Ryan Parman wrote:
What I'm suggesting is that if this is an identified pattern being used by PHP developers, then there should be a way to document it for end-users. My suggestion is an @event tag.How exactly are we identifying this pattern?The event pattern is being used. It didn't occur to be that this would even be in question, but here is the evidence:
To me, it makes sense that we should establish a pattern now in order to avoid a [Doc tools * Event libraries] matrix. By establishing a common pattern for documenting events (i.e., an identified design pattern that developers are already using *today*), we can avoid establishing this in the future when we have more inconsistency to tame.
Thoughts?I agree with this argument. Based on the conversation so far, I'm generally in favor of having an @event tag.But you repeatedly mention that event-driven systems are an "identified pattern". Identified by who? What are the characteristics of an "event pattern"? Is there a formal definition somewhere? Since there's no standard implementation of events in PHP, how do we determine where an @event tag is or is not appropriate?In an attempt to bring what sounds like a hypothetical argument and bring in down to real-world implementations, I'm talking about the 800 lb. gorilla: Symfony Event Dispatcher. I recognize that there are other event systems in-use, and I'd love to take those into account as well, but I've been hard-pressed to find them.
Educate me?My concern is that people will have differing expectations of what constitues an event, and therefore will use and interpret @event tags in different ways. This has the potential to cause confusion. As you said, the purpose of a documentation spec should be to provide the best documentation experience for users. That won't happen if there isn't a clear definition and solid understanding among developers of what each documentation tag relates to.If this were a hypothetical debate, then sure, I'd agree with you. But how many people do you know who are using events in PHP _without_ using Symfony Event Dispatcher? Now, how many with?One of the tenets of this group is to attempt to codify things that are already happening in the community. This is something that is clearly already happening in the community.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Oct 9, 2012, at 11:12 PM, Sebastian Krebs <kreb...@gmail.com> wrote:
> A 800 lb. gorilla is not a "standard gorilla" and also there is at least a ZF2-implementation, that is not a tiny, little mouse too ;)
By this logic, PHPDoc isn't a standard either... but the truth is, it is -- at least as a _de-facto_ standard. The same could be said for Microsoft Word (in the business world), XMLHTTPRequest (until recently), and other non-standards that we completely take for granted.
Arguably, an 800 lb. gorilla *may* be (at the very least) a de-facto standard.
But nevermind that. That isn't even my intended point...
> Anyway, I don't think it's useful, when this group begins to make preferences about one implementations over others. At the end "the others" will just go away.
The event pattern is being used. It didn't occur to be that this would even be in question, but here is the evidence:
If this were a hypothetical debate, then sure, I'd agree with you. But how many people do you know who are using events in PHP _without_ using Symfony Event Dispatcher? Now, how many with?
Personally I don't like the name @event because the method triggering an
event itself isn't an event.
Like @throws describes en exception that may be throw.
A better name would be @triggers or @fires.
I think you misunderstood me. I'm not contesting that people are using event patterns. I was asking how you define an event pattern. How do you distinguish between an event pattern and a non-event pattern? Does an event pattern have to use a defined Event or EventDispatcher class?
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/6QlcH3c4SEQJ.
I think you misunderstood me. I'm not contesting that people are using event patterns. I was asking how you define an event pattern. How do you distinguish between an event pattern and a non-event pattern? Does an event pattern have to use a defined Event or EventDispatcher class?The "event pattern" is also known as the "observer pattern" and is a pretty widely pervasive software design pattern.
I think you misunderstood me. I'm not contesting that people are using event patterns. I was asking how you define an event pattern. How do you distinguish between an event pattern and a non-event pattern? Does an event pattern have to use a defined Event or EventDispatcher class?The "event pattern" is also known as the "observer pattern" and is a pretty widely pervasive software design pattern.It is called a "pattern" because it is just that -- an underlying design pattern; it is not the names of the classes involved, or even the interface through which they're accessed (similar to how a pattern is used to cut out the cloth for a piece of clothing -- but doesn't define the cloth or embellishments).I'm not really sure that the problem you are professing is a problem at all.
Regardless, I agree with the sentiment that an "@event" tag should not be included in the core PHPDoc PSR, but should rather be defined as a PHPDoc extension in a future Event-related PSR -- and this standard of "core" vs. "extension" should also be applied to any non-standard, implementation-related PHPDoc tags in the future.By leaving open the opportunity for extension by future PSRs, the PHPDoc standard, essentially, gains a level future-proofing that is not insubstantial, and it also allows those extensions to occur without unnecessary bloating of the core PHPDoc PSR.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
2012/10/10 Ryan Parman <ry...@ryanparman.com>
So, if I'm using ApiGen as my documentation tool, but I want to note that I'm using Symfony EventDispatcher events, which way would I go?
/**
* @apigen-event [...syntax and description...]
*/
or...
/**
* @symfony-event [...syntax and description...]
*/
Does either vendor have a preference?I would say "ryan-" or something like that, because you are neither the vendor of symfony, nor of apigen and both also doesn't define such a tag on it's own. Claiming a vendor-prefix of a foreign vendor is not nice ;)
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
If the consensus is that we don't add @event to the core PHPDoc spec, then how to we move forward? A couple of people have mentioned "future extension" or something similar. What does that look like?
Based on the conversation, it sounds as though the appropriate approach is to use @vanity-event.
Is it more appropriate to say:"I am a documentation tool. Give me all of your events." (e.g., @vanity-event, @apigen-event, @phpdocumentor-event)or..."Give me the events provided by a particular event library, and I will document them." (e.g., @symfony-event, @zf2-event)
1) When you say you're "moving forward with this" - does that mean you're going to actually implement this, or you're moving forward by proposing this extension? Are you going to ask for feedback and votes on this proposal before it is used?
2) I agree with Mike - why use @event and @events instead of just @event? IMO adding in the plural version is confusing (and it's also easy to mis-read @events as @event). Multiple @event tags would be preferable to an @events tag.
3) Have you considered moving forward by supporting vendor prefixed (@vendor-event) tags as discussed above? An alternative might be @beta-event. Personally I would prefer this over @event, since there hasn't really been a discussion in this group about events themselves. It would be nice to keep @event open until that occurs. Using vendor- or beta- prefixed tags would still allow you to meet the three goals you set out in this document, but would have the advantage of not introducing potential forward-compatibility issues if an alternative @event tag syntax is proposed in the future.
4) What do you think of the idea of calling this tag @dispatches (or @fires or @triggers or something similar) instead of @event? This feels cleaner to me, as it describes what the code actually does (in the same way that @throws describes that an exception may be thrown, @dispatches could describe that an event may be dispatched.
5) Have you thought about using extra tags to allow more granular documentation of when events are fired? For example, I may have a method that immediately fires an event when it is called, and fires a second event only when the method has completed some task successfully (similar to the example code you give in this document). For this, I may want to use something like @preEvent to document the first event (which is fired every time the method is called) and @postEvent (which is conditionally fired at the end of the method body). However this may be adding too much detail.
On Oct 11, 2012, at 11:27 AM, Patrick Mulvey <pdmu...@gmail.com> wrote:1) When you say you're "moving forward with this" - does that mean you're going to actually implement this, or you're moving forward by proposing this extension? Are you going to ask for feedback and votes on this proposal before it is used?In an ideal world, I would wait for more discussion first.But in reality, I have a project that leverages event dispatching heavily, and I need to be able to document those events for my end-users. I have a very practical, immediate need, and I don't have the time to wait for a potentially lengthy discussion and a vote.So, I'm pulling a WebKit — that is to say, I'm implementing support for the proposal now and submitting it to the standards body at the same time. I expect the implementation to adjust and change a bit as more discussion occurs, but that's a bullet I'm going to have to bite.
2) I agree with Mike - why use @event and @events instead of just @event? IMO adding in the plural version is confusing (and it's also easy to mis-read @events as @event). Multiple @event tags would be preferable to an @events tag.Yep, I agree. But ZF2 is using @events, and I wanted to attempt to accurately capture what was already happening in the wild.
3) Have you considered moving forward by supporting vendor prefixed (@vendor-event) tags as discussed above? An alternative might be @beta-event. Personally I would prefer this over @event, since there hasn't really been a discussion in this group about events themselves. It would be nice to keep @event open until that occurs. Using vendor- or beta- prefixed tags would still allow you to meet the three goals you set out in this document, but would have the advantage of not introducing potential forward-compatibility issues if an alternative @event tag syntax is proposed in the future.I'm currently on the fence about this one.Web browsers presently use -webkit, -moz, -ms and -o as CSS prefixes, with a default being non-prefixed. Over time as the spec shapes up, a browser will add support for the non-prefixed version while typically continuing to support the prefixed version.Both considering as well as discarding the language in the current draft of Mike's PHPDoc spec, I've considered:@event@:event@-event@vanity-event@v-event@-vanity-event@-v-event@:vanity-event@:v-eventI'm trying to find one that implies that it isn't part of the core spec, and it might change over time. At the moment, I was going to implement support for both @event and @vanity-event (as well as their pluralized counterparts), but I haven't written any code yet.Thoughts?
4) What do you think of the idea of calling this tag @dispatches (or @fires or @triggers or something similar) instead of @event? This feels cleaner to me, as it describes what the code actually does (in the same way that @throws describes that an exception may be thrown, @dispatches could describe that an event may be dispatched.I'd not considered that, but it's not a bad idea. The only issue I see is that I've not found a single instance of @dispatches in the wild, but I've seen @event on multiple occasions. Using @event seemed like the most pragmatic way forward.
5) Have you thought about using extra tags to allow more granular documentation of when events are fired? For example, I may have a method that immediately fires an event when it is called, and fires a second event only when the method has completed some task successfully (similar to the example code you give in this document). For this, I may want to use something like @preEvent to document the first event (which is fired every time the method is called) and @postEvent (which is conditionally fired at the end of the method body). However this may be adding too much detail.I hadn't considered that — mostly because my own usage places that information in the event identifier instead (e.g., vendor.task.pre, vendor.task.post).
[…] I'll be honest - I think this is a bad idea. If you publish a tool that makes use of @event, and it starts getting used as an unofficial standard, it will create conflicts later if this group (or anyone else, really) puts together a different standard for @event. If that happens, it won't just be you who is inconvenienced by it. This has the potential to affect a lot of developers.
Section 5.3 of the PHPDoc proposal (which you've linked to several times) specifically states "Tag names that are not prefixed with a vendor or namespace MUST be described in this specification (see chapter 7) and/or any official addendum.". If you're going forward with @event without waiting for a discussion and votes first, then you're clearly going against this clause.
As Mike and Niels have pointed out, there some issues with your proposed syntax. This is mainly because there hasn't been enough discussion yet. I understand you want to get on with documenting events immediately, without waiting for a protracted discussion. But there are ways of doing this (see below) that don't introduce the potential for compatibility problems in the future.As mentioned earlier, you can document events simply by using vendor-prefixing.
[…] The reason for these differences in the wild is that there is no defined standard - vendors have been making it up as they go. If a clear, sensible standard was accepted and became the norm, I imagine that vendors would eventually switch to use it. Having both @event and @events is obviously confusing and I don't think it should be standardised.
[…] As I described earlier in this thread, I don't think @vanity-event is appropriate at all. You know I think @event is a bad idea. I would propose supporting @vendor-event (so each vendor can use their own prefix) or @beta-event because it makes it clear that it's not an accepted standard yet, and is subject to modification. @beta-event may be the most clear way to indicate this.
Using a prefixed version allows you to start documenting events immediately without the issues of using @event itself. So then everybody's happy, right?
[…] That's true. I'd argue that if @dispatches became available in documentation tools it would be adopted. Perhaps both could be supported.
5) Have you thought about using extra tags to allow more granular documentation of when events are fired? For example, I may have a method that immediately fires an event when it is called, and fires a second event only when the method has completed some task successfully (similar to the example code you give in this document). For this, I may want to use something like @preEvent to document the first event (which is fired every time the method is called) and @postEvent (which is conditionally fired at the end of the method body). However this may be adding too much detail.I hadn't considered that — mostly because my own usage places that information in the event identifier instead (e.g., vendor.task.pre, vendor.task.post).Now that you have considered it, what are your thoughts?
Would it help to use braces with this particular tag? (as was suggested with @author?)
On Oct 12, 2012, at 11:29 AM, Drak <dr...@zikula.org> wrote:Would it help to use braces with this particular tag? (as was suggested with @author?)What would it look like?
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Section 5.3 of the PHPDoc proposal (which you've linked to several times) specifically states "Tag names that are not prefixed with a vendor or namespace MUST be described in this specification (see chapter 7) and/or any official addendum.". If you're going forward with @event without waiting for a discussion and votes first, then you're clearly going against this clause.I understand. I was weighing the pros and cons of following that section and supporting `@event`. I hadn't made up my mind yet, and I hadn't written any code yet.
As Mike and Niels have pointed out, there some issues with your proposed syntax. This is mainly because there hasn't been enough discussion yet. I understand you want to get on with documenting events immediately, without waiting for a protracted discussion. But there are ways of doing this (see below) that don't introduce the potential for compatibility problems in the future.As mentioned earlier, you can document events simply by using vendor-prefixing.I think you're right. But there was also some debate about what that vendor prefix should be.
Even then, the proposal should still be called "@event", but implementations should remain vendor-prefixed until such a PSR is ratified.
[…] As I described earlier in this thread, I don't think @vanity-event is appropriate at all. You know I think @event is a bad idea. I would propose supporting @vendor-event (so each vendor can use their own prefix) or @beta-event because it makes it clear that it's not an accepted standard yet, and is subject to modification. @beta-event may be the most clear way to indicate this.Using a prefixed version allows you to start documenting events immediately without the issues of using @event itself. So then everybody's happy, right?Sure, but I'm a little confused. @event is the tag, "vanity" is MY vendor prefix. Using the names of Event Dispatching software is problematic because we're trying to produce a single standard, not a splintered one (e.g., symfony-event, @zf2-event). @beta-event is... okay... but it just doesn't quite feel right to me, although I can't pinpoint why.
5) Have you thought about using extra tags to allow more granular documentation of when events are fired? For example, I may have a method that immediately fires an event when it is called, and fires a second event only when the method has completed some task successfully (similar to the example code you give in this document). For this, I may want to use something like @preEvent to document the first event (which is fired every time the method is called) and @postEvent (which is conditionally fired at the end of the method body). However this may be adding too much detail.I hadn't considered that — mostly because my own usage places that information in the event identifier instead (e.g., vendor.task.pre, vendor.task.post).Now that you have considered it, what are your thoughts?I think that *when* the events fire is entirely up to the software, and is probably too granular for the DocBlock. In my own uses cases, I frequently fire multiple pre/post events in a given task. As such, I feel like @preEvent and @postEvent are arguably a bit too niche at present.
Personally I don't like the name @event because the method triggering an
event itself isn't an event.
Like @throws describes en exception that may be throw.
A better name would be @triggers or @fires.
The Observer-Subject pattern does not use event names, so this kind of
documentation is not needed there. GOF is not mentioning named events at
all, IIRC. Though, the tag we're talking about, is to be used to
document the places, where named events are triggered.
So @triggers is the right terminus.
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/RdV06UsHD0o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+unsubscribe@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/741159e5-b5a4-41a2-b6be-951c631fd638%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I would like to propose the following enhancement to be included in a future PHPDoc-specific PSR: @event@eventThe @event tag is used to document events that are triggered by this function or method.## Syntax@event <"Type"> <"event_identifier"> [description]## DescriptionWith the @event tag, it is possible to document and event that is triggered by the function or method. When provided it MUST contain a "Type" (See Appendix A) to indicate what is returned; it MUST contain the name of the event that can be subscribed to by an event handler; the description on the other hand is OPTIONAL yet RECOMMENDED.The @event tag MAY have a multi-line description and does not need explicit delimiting.This tag MAY occur more than once in a "DocBlock" and is limited to the "DocBlock" of a type method or function.## Examplesuse Symfony\Component\EventDispatcher\Event;use Vanity\Custom\Event\SimpleEvent;
/*** @event Event vanity.task.all.complete Triggers when all of the tasks have been completed.* @event SimpleEvent vanity.task.failure Triggers when a task fails to complete successfully.*/