Skip to content

Commit 9f7d7e1

Browse files
committed
PHP 8.2 upgrade
1 parent 1827d2e commit 9f7d7e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+82
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea/

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# CoffeeScript PHP
22

3-
A port of the [CoffeeScript](http://jashkenas.github.com/coffee-script/)
4-
compiler to PHP.
3+
A port of the [CoffeeScript](http://jashkenas.github.com/coffee-script/) compiler to PHP.
4+
5+
Updating compatibility up to PHP 8.2.
56

67
## Status
78

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.0.0"
16+
"php": ">=8.0.0"
1717
},
1818
"autoload": {
1919
"psr-0": {

src/CoffeeScript/Helpers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class Helpers {
1111
* with their parent class's. This workaround is used to silence E_STRICT
1212
* errors.
1313
*
14-
* @param $args `func_get_args()`
15-
* @param $required The number of required arguments.
16-
* @param $optional An array of defaults for optional arguments.
14+
* @param array $args `func_get_args()`
15+
* @param mixed $required The number of required arguments.
16+
* @param array $optional An array of defaults for optional arguments.
1717
*/
1818
static function args(array $args, $required, array $optional = NULL)
1919
{

src/CoffeeScript/Lexer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* source code, though there are some relatively minor differences in how it
1010
* works with the parser (since we're using Lemon).
1111
*/
12+
#[\AllowDynamicProperties]
1213
class Lexer
1314
{
1415
static $COFFEE_ALIASES = array(

src/CoffeeScript/Parser.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class yyToken implements ArrayAccess
1717
public $string = '';
1818
public $metadata = array();
1919

20-
function __construct($s, $m = array())
20+
public function __construct($s, $m = array())
2121
{
2222
if ($s instanceof yyToken) {
2323
$this->string = $s->string;
@@ -32,22 +32,22 @@ function __construct($s, $m = array())
3232
}
3333
}
3434

35-
function __toString()
35+
public function __toString()
3636
{
3737
return $this->string;
3838
}
3939

40-
function offsetExists($offset)
40+
public function offsetExists(mixed $offset): bool
4141
{
4242
return isset($this->metadata[$offset]);
4343
}
4444

45-
function offsetGet($offset)
45+
public function offsetGet(mixed $offset): mixed
4646
{
4747
return $this->metadata[$offset];
4848
}
4949

50-
function offsetSet($offset, $value)
50+
public function offsetSet(mixed $offset, mixed $value): void
5151
{
5252
if ($offset === null) {
5353
if (isset($value[0])) {
@@ -70,7 +70,7 @@ function offsetSet($offset, $value)
7070
}
7171
}
7272

73-
function offsetUnset($offset)
73+
public function offsetUnset(mixed $offset): void
7474
{
7575
unset($this->metadata[$offset]);
7676
}
@@ -1945,7 +1945,6 @@ static function yy_destructor($yymajor, $yypminor)
19451945
* is popped from the stack, then call it.
19461946
*
19471947
* Return the major token number for the symbol popped.
1948-
* @param yyParser
19491948
* @return int
19501949
*/
19511950
function yy_pop_parser_stack()
@@ -2024,7 +2023,7 @@ function yy_get_expected_tokens($token)
20242023
if ($nextstate < self::YYNSTATE) {
20252024
// we need to shift a non-terminal
20262025
$this->yyidx++;
2027-
$x = new yyStackEntry;
2026+
$x = new yyStackEntry();
20282027
$x->stateno = $nextstate;
20292028
$x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
20302029
$this->yystack[$this->yyidx] = $x;
@@ -2098,7 +2097,7 @@ function yy_is_expected_token($token)
20982097
if ($nextstate < self::YYNSTATE) {
20992098
// we need to shift a non-terminal
21002099
$this->yyidx++;
2101-
$x = new yyStackEntry;
2100+
$x = new yyStackEntry();
21022101
$x->stateno = $nextstate;
21032102
$x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
21042103
$this->yystack[$this->yyidx] = $x;
@@ -2228,7 +2227,7 @@ function yy_shift($yyNewState, $yyMajor, $yypMinor)
22282227
** stack ever overflows */
22292228
return;
22302229
}
2231-
$yytos = new yyStackEntry;
2230+
$yytos = new yyStackEntry();
22322231
$yytos->stateno = $yyNewState;
22332232
$yytos->major = $yyMajor;
22342233
$yytos->minor = $yypMinor;
@@ -3104,7 +3103,7 @@ function yy_reduce($yyruleno)
31043103
** That gives a significant speed improvement. */
31053104
if (!self::$yyTraceFILE && $yysize) {
31063105
$this->yyidx++;
3107-
$x = new yyStackEntry;
3106+
$x = new yyStackEntry();
31083107
$x->stateno = $yyact;
31093108
$x->major = $yygoto;
31103109
$x->minor = $yy_lefthand_side;
@@ -3195,7 +3194,7 @@ function parse($token)
31953194
/* if ($yymajor == 0) return; // not sure why this was here... */
31963195
$this->yyidx = 0;
31973196
$this->yyerrcnt = -1;
3198-
$x = new yyStackEntry;
3197+
$x = new yyStackEntry();
31993198
$x->stateno = 0;
32003199
$x->major = 0;
32013200
$this->yystack = array();

src/CoffeeScript/Rewriter.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
Init::init();
66

7+
#[\AllowDynamicProperties]
78
class Rewriter
89
{
910
static $BALANCED_PAIRS = array(
@@ -52,7 +53,7 @@ static function init()
5253

5354
foreach (self::$BALANCED_PAIRS as $pair)
5455
{
55-
list($left, $rite) = $pair;
56+
[$left, $rite] = $pair;
5657

5758
self::$EXPRESSION_START[] = self::$INVERSES[$rite] = $left;
5859
self::$EXPRESSION_END[] = self::$INVERSES[$left] = $rite;
@@ -88,7 +89,7 @@ function add_implicit_braces()
8889
$list[$j] = isset($self->tokens[$k]) ? $self->tokens[$k] : array(NULL, NULL);
8990
}
9091

91-
list($one, $two, $three) = $list;
92+
[$one, $two, $three] = $list;
9293

9394
if ($one[0] === t('HERECOMMENT'))
9495
{
@@ -209,7 +210,7 @@ function add_implicit_indentation()
209210
! ($tag === t('ELSE') && $self->tag($i + 1) === t('IF')))
210211
{
211212
$starter = $tag;
212-
list($indent, $outdent) = $self->indentation($token, TRUE);
213+
[$indent, $outdent] = $self->indentation($token, TRUE);
213214

214215
if ($starter === t('THEN'))
215216
{

src/CoffeeScript/Scope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/**
88
* Lexical scope manager.
99
*/
10+
#[\AllowDynamicProperties]
1011
class Scope
1112
{
1213
static $root = NULL;

src/CoffeeScript/Value.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
Init::init();
66

7+
#[\AllowDynamicProperties]
78
class Value
89
{
910
function __construct($v)

src/CoffeeScript/yy/Access.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace CoffeeScript;
44

5+
#[\AllowDynamicProperties]
56
class yy_Access extends yy_Base
67
{
78
public $children = array('name');

0 commit comments

Comments
 (0)