Skip to content

Instantly share code, notes, and snippets.

@morrisonlevi
morrisonlevi / Generics.md
Last active November 14, 2017 14:06
Thinking through some issues with adding generic types in PHP.

Let's consider ArrayAccess as a generic type. In order to preseve backwards- compatibility let's default the types to any type. Although I don't like the name mixed this is what documentation uses so I'll use it here:

class ArrayAccess<Element = mixed, Key = mixed> {
    function offsetExists(Key $offset): boolean;
    function offsetGet(Key $offset): Value;
    function offsetSet(?Key $offset, Element $value): void;
    function offsetUnset(Key $offset): void;
@Leneshka-jb
Leneshka-jb / XBladeLanguageInjector.java
Created January 15, 2019 15:44
XBlade-style php injection
package com.jetbrains.php.blade.injection;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.jetbrains.php.blade.BladeFileType;
import com.jetbrains.php.lang.PhpLanguage;
import org.jetbrains.annotations.NotNull;