Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations with \ do not get parsed correctly #1480

Closed
stanlemon opened this issue Oct 30, 2013 · 13 comments
Closed

Annotations with \ do not get parsed correctly #1480

stanlemon opened this issue Oct 30, 2013 · 13 comments

Comments

@stanlemon
Copy link

For example... @Orm\Column just yields "ORM" - this makes it virtually impossible to use annotations that map to fully qualified class names.

@volodymyrburdeinyi
Copy link

I think this issue is linked with this one:
http://forum.phalconphp.com/discussion/1104/router-annotations-arrays-handle-v1-2-4

@stanlemon
Copy link
Author

@hander Maybe, but I've been able to parse annotations with arrays using Phalcon when I am doing it stand-alone and now with the Mvc\Router\Annotations implementation.

@ghost
Copy link

ghost commented Nov 22, 2013

@stanlemon do you have a test case or sample code that fails?

@stanlemon
Copy link
Author

Sure, so the code below for example will yield "ORM" and "Routing" for annotation when what is desired is "ORM\Table" and "Routing\Route" because those map to concrete classes I was to use as annotations.

<?php

/**
 * @ORM\Table("test", ["id", "name", "created"])
 * @Routing\Route("/foo/bar")
 */
class Test {

    public function fooBar()
    {
    }
}

$reader = new \Phalcon\Annotations\Adapter\Memory();

//Reflect the annotations in the class Example
$reflector = $reader->get('Test');

//Read the annotations in the class' docblock
$annotations = $reflector->getClassAnnotations();

//Traverse the annotations
foreach ($annotations as $annotation) {

    //Print the annotation name
    echo $annotation->getName(), PHP_EOL;

    //Print the number of arguments
    echo $annotation->numberArguments(), PHP_EOL;

    //Print the arguments
    print_r($annotation->getArguments());
}

@ghost
Copy link

ghost commented Nov 23, 2013

The bug seems to be in phannot_remove_comment_separators() function:

Before:

/**
 * @ORM\Table("test", ["id", "name", "created"])
 * @Routing\Route("/foo/bar")
 */

After:

@ORM @Routing

@ghost ghost mentioned this issue Dec 2, 2013
phalcon pushed a commit that referenced this issue Dec 2, 2013
phalcon pushed a commit that referenced this issue Dec 2, 2013
@ghost
Copy link

ghost commented Dec 2, 2013

This is fixed in both 1.2.5 and 1.3.0, could you please check now?

@stanlemon
Copy link
Author

1.2.5 looks good, but it does not appear fixed with 1.3.0.

@stanlemon
Copy link
Author

Thanks btw - this is a pretty awesome improvement!

@ghost
Copy link

ghost commented Dec 3, 2013

Please build 1.3.0 from ext/, not from build/

cd ext
phpize && ./configure && make && sudo make install

@stanlemon
Copy link
Author

Hmm... I am not able to build that way on OS X so I am not able to confirm.

FWIW... This is what I get:

mkdir mvc/view/engine/.libs
 cc -I. -I/Users/stan/Sites/cphalcon/ext -DPHP_ATOM_INC -I/Users/stan/Sites/cphalcon/ext/include -I/Users/stan/Sites/cphalcon/ext/main -I/Users/stan/Sites/cphalcon/ext -I/usr/local/php5/include/php -I/usr/local/php5/include/php/main -I/usr/local/php5/include/php/TSRM -I/usr/local/php5/include/php/Zend -I/usr/local/php5/include/php/ext -I/usr/local/php5/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/stan/Sites/cphalcon/ext/mvc/view/engine/php.c  -fno-common -DPIC -o mvc/view/engine/.libs/php.o
/Users/stan/Sites/cphalcon/ext/mvc/view/engine/php.c:102:4: error: too few arguments to function call, expected 4, have 1
                        NULL
                        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/include/stddef.h:74:25: note:
      expanded from macro 'NULL'
#  define NULL ((void*)0)
                        ^
./mvc/view/engine/helpers.h:25:1: note: 'phalcon_mvc_view_engine_php_symtable_merger' declared here
zend_bool phalcon_mvc_view_engine_php_symtable_merger(HashTable *ht, void *pData, zend_hash_key *hash_key, void *pParam);
^
1 error generated.
make: *** [mvc/view/engine/php.lo] Error 1
Maximus:ext stan$

@ghost
Copy link

ghost commented Dec 4, 2013

Could you please paste the full build log?

Also, what version of PHO do you use?

@stanlemon
Copy link
Author

Here is PHP:

Maximus:ext stan$ php -v
PHP 5.5.5 (cli) (built: Oct 20 2013 22:14:10)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans

And the full build log:
https://gist.github.com/stanlemon/07ba14b8e7c2d6e29073

@ghost
Copy link

ghost commented Dec 5, 2013

Thanks, fix submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants