Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Commits on Feb 27, 2015
  1. phooji

    [pfff][lexer fix]

    phooji authored
    Summary:
    This seems to fix the issue of dealing with complex expressions
    directly following `...` in a function call (see testcase); looks like
    the special token isn't really needed.
    
    Test Plan:
    make tests # succeeds 124, 2 skipped
    
    in `flib`:
    
      $ find . -name '*.php' -exec bash -c ">&2 ~/pfff/pfff.opt -dump_php {} && echo \"0 {}\" || echo \"1 {}\"" \; > out.txt
    
      $ grep '^[^0]' ./out.txt
      1 ./thrift/lib/fbcode/adsatlas/api/extif/atlas_api.thrift/atlas_api_types.php
      1 ./third-party/php-openid/Auth/OpenID/Server.php
      1 ./third-party/php-openid/Auth/OpenID/TrustRoot.php
    
    Reviewers: michalburger1, eletuchy
    
    Reviewed By: eletuchy
    
    Subscribers: dominik, jezng
    
    Differential Revision: https://phabricator.fb.com/D1869317
    
    Signature: t1:1869317:1424897321:945d693f4afdf783875bf9d85ea345f4f5aa56b7
  2. phooji

    [pfff] add travis CI badge to readme

    phooji authored
    Summary:
    Convert readme to have markdown extension, add rando kludge that
    should show up as a badge + link to the travis build. This makes
    it easier to find out when we break the build.
    
    Test Plan: yolo3
    
    Reviewers: eletuchy, leegao
    
    Reviewed By: leegao
    
    Subscribers: dominik
    
    Differential Revision: https://phabricator.fb.com/D1865672
    
    Signature: t1:1865672:1424734402:cdebc7c5708e7410f527a2b95317bead61f29c2d
  3. phooji

    [pfff][prolog] make the unit tests pass

    phooji authored
    Summary:
    D1816838 fixes this for one version of Swipl, but it per @pad's
    comments
    [[https://github.com/facebook/pfff/commit/385c43f5219f0c591be088b69f71d1c34446fafb| on github]], our travis instance uses some non-space version of
    swipl. Fix by just normalizing the output from whatever PL to not
    include spaces.
    
    Test Plan:
      make tests
    
    Ran with 5.11, which seems to not include spaces; got the tests to pass
    
    Reviewers: eletuchy, leegao
    
    Reviewed By: leegao
    
    Subscribers: dominik, pad
    
    Differential Revision: https://phabricator.fb.com/D1865665
    
    Signature: t1:1865665:1424734504:53b391b5ffbd912f69c0ef7504bc46f515064b5c
    
    Blame Revision: D1816838
Commits on Feb 18, 2015
  1. phooji

    Merge pull request #105 from Stelian/phar-file

    phooji authored
    Fixed an issue where phar files are treated like php scripts
Commits on Jan 31, 2015
  1. Eugene Letuchy

    [pfff] support abstract const declarations

    elgenie authored
    Summary:
    `abstract const` for classes is necessary to be able to
     safely deal with PHP-isms like `static::THE_CONST` and
     `$instance::THE_CONST`.
    
     Mostly shuffling ast nodes: there's entirely entirely too
     much code being churned in this diff.
    
    Test Plan: included test (possibly inadequate test coverage)
    
    Reviewers: jezng, andrewparoski, mqian, pieter
    
    Reviewed By: pieter
    
    Differential Revision: https://phabricator.fb.com/D1817448
    
    Signature: t1:1817448:1422688166:ddc4c8d4a3dbbde1c3dc24cb5862df02ab4459c3
  2. Eugene Letuchy

    [pfff] update spacing in prolog tests

    elgenie authored
    Summary:
    When running swipl 5.7, the (insignificant) whitespace in
     facts did not quite match up with what the tests were expecting
    
      > swipl --version
      SWI-Prolog version 5.7.11 for x86_64-linux
    
    Test Plan:
      make test (prolog tests now pass)
    
    Reviewers: andrewparoski, pieter
    
    Reviewed By: pieter
    
    Differential Revision: https://phabricator.fb.com/D1816838
    
    Signature: t1:1816838:1422670201:f3643b7ebccfd407bea23227a5c3fd4f5c382c3b
  3. Eugene Letuchy

    [pfff] parse hh async blocks

    elgenie authored
    Summary:
    The syntax `async { <body> }` is used to indicate an
     immediately executed short closure (aka lambda). Some AST
     manipulation is required to indicate that the parameter list and
     `==>` portions of the lambda have been omitted.
    
    Test Plan: included test
    
    Reviewers: pieter, mqian, andrewparoski, jezng, jan
    
    Reviewed By: jan
    
    Differential Revision: https://phabricator.fb.com/D1816822
    
    Signature: t1:1816822:1422667074:805bb5a4ce559b0192459ab6015b50df0d9be164
Commits on Jan 30, 2015
  1. hansonw

    [pfff] Replace >> with "> >" in lambda typehints

    hansonw authored
    Summary:
    pad's parsing hack for ">>" doesn't know about lambda typehint contexts, so using ">>" in any lambda param typehint or return type typehint leads to a parsing error. Replace these properly.
    
    Also, I made the lambda typehint parse hack stop throwing errors - it just silently ignores things it doesn't understand now. I think this is preferable? The standard parse error will probably lead you to the approximate error location at least.
    
    Test Plan:
    Updated unit test, ran on all of `~/www`.
    
    These are the failures:
    ```
    1 /home/hansonw/www/flib/thrift/lib/fbcode/adsatlas/api/extif/atlas_api.thrift/atlas_api_types.php
    2 /home/hansonw/www/flib/intern/site/x/search/metrics/XInternNewsEventEvaluationQueriesPrecisionGeneratorController.php
    3 /home/hansonw/www/flib/groups/notifications/comment_mention/GroupCommentMentionNotificationSender.php
    4 /home/hansonw/www/flib/entity/query/core/filters/EntArgsBasedQueryFilter.php
    5 /home/hansonw/www/flib/js/mercury/MercuryConfig.php
    6 /home/hansonw/www/flib/notifications/renderers/fql_common/__tests__/NotifFQLRepresentationTestCase.php
    7 /home/hansonw/www/flib/third-party/php-openid/Auth/OpenID/Server.php
    8 /home/hansonw/www/flib/third-party/php-openid/Auth/OpenID/TrustRoot.php
    ```
    
    Upon inspection:
    - 1, 7, 8 are legitimate syntax errors
    - 4, 6 caused by some still unsupported unpacking syntax
    - 2, 3, 5 are caused by the new `async { }` syntax
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    Differential Revision: https://phabricator.fb.com/D1813353
    
    Signature: t1:1813353:1422571196:238f2d5aad28ce1c90bc71ac2f350f54d79ce2e3
Commits on Jan 21, 2015
  1. Yoann Padioleau

    Merge pull request #106 from mtibben/patch-1

    aryx authored
    Fix MacOSX install instructions
  2. Michael Tibben

    Fix MacOSX install instructions

    mtibben authored
    Updates the MacOSX install instructions for installing brew dependencies.
    
    Added `camlp4` as it's required when calling `make depend`. And `ocaml` is now called `objective-caml`.
Commits on Jan 20, 2015
  1. Stelian Mocanita

    Fixed an issue where phar files are treated like php scripts

    Stelian authored
    Added 'is_php_fileame_phar' function to check against the phar files
    Reworked 'is_php_file' so it ignores phar files
Commits on Dec 23, 2014
  1. phooji

    [pfff] move commons_graph to a separate directory

    phooji authored
    Summary:
    
    Looks like 378a73c wasn't
    quite match how the library is actually built. This moves
    the commons graph wrapper to a separate directory so that
    it's easier to build as a separate findlib package.
    
    This makes it easier to deal with some internal tooling that
    expects a single `.cmxa` and `.a` as a limitation.
    
    Test Plan:
    
      make clean
      make depend
      make
      make opt
      make uninstall-findlib
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  2. phooji

    [pfff] commons: export additional interfaces

    phooji authored
    Summary:
    
    `Graph` is referenced in `graph_code` (unsurprisingly)
    
    Test Plan:
    
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  3. phooji

    [pfff] export pretty_print_code

    phooji authored
    Summary:
    
    Almost there!
    
    Test Plan:
    
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed by: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  4. phooji

    [pfff] add lang_php/pretty findlib

    phooji authored
    Test Plan:
    
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  5. phooji

    [pfff] add json_out to exported symbols for jsonwheel

    phooji authored
    Summary:
    
    Similar to json_in; something references directly.
    
    Test Plan:
    
    make
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  6. phooji

    [pfff] add commons.mli to exported interfaces for pfff/commons

    phooji authored
    Summary:
    
    There's some references to this in fb-only code, so make sure
    it's exposed.
    
    Test Plan:
    
      make
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  7. phooji

    [pfff] h_program-lang fixup: more cmis

    phooji authored
    Summary:
    
    `Database_code` is referenced directly in a few places, and
    wasn't getting imported properly.
    
    Test Plan:
    
    make install-findlib; build something that uses `Database_code`
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  8. phooji

    [pfff] export findlib target for lang_php/analyze/matcher

    phooji authored
    Summary:
    
    Same as the last couple; make this findlib-exportable so I can
    link directly against the individual build products rather than
    just one All of PFFF Blob.
    
    Test Plan:
    
      make install-findlib # from various directories
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  9. phooji

    [pfff] export ast_php_simple.cmi

    phooji authored
    Summary:
    
    CMF depends directly on this file, and it doesn't have an mli,
    so we need to export this explicitly.
    
    Test Plan:
    
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  10. phooji

    [pfff] export findlib target for lang_php/matcher

    phooji authored
    Summary:
    
    Similar to the last couple.
    
    Test Plan:
    
      make uninstall-findlib
      cd lang_php/matcher
      make install-findlib
      make uninstall-findlib
      cd ../..
      make install-findlib
      make uninstall-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  11. phooji

    [pfff] export findlib target for h_version-control

    phooji authored
    Summary:
    
    Per title.
    
    Test Plan:
    
      make uninstall-findlib
      cd h_version-control
      make install-findlib
      make uninstall-findlib
      cd ..
      make install-findlib
      make uninstall-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  12. phooji

    [pfff] minor Makefile fixes

    phooji authored
    Summary:
    
    jsonwheel seems to have incurred a last-minute typo, and needs
    to export json_in; export all mli for graph_code.
    
    Test Plan:
    
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
Commits on Dec 22, 2014
  1. phooji

    [pfff] make install-findlib pick up graph_code and ocamlgraph

    phooji authored
    Summary:
    
    Looks like graph_code was missing a META file, and ocamlgraph was
    referring to a missing `graph.a` without the `ocaml` prefix.
    
    Test Plan:
    
    From the root:
    
      make uninstall-findlib
      make install-findlib # includes graph_code and ocamlgraph; succeeds
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  2. phooji

    [pfff] add entity_code.mli to findlibs interface for h_program-lang

    phooji authored
    Summary:
    
    Title
    
    Test Plan:
    
      cd h_program-lang
      make uninstall-findlib
      make install-findlib # succeeds; lists `entity_code.mli`
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  3. phooji

    [pfff] make lang_php/analyze/foundation findlib installable

    phooji authored
    Summary:
    
    Same approximate motivation as the previous round of this.
    
    Test Plan:
    
      make install-findlib
      make uninstall-findlib # from pfff ; pfff/lang_php/analyze ; pfff/lang_php/analyze/foundation
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  4. phooji

    [pfff] add parallel.ml to exported interfaces for findlib

    phooji authored
    Summary:
    
    Need a direct dep on this.
    
    Test Plan:
    
      make uninstall-findlib
      make install-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  5. phooji

    [pfff] add install-findlib target for jsonwheel

    phooji authored
    Summary:
    
    Title.
    
    Test Plan:
    
      make install-findlib
      make uninstall-findlib
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
  6. Drew Paroski phooji

    RFC: [pfff] Fix issue with lexing XHP identifiers

    paroski authored phooji committed
    Summary:
    This fixes pfff's lexer to match the behavior of github.com/facebook/xhp,
    HHVM, and the Hack typechecker.
    
    Test Plan: ?
    
    Reviewers: andrewparoski
    
    Reviewed By: andrewparoski
    
    Differential Revision: https://phabricator.fb.com/D1745109
    
    Signature: t1:1745109:1418805782:6e96e2b4c69cbe383de76b61400dfd35a4fe3193
Commits on Nov 21, 2014
  1. hansonw

    [pfff] Introduce a lexing hack to properly parse lambdas with typehints

    hansonw authored
    Summary:
    Lambdas are currently parsed in a pretty hacky way to avoid conflicts: any bracketed expression is allowed in the lambda parameters, which causes all sorts of problems when we attempt to introduce typehints (which can often look like expressions).
    
    This introduces a lexing hack in `parsing_php_hacks.ml` to resolve these conflicts. Whenever we see a `==>` token (which can only be used for a lambda) we examine the preceding tokens to look for the parameters.
    Once the parameters are identified, the open/closing parens are replaced with lambda-specific parens so the parser can easily identify them without context.
    
    There are three main cases:
    
    1) The last non-comment token was a variable. We don't need to do any processing for these, since they can't be typehinted and the parser can handle these fine
    2) The last non-comment token was a closing paren. We match the preceding group of parenthesized tokens. At this point it can still be a typehint (for a function or tuple type). However, we can easily tell if a group of tokens represents the parameters or the return typehint by checking if:
      1) it's an empty pair of parens, or
      2) it contains a variable or variadic (`...`, `...$x`).
    3) Otherwise, the preceding tokens must represent a typehint. We look for the last colon (not inside parens or brackets) and then look for a parenthesized group of arguments preceding that.
    
    The typehint checking is a little sketchy - I didn't try to be overly accurate about it. It will never reject a valid typehint, but it might let invalid ones through. I think this is generally fine, as the real parser should be able to take care of that.
    
    The grammar for lambda expressions is super clean now :D
    
    Test Plan:
    Ran over all files in www using this script:
    
    {P17364735}
    
    The resulting output is
    
    ```
    /home/hansonw/www/flib/thrift/lib/fbcode/adsatlas/api/extif/atlas_api.thrift/atlas_api_types.php
    /home/hansonw/www/flib/entity/query/core/filters/EntArgsBasedQueryFilter.php
    /home/hansonw/www/flib/entity/core/mutator/__tests__/EntMutatorComponentProviderTestCase.php
    /home/hansonw/www/flib/notifications/renderers/fql_common/__tests__/NotifFQLRepresentationTestCase.php
    /home/hansonw/www/flib/third-party/php-openid/Auth/OpenID/TrustRoot.php
    /home/hansonw/www/flib/third-party/php-openid/Auth/OpenID/Server.php
    ```
    
    1, 5, 6 are legitimate syntax errors. 2 and 3 are caused by modifiers on variadics in the constructor, and 4 is caused by unpacking an array access (`...$x['abc']`) which is not parsed correctly since pfff lexes `...$x` as a `T_VARIABLE_VARIADIC`.
    
    Also added a test `lambda_typehints.php`. Output of `pfff -dump_php` can be found at P17318696
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    Subscribers: keito
    
    Differential Revision: https://phabricator.fb.com/D1691785
    
    Signature: t1:1691785:1416528091:2d0a27aaca9ea81976eb92191304fd40f9421ac3
Commits on Nov 18, 2014
  1. phooji

    [pfff] remove `rm` for nonexistant files

    phooji authored
    Summary:
    
    A bunch of these don't get generated anymore, it seems, so
    dropping the corresponding cleanup from the Makefile.
    
    Test Plan:
    
    yolo3
    
    Reviewers: pieter
    
    Reviewed By: pieter
    
    CC:
    
    Task ID: #
    
    Blame Rev:
Commits on Nov 5, 2014
  1. phooji

    [pfff] parse + - type parameter constraints in combination with `as`

    phooji authored
    Summary:
    Looks like I went a little too easy D1638340; also
    [[https://www.facebook.com/groups/hackforhiphop/permalink/761864200528864/|hack group discussion]].
    
    Test Plan:
      ./pfff -dump_php ./test.php
      [ClassDef(
       {c_type=ClassAbstract(i_1, i_2); c_name=Name(("MobileZeroTargeter", i_3));
        c_tparams=Some((i_4,
                        [Left(
                           TParamConstraint(Name(("T", i_5)), i_6,
                             Hint(
                               XName([QI(Name(("IMobileZeroTargetable", i_7)))]),
                               None)))],
                        i_8));
        c_extends=None; c_implements=None; c_attrs=None; c_body=(i_9, [], i_10);
        c_enum_type=None; }); FinalDef(i_11)]
      [pieter@dev1342 ~/pfff] cat test.php
      <?hh
      abstract class MobileZeroTargeter<-T as IMobileZeroTargetable> {
    
      }
    
    Reviewers: jwatzman, eletuchy
    
    Reviewed By: eletuchy
    
    Subscribers: dominik
    
    Differential Revision: https://phabricator.fb.com/D1659736
    
    Signature: t1:1659736:1415149410:0ca7d109400b0820bf9dd34ef560edf3ac2ffc3a
Commits on Oct 30, 2014
  1. Eugene Letuchy

    [pfff] support for abstract final

    elgenie authored
    Summary:
    'abstract final class' is now allowed to support the 'class
     with static utility methods' pattern that's fairly common in PHP
     codebases (especially pre-namespaces ones).
    
    Test Plan: make
    
    Reviewers: jwatzman, pieter
    
    Reviewed By: pieter
    
    Differential Revision: https://phabricator.fb.com/D1648175
    
    Signature: t1:1648175:1414626868:749688fc54f93acb738b2fde0bae2b9d93b14c85
  2. Eugene Letuchy

    [pfff] fix arg unpacking semantics

    elgenie authored
    Summary:
    The unpack operator can be applied to any expression, as long
     as it happens within a function call.
    
    Test Plan: make
    
    Reviewers: hansonw, jwatzman, pieter
    
    Reviewed By: pieter
    
    Differential Revision: https://phabricator.fb.com/D1648160
    
    Signature: t1:1648160:1414626928:15d3b5700daa5621e074fa1579c78258e775f014
  3. Eugene Letuchy

    [pfff] rename dots token to ellipsis

    elgenie authored
    Summary:
    ... this better matches PHP/HHVM token naming. DOTS made
     sense when ellipses could only show up in pfff-only "match variable
     arguments".
    
    Test Plan: make succeeds!
    
    Reviewers: jwatzman, hansonw, pieter
    
    Reviewed By: pieter
    
    Differential Revision: https://phabricator.fb.com/D1648146
    
    Signature: t1:1648146:1414626807:71b2f239e752ec38f5f0c3061e7be5a6d8f262a1
Something went wrong with that request. Please try again.