PHP Annotations Are a Horrible Idea
theunraveler.com
PHP Annotations Are a Horrible Idea
1–10 of 127 posts
Re: PHP Annotations Are a Horrible Idea
#2This says it all ... and to be honest, from an ease point of view I like using annotations but as with most parts of PHP it's the implementation that sucks (or the lack of implementation)
Over 2 years ago a RFC has been filed for native php annotations and I must say that I like the idea of annotations being part of the actual language and not relying on Inflection on comments (wtf?) to attach metadata to classes, propeties or methods. Just too bad nobody can get their act together and get it implemented in the core. https://wiki.php.net/rfc/annotations
Re: PHP Annotations Are a Horrible Idea
#3I don't think that just an array quite make it as a real alternative but a definition builder called from a method seems more appropriate. Also I would seperate model definition from model repository.
Re: PHP Annotations Are a Horrible Idea
#4Re: PHP Annotations Are a Horrible Idea
#5First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done.
He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon.
The fact that you can even parse out comments with the reflection API lends, to me, that meta-programming is a-ok.
Also, his alternatives are kind of weak. Here's an annotation:
/**
* @Column(type="string", length=32, unique=true, nullable=false)
*/
protected $username;
And here's his proposed alternative: class User
{
public static $mapping = array(
'username' => array(
'type' => 'string',
'length' => 32,
'unique' => true,
'nullable' => function() {
// Some logic to determine value.
}
)
);
}
I'll take the first one because I have other shit I need to do.Re: PHP Annotations Are a Horrible Idea
#6Re: PHP Annotations Are a Horrible Idea
#7 return $this->render("MyBundle:Controller:template.html.php", array(...));
That said, it would be easy enough to add the static variable-based mapping information to Doctrine as a metadata driver, and create a version of SensioFrameworkExtraBundle that does the same for its annotations.Re: PHP Annotations Are a Horrible Idea
#8This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…
Judging from the RCF and discussions on internals we still have a long way to go before we get annotations in PHP core.
http://marc.info/?r=1&w=2&q=b&l=php-internals... https://wiki.php.net/rfc/annotations
Re: PHP Annotations Are a Horrible Idea
#9 while (true)
read("http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/");Re: PHP Annotations Are a Horrible Idea
#10I see PHP Annotations as a hack for comments. That said, I found very ironic someone giving a rant of a hack in hacker news. Just saying.. :)