Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active July 4, 2023 22:49
Show Gist options
  • Save trikitrok/bb89055689825b93a062153e6e2370da to your computer and use it in GitHub Desktop.
Save trikitrok/bb89055689825b93a062153e6e2370da to your computer and use it in GitHub Desktop.
// Adapted from Rachel M. Carmena's https://github.com/rachelcarmena/code-smells
// see also Ds\Vector in https://www.php.net/manual/en/class.ds-vector.php
<?php
class CoolStack extends Ds\Vector {
public function push(...$values): void {
parent::push(...$values);
}
public function pop() {
return parent::pop();
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
<?php
class CoolStack<T> {
private $elements;
function __construct() {
$this->elements = new \Ds\Vector();
}
public function push(...$values): void {
$this->elements->push(...$values);
}
public function pop() {
return $this->elements->pop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment