Skip to content

Instantly share code, notes, and snippets.

View sobstel's full-sized avatar
⚛️

sobstel

⚛️
  • 11:03 (UTC +01:00)
View GitHub Profile
@ludekstepan
ludekstepan / MigrationExample.php
Created September 20, 2012 11:19
Example of container aware migration
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20120920130854 extends AbstractMigration
{
public function up(Schema $schema)
@chetan
chetan / yardoc_cheatsheet.md
Last active November 11, 2024 08:27
YARD cheatsheet
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
module FormBuilderHelpers
class Html5
def self.options_from(object, attribute)
return {} unless object.class.respond_to?(:validators_on)
{}.tap do |options|
options[:required] = true if object.class.validators_on(attribute).any? { |validator| validator.is_a?(ActiveModel::Validations::PresenceValidator) }
if validator = object.class.validators_on(attribute).select { |validator| validator.is_a?(ActiveModel::Validations::InclusionValidator) && validator.options[:in].is_a?(Range) }.last
options[:min] = validator.options[:in].min