Skip to content

Commit

Permalink
Bump PHP version (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
KennedyTedesco authored Dec 14, 2024
1 parent 2959002 commit b67ec5d
Show file tree
Hide file tree
Showing 29 changed files with 184 additions and 154 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4'
tools: composer:v2
coverage: none
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=256M
- name: Install Dependencies
run: composer update --no-interaction --no-progress
- name: Run Tests
Expand Down
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p style="text-align: center">
<img src="resources/monkey-php.png?raw=true" alt="Monkey Programming Language">
</p>
<div align="center">
<img src="resources/monkey-php-logo.svg?raw=true" alt="Monkey Programming Language">
</div>

## Monkey Programming Language

Expand Down Expand Up @@ -133,32 +133,26 @@ The steps are:
<img src="resources/how-it-works.png?raw=true" alt="How it works">
</p>

### Running with Docker (PHP ^8.1)

Pull the docker image:

```bash
docker pull php:8.2-cli
```
### Running with Docker (PHP ^8.4)

Running the tests:

```bash
docker run --rm -v $(pwd):/monkey -w /monkey php:8.2-cli ./vendor/bin/pest
docker run --rm -v $(pwd):/monkey -w /monkey php:8.4-cli ./vendor/bin/pest
```

Running from a file contents of the examples folder:

```bash
docker run --rm -v (pwd):/monkey -w /monkey php:8.2-cli ./monkey run examples/fibo_while.monkey
docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey run examples/fibo_while.monkey
```

### Using the REPL

Clone this repository, execute `composer install`, then:

```bash
docker run --rm -v (pwd):/monkey -w /monkey php:8.2-cli ./monkey repl
docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey repl
```

Example:
Expand Down Expand Up @@ -186,7 +180,7 @@ Example:
Or, if you want to execute a file:

```bash
docker run --rm -v (pwd):/monkey -w /monkey php:8.2-cli ./monkey run examples/closure.monkey
docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey run examples/closure.monkey
```

### Contributing
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"description": "Monkey Programming Language",
"license": "MIT",
"require-dev": {
"laravel/pint": "^1.12",
"pestphp/pest": "^2.16.1",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.32",
"rector/rector": "^0.18.1"
"laravel/pint": "^1.18.3",
"pestphp/pest": "^v3.7.1",
"phpstan/phpstan": "^2.0.3",
"rector/rector": "^2.0.3"
},
"require": {
"php": "^8.2"
"php": "^8.4"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 0 additions & 3 deletions examples/fibo_recursive.monkey
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// In this implementation, we use a recursive function to calculate the nth Fibonacci number, but this is the slowest way to do it (in this parser).
// The fibo_while.monkey implementation is much faster.

let fibonacci = fn(x) {
if (x == 0 || x == 1) {
return x;
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ parameters:
paths:
- src
level: max
checkMissingIterableValueType: true
inferPrivatePropertyTypeFromConstructor: true
checkUninitializedProperties: true
30 changes: 25 additions & 5 deletions pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"rules": {
"@Symfony": true,
"@Symfony:risky": true,
"protected_to_private": false,
"array_push": true,
"backtick_to_shell_exec": true,
"protected_to_private": true,
"no_unused_imports": true,
"trailing_comma_in_multiline": {
"elements": [
"arrays",
Expand Down Expand Up @@ -65,7 +68,7 @@
"method_argument_space": {
"on_multiline": "ensure_fully_multiline"
},
"method_chaining_indentation": false,
"method_chaining_indentation": true,
"modernize_types_casting": true,
"multiline_comment_opening_closing": true,
"multiline_whitespace_before_semicolons": true,
Expand Down Expand Up @@ -103,13 +106,27 @@
"ordered_class_elements": {
"order": [
"use_trait",
"case",
"constant",
"constant_public",
"constant_protected",
"constant_private",
"property_public",
"property_protected",
"property_private"
]
"property_private",
"construct",
"destruct",
"magic",
"phpunit",
"method_abstract",
"method_public_static",
"method_public",
"method_protected_static",
"method_protected",
"method_private_static",
"method_private"
],
"sort_algorithm": "none"
},
"ordered_imports": {
"imports_order": [
Expand Down Expand Up @@ -151,7 +168,7 @@
"simplified_null_return": false,
"single_class_element_per_statement": true,
"single_line_throw": false,
"single_quote": false,
"single_quote": true,
"single_trait_insert_per_statement": true,
"space_after_semicolon": {
"remove_in_empty_for_expressions": true
Expand All @@ -172,6 +189,9 @@
"identical": false,
"less_and_greater": false
},
"ordered_traits": true,
"ordered_interfaces": true,
"strict_comparison": true,
"no_multiline_whitespace_around_double_arrow": false
}
}
48 changes: 26 additions & 22 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@

declare(strict_types=1);

use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->removeUnusedImports();
$rectorConfig->importShortClasses();

$rectorConfig->autoloadPaths([
return RectorConfig::configure()
->withIndent()
->withParallel()
->withImportNames(
removeUnusedImports: true,
)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true,
rectorPreset: true,
)
->withPhpPolyfill()
->withSets([
LevelSetList::UP_TO_PHP_84,
])
->withSkip([
EncapsedStringsToSprintfRector::class,
])
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
]);

$rectorConfig->import(SetList::CODE_QUALITY);
$rectorConfig->import(SetList::EARLY_RETURN);
$rectorConfig->import(SetList::TYPE_DECLARATION);
$rectorConfig->import(LevelSetList::UP_TO_PHP_82);
$rectorConfig->import(SetList::DEAD_CODE);
$rectorConfig->import(SetList::STRICT_BOOLEANS);
$rectorConfig->import(SetList::INSTANCEOF);
};
1 change: 1 addition & 0 deletions resources/monkey-php-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/monkey-php.png
Binary file not shown.
Binary file removed resources/monkey-php.psd
Binary file not shown.
Loading

0 comments on commit b67ec5d

Please sign in to comment.