Comments (2)
Real-life example:
diff --git a/src/main/php/de/thekid/dialog/color/PriorityQueue.php b/src/main/php/de/thekid/dialog/color/PriorityQueue.php
index a683a76..6fcb295 100755
--- a/src/main/php/de/thekid/dialog/color/PriorityQueue.php
+++ b/src/main/php/de/thekid/dialog/color/PriorityQueue.php
@@ -1,12 +1,12 @@
<?php namespace de\thekid\dialog\color;
/** @test de.thekid.dialog.unittest.PriorityQueueTest */
-class PriorityQueue {
+class PriorityQueue<T> {
private $elements= [];
private $sorted= true;
private $comparator= null;
- public function comparing(function(mixed, mixed): int $comparator): self {
+ public function comparing(function(T, T): int $comparator): self {
$this->comparator= $comparator;
return $this;
}
@@ -17,13 +17,13 @@ class PriorityQueue {
}
/** Pushes an element */
- public function push($element): void {
+ public function push(T $element): void {
$this->elements[]= $element;
$this->sorted= false;
}
/** Pops an element */
- public function pop() {
+ public function pop(): ?T {
if (!$this->sorted) {
$this->comparator ? usort($this->elements, $this->comparator) : sort($this->elements);
$this->sorted= true;
Maybe as an addition xp-lang/xp-generics
package?
from compiler.
Maybe as an addition xp-lang/xp-generics package?
Yes
from compiler.
Related Issues (20)
- Implement intersection types HOT 3
- Will there be an option for "prune" option of the compiler? HOT 7
- Undefined constant Sources::FromEmpty HOT 1
- Use php:X.Y instead of PHP.X.Y HOT 1
- Regex syntax exploration HOT 1
- XP Core dependencies HOT 2
- Logical Operators and Assignment Expressions: HOT 1
- For with ranges HOT 3
- Line number inconsistent after multi-line doc comments HOT 2
- Produce errors for trojan source HOT 1
- Support Disjunctive Normal Form Types
- Nullable type unions don't work as expected HOT 5
- do expression HOT 3
- #Override annotation HOT 6
- Interface Default Methods HOT 4
- Typed local variables HOT 1
- Typed class constants support HOT 3
- Fatal error: Label 'c1107822099' already defined HOT 1
- Arbitrary static variable initializers HOT 4
- Reusable property hooks HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler.