Skip to content

Instantly share code, notes, and snippets.

@amnuts
Last active January 4, 2016 14:19
Show Gist options
  • Save amnuts/8633535 to your computer and use it in GitHub Desktop.
Save amnuts/8633535 to your computer and use it in GitHub Desktop.
Zephir not incrementing correctly?
namespace Utils;
class Greeting
{
protected counter1 = 0;
protected counter2 = 0;
protected counter3 = 0;
protected revcounter1 = 5;
protected revcounter2 = 5;
protected revcounter3 = 5;
protected name = "";
public function __construct(string! name = "world")
{
let this->name = name;
}
public function speakLoop(int times = 5) -> void
{
while times {
echo "hello " . this->name . "!\n";
let this->counter1++;
let this->counter2 += 1;
let this->counter3 = this->counter3 + 1;
let this->revcounter1--;
let this->revcounter2 -= 1;
let this->revcounter3 = this->revcounter3 - 1;
let times -= 1;
}
}
}
class Utils\Greeting#1 (7) {
protected $counter1 =>
int(0)
protected $counter2 =>
int(0)
protected $counter3 =>
int(0)
protected $revcounter1 =>
int(5)
protected $revcounter2 =>
int(5)
protected $revcounter3 =>
int(5)
protected $name =>
string(4) "Andy"
}
hello Andy!
hello Andy!
hello Andy!
hello Andy!
hello Andy!
class Utils\Greeting#1 (7) {
protected $counter1 =>
int(0)
protected $counter2 =>
int(1)
protected $counter3 =>
int(5)
protected $revcounter1 =>
int(5)
protected $revcounter2 =>
int(1)
protected $revcounter3 =>
int(0)
protected $name =>
string(4) "Andy"
}
<?php
$g = new \Utils\Greeting('Andy');
var_dump($g);
$g->speakLoop(5);
var_dump($g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment