Doctrine Common
  1. Doctrine Common
  2. DCOM-38

Annotation parser plain value types

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Annotations
    • Labels:
      None
    • Environment:
      any

      Description

      Hi,

      I posted this question in doctrine user group(https://groups.google.com/forum/?fromgroups#!topic/doctrine-user/QhAz-Yr70T0), but with no response, so I'd like to open it up here as the solution is trivial and would save me either a lot of sub-classing or prevent me from changing the doctrine library files.

      This annotation

      class SomeGrid {
          /**
           *  @GRID:Column(header="Reg. plate", width=80, editable=TRUE, hidden=FALSE, tooltip="Registration plate", align="left", sortable=TRUE)
           */
          public $regPlate;
      }
      

      produces the following object:

      (object) Grid\Annotations\Column {
          "header"   => (string) "Reg. plate"
          "width"    => (string) "80"
          "editable" => (bool)   true
          "hidden"   => (bool)   false
          "tooltip"  => (string) "Registration plate"
          "align"    => (string) "left"
          "sortable" => (bool)   true
      }
      

      You can see the value of the width property is string even I didn't use quotes in the annotation.
      The same happens with float values, but true and false values become, correctly, bool.

      I found this happens because of the following fragment of code in \Doctrine\Common\Annotations\Parser and could be easily corrected by prefixing the value with the corresponding type cast (marked in red).

          case Lexer::T_STRING:
              $this->match(Lexer::T_STRING);
              return $this->lexer->token['value'];
          case Lexer::T_INTEGER:
              $this->match(Lexer::T_INTEGER);
              return (int)$this->lexer->token['value'];
          case Lexer::T_FLOAT:
              $this->match(Lexer::T_FLOAT);
              return (float)$this->lexer->token['value'];
          case Lexer::T_TRUE:
              $this->match(Lexer::T_TRUE);
              return true;
          case Lexer::T_FALSE:
              $this->match(Lexer::T_FALSE);
              return false;
      

      The point is, in our app, some of the values go directly to browser and are processed by JavaScript. Having those values as strings breaks all kinds of mathematical operations on the client or would require additional (unnecessary) string to int/float conversions.

        Activity

        Martin Ivičič created issue -
        Hide
        Benjamin Eberlei added a comment -

        Fixed.

        Show
        Benjamin Eberlei added a comment - Fixed.
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12424 ] jira-feedback2 [ 17885 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17885 ] jira-feedback3 [ 19848 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DCOM-38, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Martin Ivičič
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: