You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+85-51Lines changed: 85 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,16 +10,16 @@ Running Our Software
10
10
The main prerequisites to running the [PHP][php], [Java][java], and [Rascal][rascal] code
11
11
used to implement our analysis are:
12
12
13
-
* Java JDK version 11: Java 11 is available from the [Java download][java] page. We recommend using the Eclipse Temurin release to avoid any licensing issues.
13
+
* Java JDK version 17: Java 11 is available from the [Java download][java] page. We recommend using the Eclipse Temurin release to avoid any licensing issues.
14
14
* PHP version 8: Although you can download the sourcecode for PHP from the [PHP download][php] page, it's often easier to use a precompiled version. For macOS, you can use [Homebrew][homebrew] and the [Homebrew PHP Formula][homebrew-php] to easily install a working version of PHP. For Windows, [XAMPP][xampp] provides a working version of PHP. For Linux, you should be able to use your package manager to install the newest version. Note that PHP no longer is included on macOS with the developer tools.
15
15
16
-
To edit and run Rascal code, please see the relevant information in the [online Rascal documentation][run-rascal]. You can use the command line, Eclipse, or VScode. All included code should work with the newest release of Rascal.
16
+
To edit and run Rascal code, please see the relevant information in the [online Rascal documentation][run-rascal]. You can use the command line, Eclipse, or VScode (recommended). All included code should work with the newest release of Rascal.
17
17
18
18
To parse PHP code, we are using a fork of an open-source PHP
19
19
Parser. This is also available in our Github repository, and
20
20
is named [PHP-Parser][phpp]. You will want to clone this project to a convenient location.
@@ -52,71 +52,105 @@ Second, you will want to add PHP AiR as a plugin dependency in the pom.xml file.
52
52
<dependency>
53
53
<groupId>org.rascalmpl</groupId>
54
54
<artifactId>php-analysis</artifactId>
55
-
<version>0.2.1-SNAPSHOT</version>
55
+
<version>0.3.1</version>
56
56
</dependency>
57
57
```
58
58
59
+
The `version` will depend on whether you also have PHP AiR installed locally. If you are also making changes to the PHP AiR project, you will want to use the version from the `pom.xml` file in that project. If not, you should select a version available to download as a dependency.
60
+
59
61
You will now be able to import libraries from PHP AiR in your project and in a Rascal console created in the context of your project.
60
62
61
63
Configuring PHP AiR
62
64
-------------------
63
65
64
-
Before you first use PHP AiR, you need to create a file named Config.rsc that will be in the folder src/main/rascal/lang/php/config. This will be the module `lang::php::config::Config`. You will do this either directly in the PHP AiR project or within your own project that imports PHP AiR as a dependency.
66
+
Before you first use PHP AiR, you need to set the values of configuration variables in a YAML file and set the environment variable `PHP_AIR_CONFIG` to point to this file. For instance, to set this to a file named `config.yaml`in a folder under your home directory named `/Projects/php-analysis/php-analysis`, you would use command `export PHP_AIR_CONFIG=$HOME/Projects/php-analysis/php-analysis/config.yaml`. You can also set this when using the `code` command to start VSCode, like `PHP_AIR_CONFIG=$HOME/Projects/php-analysis/php-analysis/config.yaml code .` to launch VSCode in the directory of the PHP AiR project.
65
67
66
-
An example of this configuration fileis shown below. Note that we assume, for this README, that all code being analyzed, and all intermediate results, are stored in a directory named `PHPAnalysis` in the user's home directory (i.e., `~/PHPAnalysis` on a Mac or Linux machine). Note also that there is an existing file under src/main/rascal/lang/php.config.rsc-dist. This file contains a template that you can copy to create your config file, and is the easiest way to create a new one. This file also contains Rascal `@doc` comments for each item. These comments are not shown below.
68
+
An example of this configuration file, based on one used by one of the contributors to this project, is shown below. This file is also included in the root of the repository. Note that we assume, for this README, that all code being analyzed, and all intermediate results, are stored in a directory named `PHPAnalysis` in the user's home directory (i.e., `~/PHPAnalysis` on a Mac or Linux machine).
67
69
68
70
```
69
-
module lang::php::config::Config
70
-
71
-
public bool usePhpParserJar = false;
72
-
73
-
public loc phploc = |file:///usr/local/php5/bin/php|;
74
-
75
-
public loc parserLoc = |file:///Users/hillsma/Projects/phpsa/PHP-Parser|;
76
-
77
-
public loc analysisLoc = |file:///Users/hillsma/Projects/phpsa/rascal/php-analysis/|;
78
-
79
-
public str parserMemLimit = "1024M";
80
-
81
-
public str astToRascal = "lib/Rascal/AST2Rascal.php";
82
-
83
-
public loc parserWorkingDir = (parserLoc + astToRascal).parent;
84
-
85
-
public loc baseLoc = |home:///PHPAnalysis|;
86
-
87
-
public loc parsedDir = baseLoc + "serialized/parsed";
88
-
89
-
public loc statsDir = baseLoc + "serialized/stats";
90
-
91
-
public loc corpusRoot = baseLoc + "systems";
92
-
93
-
public loc countsDir = baseLoc + "serialized/counts";
94
-
95
-
public bool useBinaries = false;
96
-
97
-
public bool includePhpDocs = false;
98
-
public bool includeLocationInfo = false;
99
-
public bool resolveNamespaces = false;
100
-
101
-
public int logLevel = 2;
71
+
# Main PHP Analysis configuration settings.
72
+
php-air:
73
+
# The location of the PHP executable in Rascal location format.
74
+
phpLoc: "file:///opt/homebrew/bin/php"
75
+
# The debugging level for log statements.
76
+
# 0 means disable logging
77
+
# 1 means typical logging statements
78
+
# 2 means debug-level logging
79
+
logLevel: 2
80
+
# The location of the cloc tool, used for source lines of code,
81
+
# in Rascal location format.
82
+
clocLoc: "file:///opt/homebrew/bin/cloc"
83
+
84
+
# Settings related to parsing PHP code.
85
+
parsing:
86
+
# Indicates whether to use the parser contained in a distributed jar
87
+
# file or from the directory given as parserLoc. By default, this should
88
+
# be false unless you have such a file (e.g., a Java-based parsing library
89
+
# for PHP).
90
+
usePhpParserJar: false
91
+
# The base install location for the PHP-Parser project, in Rascal location format.
0 commit comments