-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properties might be covariant or contravariant, depending on the allo…
…wed operations on the parent
- Loading branch information
1 parent
b3ca610
commit 50f8e49
Showing
3 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php // lint >= 8.4 | ||
|
||
namespace Bug12466OverridenProperty; | ||
|
||
interface Foo | ||
{ | ||
|
||
public int|string $onlyGet { get; } | ||
|
||
public int|string $onlySet { set; } | ||
|
||
} | ||
|
||
class Bar implements Foo | ||
{ | ||
|
||
public int $onlyGet { | ||
get { | ||
return 1; | ||
} | ||
} | ||
|
||
public int|string|null $onlySet { | ||
set { | ||
$this->onlySet = $value; | ||
} | ||
} | ||
|
||
} | ||
|
||
class Baz implements Foo | ||
{ | ||
|
||
public int|string|null $onlyGet { | ||
get { | ||
return null; | ||
} | ||
} | ||
|
||
public int $onlySet { | ||
set { | ||
$this->onlySet = $value; | ||
} | ||
} | ||
|
||
} | ||
|
||
interface FooWithPhpDocs | ||
{ | ||
|
||
/** @var array<int|string> */ | ||
public array $onlyGet { get; } | ||
|
||
/** @var array<int|string> */ | ||
public array $onlySet { set; } | ||
|
||
} | ||
|
||
class BarWithPhpDocs implements FooWithPhpDocs | ||
{ | ||
|
||
/** @var array<int> */ | ||
public array $onlyGet { | ||
get { | ||
return []; | ||
} | ||
} | ||
|
||
/** @var array<int|string|null> */ | ||
public array $onlySet { | ||
set { | ||
$this->onlySet = $value; | ||
} | ||
} | ||
|
||
} | ||
|
||
class BazWithPhpDocs implements FooWithPhpDocs | ||
{ | ||
|
||
/** @var array<int|string|null> */ | ||
public array $onlyGet { | ||
get { | ||
return []; | ||
} | ||
} | ||
|
||
/** @var array<int> */ | ||
public array $onlySet { | ||
set { | ||
$this->onlySet = $value; | ||
} | ||
} | ||
|
||
} |