https://telegram.me/oop_ru is an English/Russian chat about OOP. Feel free to submit pull requests to this gist. Test
This file contains hidden or 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
<?php | |
namespace EC\Domain; | |
class Good | |
{ | |
private $type; | |
private $price; | |
private $name; | |
private $sizes; |
This file contains hidden or 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
<?php | |
interface EventEmitter | |
{ | |
public function emit(Event $e); | |
public function on(Event $e, callable $callback); | |
} |
This file contains hidden or 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
<?php | |
interface Chef | |
{ | |
public function cook(); | |
} | |
class TrueItalianChef implements Chef | |
{ | |
public function cook() |
This file contains hidden or 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
<?php | |
interface Logger | |
{ | |
public function log(string $message, int $level = 0): void; | |
} |
This file contains hidden or 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
export class SomeHandler { | |
constructor(private http: Http) { } | |
@afterEvery(SomeCommand) | |
async handleSomeCommand(action: SomeCommand, dispatch: Dispatch) { | |
const withData = await this.http.get("/"); | |
dispatch(someEventHappened(withData)); | |
} | |
} |
This file contains hidden or 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
import { World } from "support/World"; | |
export namespace cucumber { | |
type Step = RegExp|string; | |
interface StepCallback extends Function { | |
(this: World, ...args: any[]): void|Promise<any>; | |
} | |
export interface Feature { | |
Given(step: Step, callback: StepCallback): void; | |
When(step: Step, callback: StepCallback): void; |
This file contains hidden or 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
declare module "react-redux" { | |
export type Connect<State> = { | |
<P>( | |
mapStateToProps?: MapStateToPropsWithKnownState<State>, | |
mapDispatchToProps?: MapDispatchToPropsFunction|MapDispatchToPropsObject, | |
mergeProps?: MergeProps, | |
options?: Options | |
): ComponentConstructDecorator<P>; | |
} | |
interface MapStateToPropsWithKnownState<State> { |
This file contains hidden or 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
<?php | |
namespace ReturnTrue; | |
// inspired by http://alf.nu/ReturnTrue | |
function transitive($a, $b, $c) { | |
return $a == $b && $a == $c && $b != $c; | |
} | |
function peano($a) { | |
return $a++ !== $a && $a++ === $a; |
This file contains hidden or 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
<?php | |
use Mkusher\Co; | |
use React\EventLoop\Factory; | |
use React\Promise; | |
use Webmozart\Assert\Assert; | |
require dirname(__DIR__) . '/vendor/autoload.php'; | |
$loop = Factory::create(); |
NewerOlder