Skip to content
This repository has been archived by the owner on Sep 6, 2020. It is now read-only.

Doctrine-style Annotations are removed #85

Open
mvriel opened this issue Aug 24, 2014 · 10 comments
Open

Doctrine-style Annotations are removed #85

mvriel opened this issue Aug 24, 2014 · 10 comments
Labels

Comments

@mvriel
Copy link

mvriel commented Aug 24, 2014

When I build a new phar using box 2.4.4 then I JMS serializer starts to complain that an annotation is missing:

mvriel@vps2686:~/release$ php phpDocumentor.phar --version
PHP Fatal error:  Uncaught exception 'JMS\Serializer\Exception\RuntimeException' with message 'You must define a type for phpDocumentor\Configuration::$title.' in phar:///home/mvriel/release/phpDocumentor.phar/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php:213
Stack trace:
#0 phar:///home/mvriel/release/phpDocumentor.phar/vendor/jms/serializer/src/JMS/Serializer/GraphNavigator.php(227): JMS\Serializer\XmlDeserializationVisitor->visitProperty(Object(JMS\Serializer\Metadata\PropertyMetadata), Object(SimpleXMLElement), Object(JMS\Serializer\DeserializationContext))
#1 phar:///home/mvriel/release/phpDocumentor.phar/vendor/jms/serializer/src/JMS/Serializer/Serializer.php(114): JMS\Serializer\GraphNavigator->accept(Object(SimpleXMLElement), Array, Object(JMS\Serializer\DeserializationContext))
#2 phar:///home/mvriel/release/phpDocumentor.phar/src/phpDocumentor/Configuration/Loader.php(112): JMS\Serializer\Serializer->deserialize('<?xml version="...', 'phpDocumentor\C...', 'xml')
#3 phar:///home/mvriel/release in phar:///home/mvriel/release/phpDocumentor.phar/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php on line 213

But when I check the code it is there:

use JMS\Serializer\Annotation as Serializer;

[...]

    /**
     * @var string The title for the generated documentation.
     * @Serializer\Type("string")
     */
    protected $title = '';

This would lead me to the conclusion that the compacting removed the type annotation (at the least).
Is this a bug or a configuration issue that was introduced in newer versions?

@ghost
Copy link

ghost commented Aug 24, 2014

Have you tried extracting the phar to see if the processed file had its annotation removed?

box extract phpDocumentor.phar will create a phpDocumentor.phar-contents directory.

@ghost ghost added the Help label Sep 5, 2014
@TomasVotruba
Copy link
Contributor

I have similar problem. My annotations are removed and is disabled app.

I use magic class methods, that are turned to simple getters/setters.

/**
 * @method setAutowired(TRUE)
 */

When I set ignore 'method' annotation, it wipes it's content anyway.

/**
 * @method
 */

I need to keep it completely the same as in original code. Is this box2 issue?

@ghost
Copy link

ghost commented Sep 28, 2014

Hey @TomasVotruba, your particular issue is a little different. Box only provides support for Doctrine-styled annotations, which is not what you are using. You'll need to create your own custom compactor for those types of annotations, or disable compacting altogether.

@TomasVotruba
Copy link
Contributor

How to disable compacting?

@mvriel
Copy link
Author

mvriel commented Sep 29, 2014

Apologies that it took so long for me to respond but life got in the way :)

Anyway: I have recreated the phar file because I had created a workaround for it to work. the output that I got was:

namespace phpDocumentor;

use JMS\Serializer\Annotation as Serializer;
use phpDocumentor\Configuration\Logging;
use phpDocumentor\Configuration\Merger\Annotation as Merger;
use phpDocumentor\Partials\Partial;
use phpDocumentor\Plugin\Plugin;
use phpDocumentor\Transformer\Configuration\Transformations;




class Configuration
{
/**
@Serializer\Type("string")

*/
protected $title = '';

So it would seem that the annotation is there (but has no leading asterisk, I don't know if that matters).

Since the annotation is there I am going to dig deeper to see why this error occurs with the extracted contents

@mvriel
Copy link
Author

mvriel commented Sep 29, 2014

Apparently if I change the DocBlock from

/**
@Serializer\Type("string")

*/

to

/**
* @Serializer\Type("string")
*/

It does work. I assume that the asterisk in front of the annotation is required by Jms Serializer.

Is there a way to tell the compacter to skip specific files so that I can just tell it to skip the serializable files?

@TomasVotruba
Copy link
Contributor

I've finally used composer solution a bit customized, ApiGen/ApiGen@31ba2cf

Related to this issue, this fixed it: ApiGen/ApiGen@31ba2cf#diff-8dd307e1c3d75a13797b28772c4248c4R147

@ghost
Copy link

ghost commented Sep 29, 2014

@mvriel, unfortunately no but there is a workaround you can use:

List the files you want to leave as is using the files-bin configuration setting. That way the other files can be compacted, but the ones that Serializer couldn't parse will be packaged as is without making any changes to it.

@mvriel
Copy link
Author

mvriel commented Oct 14, 2014

What an excellent suggestion! I reckon that files-bin does nothing other than leaving those files alone or does it do anything else?

mvriel added a commit to mvriel/phpDocumentor2 that referenced this issue Oct 14, 2014
Kevin Herrera of the Box project mentioned that the most likely
fix for this issue was by putting the JMS Serializer-based files
in a files-bin array int he box.json (box-project/box2#85 (comment)).

Based on his recommendation this is something that we are going
to try out.
@ghost
Copy link

ghost commented Oct 15, 2014

You are correct, the files-bin option treats the listed files as if they were binary (like images, videos, etc). This means that Box won't touch the contents when it is imported into the phar.

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

No branches or pull requests

2 participants