Advent of code 2016/8
Ajax Direct

Answer

Part 1 :
Part 2 :
$screen = grid(scalar(".")->repeat(50)->append("\n")->repeat(6)->trim());

foreach ($input->lines as $cmd) {
    $num = $cmd->numbers();
    $cmd = $cmd->split(" ");

    // Draw a rectangle
    if ($cmd[0] == "rect") {
        $square = grid(scalar("#")->repeat($num[0])->append("\n")->repeat($num[1])->trim());
        $screen->insert([0, 0], $square);
        continue;
    }

    // Rotation
    if ($cmd[1] == "row") {
        $screen->setRow($num[0], $screen->rows[$num[0]]->rotate($num[1]));
    } else {
        $screen->setColumn($num[0], $screen->column($num[0])->rotate($num[1]));
    }
    $screen->clearCache();
}

// ==================================================
// > SOLUTIONS
// ==================================================
$solution_1 = $screen->cells()->keep("#")->count();
$solution_2 = $screen->rows()->callEach()->join("")->join("<br>");