Merge pull request #31 from chitoku-k/patch-1 · php-java/php-java@5f7bd7a
@@ -7,11 +7,11 @@
77<p align="center"><img src="./docs/img/phpjava.jpg" height="300"></p>
8899# What is the PHPJava?
10-The PHPJava is experimental library which emulate JVM (a.k.a. Java Virtual Machine) by PHP 🐘
11-The PHPJava proceed to read binary from pre-compiled Java file(s) ☕
12-This project reference to [Java Virtual Machine Specification](https://docs.oracle.com/javase/specs/jvms/se11/html/index.html) documentation when We makes.
10+The PHPJava is an experimental library which emulates JVM (a.k.a. Java Virtual Machine) by PHP 🐘
11+The PHPJava reads binary from pre-compiled Java file(s) ☕
12+This project referred to [Java Virtual Machine Specification](https://docs.oracle.com/javase/specs/jvms/se11/html/index.html) documentation at the time we made it.
131314-We welcoming to contributions this project 💪
14+We are welcoming any contributions to this project 💪
15151616## Requirements
1717- PHP >= 7.2
@@ -27,12 +27,12 @@ Sorry, I do not have enough time (T_T)
2727- etc...
28282929## Quick start
30-- 1) Install the PHPJava into your project.
30+- 1) Install the PHPJava into your project:
3131```
3232$ composer require memory-agape/php-java
3333```
343435-- 2) Write Java
35+- 2) Write Java:
3636```java
3737class HelloWorld
3838{
@@ -43,12 +43,12 @@ class HelloWorld
4343}
4444```
454546-- 3) Compile Java
46+- 3) Compile Java:
4747```
4848$ javac -UTF8 /path/to/HelloWorld.java
4949```
505051-- 4) Call to main method as following.
51+- 4) Call the main method as follows:
52525353```php
5454<?php
@@ -65,21 +65,21 @@ use PHPJava\Core\JavaClassFileReader;
6565 );
6666```
676768-- 5) Get a result
68+- 5) Get the result
6969```
7070$ php /path/to/HelloWorld.php
7171Hello World
7272```
73737474## Java Archive (Execute to *.jar file)
757576-- 1) Build your java files to class. Building example is below.
76+- 1) Build your Java files to class. An example is shown below:
7777```
7878$ javac -encoding UTF8 -d build src/*
7979$ cd build && jar -cvfe ../Test.jar Test *
8080```
818182-- 2) execute jar on PHPJava with enrtypoint or your targeted method.
82+- 2) Execute jar on PHPJava with either an enrtypoint or your targeted method.
8383```php
8484<?php
8585use PHPJava\Core\JavaArchive;
@@ -98,9 +98,9 @@ use PHPJava\Core\JavaArchive;
9898 );
9999```
100100101-### Get/Set a static fields
101+### Get/Set static fields
102102103-- ex) Set or Get a static fields as follows.
103+- ex) Set or Get static fields as follows:
104104105105```php
106106<?php
@@ -119,9 +119,9 @@ $staticFieldAccessor->set('fieldName', 'value');
119119echo $staticFieldAccessor->get('fieldName');
120120```
121121122-### Call to a static method
122+### Call a static method
123123124-- ex) Call to static method as follows.
124+- ex) Call a static method as follows:
125125126126```php
127127<?php
@@ -158,10 +158,10 @@ echo $result;
158158```
159159160160161-### Get/Set a dynamic fields
162-If you want to get/set dynamic fields, you need call to `construct` method on Java by PHPJava.
161+### Get/Set dynamic fields
162+If you want to get/set dynamic fields, you need to call the `construct` method on Java by PHPJava.
163163164-- ex) Call dynamic field as following.
164+- ex) Call dynamic field as follows:
165165166166```php
167167<?php
@@ -184,10 +184,10 @@ $dynamicFieldAccessor->set('fieldName', 'value');
184184echo $dynamicFieldAccessor->get('fieldName');
185185```
186186187-### Call to a dynamic method
188-If you want to get/set dynamic method (same as field), you need call to `construct` method on Java by PHPJava.
187+### Call a dynamic method
188+If you want to get/set dynamic method (same as a field), you need to call the `construct` method on Java by PHPJava.
189189190-- ex) Call dynamic method as following.
190+- ex) Call dynamic method as follows:
191191192192```php
193193<?php
@@ -225,7 +225,7 @@ echo $result;
225225226226### Output PHPJava operations
227227228-- Output debug trace as following if you want to show operated log.
228+- Output debug trace as follows if you want to show operation log:
229229230230```php
231231<?php
@@ -247,7 +247,7 @@ $javaClass
247247$javaClass->debug();
248248```
249249250-- Outputted debug trace is below.
250+- Output debug trace is shown below:
251251252252```
253253[method]
@@ -279,22 +279,22 @@ public static void main(java.lang.String[])
279279---------+--------+----------------------+------------+-----------------
280280```
281281282-- **[method]** is showing called method.
283-- **[code]** is showing JVM's real programs.
284-- **[executed]** is showing executed programs.
285-- **PC** is showing Program Counter.
286-- **OPCODE** is showing Operation Codes.
287-- **MNEMONIC** is naming Operation Codes.
288-- **OPERANDS** is showing stacked items on memory.
289-- **LOCAL STORAGE** is showing stacked items on a method.
282+- **[method]** shows the called method.
283+- **[code]** shows the JVM's real programs.
284+- **[executed]** shows the executed programs.
285+- **PC** shows the Program Counter.
286+- **OPCODE** shows the Operation Codes.
287+- **MNEMONIC** shows the names of the Operation Codes.
288+- **OPERANDS** shows the stacked items on memory.
289+- **LOCAL STORAGE** shows the stacked items on a method.
290290291291## PHP problems
292-- **Problem 1:** The PHP is cannot calculating big numbers because of PHP is different to the Java.
293- But the PHPJava use `bcmath` functions and `gmp` functions to a certain extent to cover to calculate.
294-The PHPJava return valued is mixed why therefore We recommend to cast to `string` on the PHPJava.
292+- **Problem 1:** PHP cannot calculate big numbers because PHP is different from Java.
293+ But PHPJava uses `bcmath` functions and `gmp` functions to a certain extent to cover such calculations.
294+Therefore, PHPJava returns a mixed value and we recommend to cast them to `string` on PHPJava.
295295296-- **Problem 2:** The PHPJava cannot cover to Java's types completely because of PHP is different to the Java.
297- The Java and the PHPJava comparison table is below.
296+- **Problem 2:** PHPJava cannot completely cover Java types because PHP is different from Java.
297+ The comparison table of Java and PHPJava is shown below:
298298299299|Java |PHPJava |
300300|:-------------:|:-------------:|
@@ -308,23 +308,22 @@ public static void main(java.lang.String[])
308308|float |\PHPJava\Kernel\Types\\_Float (including `__toString`), string, float |
309309|double |\PHPJava\Kernel\Types\\_Char (including `__toString`), string, float |
310310311-- **Problem 3:** The PHPJava cannot calculate big numbered `double` and `float` values because of `gmp_pow` cannot calculate negative exponents.
312- So the PHPJava use built-in functions which is `pow`.
311+- **Problem 3:** PHPJava cannot calculate big number of `double` and `float` because `gmp_pow` cannot calculate negative exponents. So, PHPJavas use built-in function `pow`.
313312314313## Run unit tests
315314316-- PHPUnit test is below.
315+- To run a PHPUnit test:
317316```
318317$ ./vendor/bin/phpunit tests
319318```
320319321-- PHP Coding standards testing is below.
320+- To run PHP Coding standards test:
322321323322```
324323$ ./vendor/bin/phpcs --standard=phpcs.xml src
325324```
326325327-- All testing is below.
326+- To run all tests:
328327329328```
330329$ composer run tests
@@ -334,4 +333,4 @@ $ composer run tests
334333- [Java Virtual Machine Specification](https://docs.oracle.com/javase/specs/jvms/se11/html/index.html)
335334336335## License
337-MIT
336+MIT