Skip to content
Closed

Hax #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/configure-x32/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ runs:
--enable-option-checking=fatal \
--build=i686-pc-linux-gnu \
--prefix=/usr \
--enable-address-sanitizer \
--enable-undefined-sanitizer \
--enable-phpdbg \
--enable-fpm \
--enable-intl \
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/test-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ runs:
--offline \
--show-diff \
--show-slow 1000 \
--set-timeout 120
--set-timeout 120 \
ext/reflection Zend/tests
- uses: actions/upload-artifact@v3
if: always() && inputs.testArtifacts != null
with:
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/magic_methods_021.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Foo2 {
}

class Foo3 {
public static function __set_state(array $data): Foo3|self {}
public static function __set_state(array $data): Foo3|Foo2 {}
}

?>
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions Zend/tests/traits/trait_parent_type_in_class_no_parent.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Cannot use a trait which references parent as a type in a class with no parent, single type
--FILE--
<?php
trait TraitExample {
public function bar(): parent { return parent::class; }
}

class A {
use TraitExample;
}
?>
--EXPECTF--
Fatal error: Cannot use trait which has "parent" as a type when current class scope has no parent in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Cannot use a trait which references parent as a type in a class with no parent, nullable type
--FILE--
<?php
trait TraitExample {
public function bar(): ?parent { return parent::class; }
}

class A {
use TraitExample;
}
?>
--EXPECTF--
Fatal error: Cannot use trait which has "parent" as a type when current class scope has no parent in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Cannot use a trait which references parent as a type in a class with no parent, union type
--FILE--
<?php
trait TraitExample {
public function bar(): int|parent { return parent::class; }
}

class A {
use TraitExample;
}
?>
--EXPECTF--
Fatal error: Cannot use trait which has "parent" as a type when current class scope has no parent in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Cannot use a trait which references parent as a type in a class with no parent, DNF type
--FILE--
<?php
trait TraitExample {
public function bar(): (X&Y)|parent { return parent::class; }
}

class A {
use TraitExample;
}
?>
--EXPECTF--
Fatal error: Cannot use trait which has "parent" as a type when current class scope has no parent in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Cannot use parent type outside a class
--FILE--
<?php

function foo($x): parent {};

?>
--EXPECTF--
Fatal error: Cannot use "parent" when no class scope is active in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Cannot use self type outside a class
--FILE--
<?php

function foo($x): self {};

?>
--EXPECTF--
Fatal error: Cannot use "self" when no class scope is active in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Cannot use static type outside a class
--FILE--
<?php

function foo($x): static {};

?>
--EXPECTF--
Fatal error: Cannot use "static" when no class scope is active in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Relative class types can be used for closures as it may be bound to a class
--FILE--
<?php

$fn1 = function($x): self {};
$fn2 = function($x): parent {};
$fn3 = function($x): static {};

?>
DONE
--EXPECT--
DONE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Duplicate parent type
--FILE--
<?php

class Foo {
public function method(array $data) {}
}
class Bar extends Foo {
public function method(array $data): parent|parent {}
}

?>
--EXPECTF--
Fatal error: Duplicate type parent is redundant in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Duplicate self type
--FILE--
<?php

class Foo {
public function method(array $data): self|self {}
}

?>
--EXPECTF--
Fatal error: Duplicate type self is redundant in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Duplicate static type
--FILE--
<?php

class Foo {
public function method(array $data): static|static {}
}

?>
--EXPECTF--
Fatal error: Duplicate type static is redundant in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Relative class type self resolving to an existing entry (after variation)
--FILE--
<?php

class Foo {
public function method(array $data): Foo|self {}
}

?>
--EXPECTF--
Fatal error: self resolves to Foo which is redundant in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Relative class type self resolving to an existing entry (before variation)
--FILE--
<?php

class Foo {
public function method(array $data): self|Foo {}
}

?>
--EXPECTF--
Fatal error: self resolves to Foo which is redundant in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Relative class type parent resolving to an existing entry (after variation)
--FILE--
<?php

class Foo {
public function method(array $data) {}
}
class Bar extends Foo {
public function method(array $data): Foo|parent {}
}

?>
--EXPECTF--
Fatal error: parent resolves to Foo which is redundant in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Relative class type parent resolving to an existing entry (before variation)
--FILE--
<?php

class Foo {
public function method(array $data) {}
}
class Bar extends Foo {
public function method(array $data): parent|Foo {}
}

?>
--EXPECTF--
Fatal error: parent resolves to Foo which is redundant in %s on line %d
Loading