Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.5%) to scientific vocabulary
Repository
PHP language analyses in Rascal
Basic Info
Statistics
- Stars: 28
- Watchers: 7
- Forks: 8
- Open Issues: 7
- Releases: 2
Metadata Files
README.md
Introduction
This repository contains our ongoing work on PHP Analysis in Rascal (PHP AiR).
Running Our Software
The main prerequisites to running the PHP, Java, and Rascal code used to implement our analysis are:
- Java JDK version 17: Java 11 is available from the Java download page. We recommend using the Eclipse Temurin release to avoid any licensing issues.
- PHP version 8: Although you can download the sourcecode for PHP from the PHP download page, it's often easier to use a precompiled version. For macOS, you can use Homebrew and the Homebrew PHP Formula to easily install a working version of PHP. For Windows, 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.
To edit and run Rascal code, please see the relevant information in the online Rascal documentation. You can use the command line, Eclipse, or VScode (recommended). All included code should work with the newest release of Rascal.
To parse PHP code, we are using a fork of an open-source PHP Parser. This is also available in our Github repository, and is named PHP-Parser. You will want to clone this project to a convenient location.
Using PHP AiR Directly
The PHP AiR code can be used directly, without creating another project. For instance, if you are trying to build a new analysis for PHP, and would like that to be incorporated directly into PHP AiR, it would make the most sense to add the analysis directly into this project. To do so, you can open/run the code in this project directly, e.g., by opening the project in VScode and running the code using a Rascal terminal. You will want to configure PHP AiR as described below, so it knows where to find the systems being analyzed and the PHP parser.
Using PHP AiR as a Maven Dependency
You can also use PHP AiR as a Maven dependency. This is the best alternative if you are creating a tool or analysis that will be kept separate from PHP AiR (that will evolve on its own, outside of the main PHP AiR project). An example is this work on feature evolution. To do this, you will want to create a new Rascal project, and then add the needed dependency for PHP AiR. This is done in two places. First, in META-INF/RASCAL.MF, you will want to add the PHP AiR project as a required library. An example of this is in the feature evolution work mentioned above:
Project-Name: feature-evolution
Source: src/main/rascal
Require-Libraries: |lib://php-analysis|
Second, you will want to add PHP AiR as a plugin dependency in the pom.xml file. This looks like the following:
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>php-analysis</artifactId>
<version>0.3.1</version>
</dependency>
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.
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.
Configuring PHP AiR
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.
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).
```
Main PHP Analysis configuration settings.
php-air: # The location of the PHP executable in Rascal location format. phpLoc: "file:///opt/homebrew/bin/php" # The debugging level for log statements. # 0 means disable logging # 1 means typical logging statements # 2 means debug-level logging logLevel: 2 # The location of the cloc tool, used for source lines of code, # in Rascal location format. clocLoc: "file:///opt/homebrew/bin/cloc"
Settings related to parsing PHP code.
parsing: # Indicates whether to use the parser contained in a distributed jar # file or from the directory given as parserLoc. By default, this should # be false unless you have such a file (e.g., a Java-based parsing library # for PHP). usePhpParserJar: false # The base install location for the PHP-Parser project, in Rascal location format. parserLoc: "file:///Users/hillsma/Projects/php-analysis/PHP-Parser" # The memory limit for PHP when the parser is run. This may need to # be increased if the parser runs out of memory, e.g., because of an # especially large or deeply-nested script. parserMemLimit: "1024M" # The name of the AST to Rascal conversion script. This should not be # modified unless you have created your own version of this. astToRascal: "AST2Rascal.php" # The working directory for when the parser runs, in Rascal location format. parserWorkingDir: "file:///Users/hillsma/Projects/php-analysis/PHP-Parser"
Analysis-related settings.
analysis: # The base location for the corpus and any serialized files, in Rascal # location format. You would normally put code to analyze under this folder, # but this isn't required. Any serialized data will be stored under this folder. baseLoc: "home:///PHPAnalysis" # The base install location for the php-analysis project. This is only # needed if you are working directly on the project, versus using it as # a dependency, since this is needed to run tests. This is given in # Rascal location format. analysisLoc: "file:///Users/hillsma/Projects/php-analysis/php-analysis/" # Where to put the binary representations of parsed systems, in Rascal # location format. parsedDir: "home:///PHPAnalysis/serialized/parsed" # Where to put the binary representations of extracted statistics, in # Rascal location format. statsDir: "home:///PHPAnalysis/serialized/stats" # Where to put extracted counts (e.g., SLOC), in Rascal location format. countsDir: "home:///PHPAnalysis/serialized/counts" # Where the PHP sources for the corpus reside. This is for systems given # with each system version in a separate directory. This is in Rascal # location format. corpusRoot: "home:///PHPAnalysis/systems" # This should only ever be true if we don't have source, i.e., we only have the # extracted binaries for parsed systems. This should normally be false. useBinaries: false ```
The configurable values in this file are as follows:
phplocpoints to the location of the php binarylogLevelindicates how much debugging information will be seen, and can be set to 0 to turn output of this information offclocLocis the location of thecloctool, which is used to compute metrics about source codeusePhpParserJarshould generally befalse, and is mainly present for historical reasonsparserLocpoints to the location of the PHP-Parser projectparserMemoryLimitgives the memory limit value to pass to PHP, and can be increased if the parser is running out of memoryastToRascalshould not be changed unless a file other thanAST2Rascal.phpis being used to build Rascal ASTsparserWorkingDirpoints to the location of the working directory for when the parser runsbaseLocprovides the base location for a number of files created as part of the parsing and extraction process, including the directory where parsed files are stored and the root of the corpus; the remaining directories are subdirectories of thisanalysisLocpoints to the location of the php-analysis project itselfparsedDirindicates where serialized versions of parsed PHP systems should be storedstatsDircontains computed stats for PHP systemscountsDircontains computed counts for PHP systemscorpusRootis the location of the systems under analysis; systems do not need to be stored there, but this allows some of the built-in functionality for counting, finding, and parsing systems to be useduseBinariesshould generally befalse, and is only needed when you have the serialized parse trees but no longer have access to the source code you want to analyze
To check to ensure that the directories are properly set up, you can run the following:
import lang::php::util::Utils;
checkConfiguration();
This will run several checks to make sure the directories can be found and that the parser can parse a simple PHP expression.
Parsing Older Code
We currently support PHP code up to version 8, including new features such
as nullable annotations on types and property hooks. Because of the evolution of the language,
some older code does not parse, though, which means those scripts will be
represented as a special type of error script using the errscript
Script constructor. The main issues we are aware of are the following:
Code in PHP version 4 often captured a reference to created objects, e.g., (from phpBB version 3.0.9)
$instance =& new phpbb_captcha_qa();. Starting in PHP 5, new objects are automatically treated as references, so this syntax (using&to capture the reference) was deprecated, and is now no longer supported.Some early PHP code, like early versions of MediaWiki, use
namespaceas an identifier. This is now a keyword to declare a namespace in PHP.Some PHP code used
matchorMATCHas names, which is no longer supported with the addition of thematchexpression.
If we find other common issues we will add them here.
Reorganization
This code is currently being reorganized to make it easier to use as a dependency in your own PHP analysis projects. Because of this, we are moving earlier experiments into their own projects. Links to those projects will be added soon. They can be helpful if you are trying to figure out how to do something similar to what we have done in the past.
Owner
- Name: CWI - Software Analysis and Transformation
- Login: cwi-swat
- Kind: organization
- Location: Amsterdam
- Website: https://www.cwi.nl/research/groups/software-analysis-and-transformation
- Repositories: 186
- Profile: https://github.com/cwi-swat
Citation (CITATION.md)
This is software will be directly citable via Zenodo soon. However, these are relevant publications
that you can cite in the mean time:
```bibtex
@article{DBLP:journals/scp/HillsKV17,
author = {Mark Hills and
Paul Klint and
Jurgen J. Vinju},
title = {Enabling {PHP} software engineering research in Rascal},
journal = {Sci. Comput. Program.},
volume = {134},
pages = {37--46},
year = {2017},
url = {https://doi.org/10.1016/j.scico.2016.05.003},
doi = {10.1016/j.scico.2016.05.003},
timestamp = {Wed, 14 Jun 2017 20:29:38 +0200},
biburl = {https://dblp.org/rec/journals/scp/HillsKV17.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/scam/Anderson017,
author = {David Anderson and
Mark Hills},
title = {Supporting Analysis of {SQL} Queries in {PHP} AiR},
booktitle = {17th {IEEE} International Working Conference on Source Code Analysis
and Manipulation, {SCAM} 2017, Shanghai, China, September 17-18, 2017},
pages = {153--158},
publisher = {{IEEE} Computer Society},
year = {2017},
url = {https://doi.org/10.1109/SCAM.2017.23},
doi = {10.1109/SCAM.2017.23},
timestamp = {Fri, 24 Mar 2023 00:02:43 +0100},
biburl = {https://dblp.org/rec/conf/scam/Anderson017.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/wcre/AndersonH17,
author = {David Anderson and
Mark Hills},
editor = {Martin Pinzger and
Gabriele Bavota and
Andrian Marcus},
title = {Query Construction Patterns in {PHP}},
booktitle = {{IEEE} 24th International Conference on Software Analysis, Evolution
and Reengineering, {SANER} 2017, Klagenfurt, Austria, February 20-24,
2017},
pages = {452--456},
publisher = {{IEEE} Computer Society},
year = {2017},
url = {https://doi.org/10.1109/SANER.2017.7884652},
doi = {10.1109/SANER.2017.7884652},
timestamp = {Fri, 24 Mar 2023 00:04:44 +0100},
biburl = {https://dblp.org/rec/conf/wcre/AndersonH17.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/iwpc/Hills16,
author = {Mark Hills},
title = {Navigating the WordPress plugin landscape},
booktitle = {24th {IEEE} International Conference on Program Comprehension, {ICPC}
2016, Austin, TX, USA, May 16-17, 2016},
pages = {1--10},
publisher = {{IEEE} Computer Society},
year = {2016},
url = {https://doi.org/10.1109/ICPC.2016.7503709},
doi = {10.1109/ICPC.2016.7503709},
timestamp = {Thu, 23 Mar 2023 23:57:51 +0100},
biburl = {https://dblp.org/rec/conf/iwpc/Hills16.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/kbse/Hills15,
author = {Mark Hills},
editor = {Myra B. Cohen and
Lars Grunske and
Michael Whalen},
title = {Variable Feature Usage Patterns in {PHP} {(T)}},
booktitle = {30th {IEEE/ACM} International Conference on Automated Software Engineering,
{ASE} 2015, Lincoln, NE, USA, November 9-13, 2015},
pages = {563--573},
publisher = {{IEEE} Computer Society},
year = {2015},
url = {https://doi.org/10.1109/ASE.2015.72},
doi = {10.1109/ASE.2015.72},
timestamp = {Fri, 24 Mar 2023 00:02:37 +0100},
biburl = {https://dblp.org/rec/conf/kbse/Hills15.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/oopsla/Hills15,
author = {Mark Hills},
editor = {Harry Xu and
Walter Binder},
title = {Supporting {PHP} dynamic analysis in {PHP} AiR},
booktitle = {Proceedings of the 13th International Workshop on Dynamic Analysis,
WODA@SPLASH 2015, Pittsburgh, PA, USA, October 26, 2015},
pages = {37--38},
publisher = {{ACM}},
year = {2015},
url = {https://doi.org/10.1145/2823363.2823373},
doi = {10.1145/2823363.2823373},
timestamp = {Fri, 14 Apr 2023 23:05:46 +0200},
biburl = {https://dblp.org/rec/conf/oopsla/Hills15.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/wcre/000115,
author = {Mark Hills},
editor = {Yann{-}Ga{\"{e}}l Gu{\'{e}}h{\'{e}}neuc and
Bram Adams and
Alexander Serebrenik},
title = {Evolution of dynamic feature usage in {PHP}},
booktitle = {22nd {IEEE} International Conference on Software Analysis, Evolution,
and Reengineering, {SANER} 2015, Montreal, QC, Canada, March 2-6,
2015},
pages = {525--529},
publisher = {{IEEE} Computer Society},
year = {2015},
url = {https://doi.org/10.1109/SANER.2015.7081870},
doi = {10.1109/SANER.2015.7081870},
timestamp = {Fri, 24 Mar 2023 00:04:45 +0100},
biburl = {https://dblp.org/rec/conf/wcre/000115.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/csmr/HillsK14,
author = {Mark Hills and
Paul Klint},
editor = {Serge Demeyer and
Dave W. Binkley and
Filippo Ricca},
title = {{PHP} AiR: Analyzing {PHP} systems with Rascal},
booktitle = {2014 Software Evolution Week - {IEEE} Conference on Software Maintenance,
Reengineering, and Reverse Engineering, {CSMR-WCRE} 2014, Antwerp,
Belgium, February 3-6, 2014},
pages = {454--457},
publisher = {{IEEE} Computer Society},
year = {2014},
url = {https://doi.org/10.1109/CSMR-WCRE.2014.6747217},
doi = {10.1109/CSMR-WCRE.2014.6747217},
timestamp = {Fri, 24 Mar 2023 00:02:40 +0100},
biburl = {https://dblp.org/rec/conf/csmr/HillsK14.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/kbse/HillsKV14,
author = {Mark Hills and
Paul Klint and
Jurgen J. Vinju},
editor = {Ivica Crnkovic and
Marsha Chechik and
Paul Gr{\"{u}}nbacher},
title = {Static, lightweight includes resolution for {PHP}},
booktitle = {{ACM/IEEE} International Conference on Automated Software Engineering,
{ASE} '14, Vasteras, Sweden - September 15 - 19, 2014},
pages = {503--514},
publisher = {{ACM}},
year = {2014},
url = {https://doi.org/10.1145/2642937.2643017},
doi = {10.1145/2642937.2643017},
timestamp = {Tue, 06 Nov 2018 16:58:23 +0100},
biburl = {https://dblp.org/rec/conf/kbse/HillsKV14.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
```bibtex
@inproceedings{DBLP:conf/issta/HillsKV13,
author = {Mark Hills and
Paul Klint and
Jurgen J. Vinju},
editor = {Mauro Pezz{\`{e}} and
Mark Harman},
title = {An empirical study of {PHP} feature usage: a static analysis perspective},
booktitle = {International Symposium on Software Testing and Analysis, {ISSTA}
'13, Lugano, Switzerland, July 15-20, 2013},
pages = {325--335},
publisher = {{ACM}},
year = {2013},
url = {https://doi.org/10.1145/2483760.2483786},
doi = {10.1145/2483760.2483786},
timestamp = {Sun, 02 Oct 2022 16:10:12 +0200},
biburl = {https://dblp.org/rec/conf/issta/HillsKV13.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
GitHub Events
Total
- Watch event: 1
- Issue comment event: 6
- Push event: 8
- Pull request event: 6
- Create event: 2
- Commit comment event: 2
Last Year
- Watch event: 1
- Issue comment event: 6
- Push event: 8
- Pull request event: 6
- Create event: 2
- Commit comment event: 2
Dependencies
- org.rascalmpl:rascal 0.28.3
- SWAT-engineering/maven-full-artifacts-action v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/setup-java v1 composite
- softprops/action-gh-release v1 composite
- usethesource/releases-maven-action v1 composite