Skip to content

Commit

Permalink
Add type hints to our methods (OnlineBuddies#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
iarna committed May 3, 2012
1 parent 3a7e993 commit 8a65dc6
Show file tree
Hide file tree
Showing 24 changed files with 164 additions and 169 deletions.
2 changes: 1 addition & 1 deletion Modyllic/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// A Modyllic generator dialect
class Modyllic_Console_CommandLine_ActionDialect extends Console_CommandLine_Action {
public function execute($value=false, $params=array()) {
public function execute($value=false, array $params=array()) {
$this->setResult( Modyllic_Generator::dialect_to_class($value) );
}
}
Expand Down
50 changes: 25 additions & 25 deletions Modyllic/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Modyllic_Diff {
* @param Modyllic_Schema $from
* @param Modyllic_Schema $to
*/
function __construct($from, $to) {
function __construct(Modyllic_Schema $from, Modyllic_Schema $to) {
$this->from = $from;
$this->to = $to;
$this->calculate_changeset();
Expand Down Expand Up @@ -395,101 +395,101 @@ function __construct() {
* Note that a table was added
* @param Modyllic_Schema_Table $table
*/
function add_table( $table ) {
function add_table( Modyllic_Schema_Table $table ) {
$this->add['tables'][$table->name] = $table;
}

/**
* Note that a table was removed
* @param Modyllic_Schema_Table $table
*/
function remove_table( $table ) {
function remove_table( Modyllic_Schema_Table $table ) {
$this->remove['tables'][$table->name] = $table;
}

/**
* Note that a table was updated (and how)
* @param Modyllic_Table_Changeset $table
*/
function update_table( $table ) {
function update_table( Modyllic_Table_Changeset $table ) {
$this->update['tables'][$table->name] = $table;
}

/**
* @param Modyllic_Schema_View $view
*/
function add_view( $view ) {
function add_view( Modyllic_Schema_View $view ) {
$this->add['views'][$view->name] = $view;
}

/**
* @param Modyllic_Schema_View_Changeset $view
* @param Modyllic_View_Changeset $view
*/
function update_view( $view ) {
function update_view( Modyllic_View_Changeset $view ) {
$this->update['views'][$view->name] = $view;
}

/**
* @param Modyllic_Schema_View $view
*/
function remove_view( $view ) {
function remove_view( Modyllic_Schema_View $view ) {
$this->remove['views'][$view->name] = $view;
}

/**
* Note that a routine was added
* @param Modyllic_Schema_Routine $routine
*/
function add_routine( $routine ) {
function add_routine( Modyllic_Schema_Routine $routine ) {
$this->add['routines'][$routine->name] = $routine;
}

/**
* Note that a routine was removed
* @param Modyllic_Schema_Routine $routine
*/
function remove_routine( $routine ) {
function remove_routine( Modyllic_Schema_Routine $routine ) {
$this->remove['routines'][$routine->name] = $routine;
}

/**
* Note that a routine was updated
* @param Modyllic_Schema_Routine $routine
*/
function update_routine( $routine ) {
function update_routine( Modyllic_Schema_Routine $routine ) {
$this->update['routines'][$routine->name] = $routine;
}

/**
* @param Modyllic_Schema_Event $event
*/
function add_event( $event ) {
function add_event( Modyllic_Schema_Event $event ) {
$this->add['events'][$event->name] = $event;
}

/**
* @param Modyllic_Event_Changeset $event
*/
function update_event( $event ) {
function update_event( Modyllic_Event_Changeset $event ) {
$this->update['events'][$event->name] = $event;
}

/**
* @param Modyllic_Schema_Event $event
*/
function remove_event( $event ) {
function remove_event( Modyllic_Schema_Event $event ) {
$this->remove['events'][$event->name] = $event;
}

/**
* @param Modyllic_Schema_Trigger $trigger
*/
function add_trigger( $trigger ) {
function add_trigger( Modyllic_Schema_Trigger $trigger ) {
$this->add['triggers'][$trigger->name] = $trigger;
}

/**
* @param Modyllic_Schema_Trigger_Changeset $trigger
* @param Modyllic_Trigger_Changeset $trigger
*/
function update_trigger( $trigger ) {
$this->update['triggers'][$trigger->name] = $trigger;
Expand All @@ -498,7 +498,7 @@ function update_trigger( $trigger ) {
/**
* @param Modyllic_Schema_Trigger $trigger
*/
function remove_trigger( $trigger ) {
function remove_trigger( Modyllic_Schema_Trigger $trigger ) {
$this->remove['triggers'][$trigger->name] = $trigger;
}

Expand Down Expand Up @@ -571,39 +571,39 @@ function __construct($name) {
* Note that a column was added
* @param Modyllic_Schema_Column $column
*/
function add_column($column) {
function add_column(Modyllic_Schema_Column $column) {
$this->add['columns'][$column->name] = $column;
}

/**
* Note that a column was removed
* @param Modyllic_Schema_Column $column
*/
function remove_column($column) {
function remove_column(Modyllic_Schema_Column $column) {
$this->remove['columns'][$column->name] = $column;
}

/**
* Note that a column was updated
* @param Modyllic_Schema_Column $column
*/
function update_column($column) {
function update_column(Modyllic_Schema_Column $column) {
$this->update['columns'][$column->name] = $column;
}

/**
* Note that an index was added
* @param Modyllic_Schema_Index $index
*/
function add_index($index) {
function add_index(Modyllic_Schema_Index $index) {
$this->add['indexes'][] = $index;
}

/**
* Note that an index was removed
* @param Modyllic_Schema_Index $index
*/
function remove_index($index) {
function remove_index(Modyllic_Schema_Index $index) {
$this->remove['indexes'][] = $index;
}

Expand All @@ -619,22 +619,22 @@ function update_option($option,$value) {
/**
* @param array $row
*/
function add_row($row) {
function add_row(array $row) {
$this->add['data'][] = $row;
}

/**
* @param array $row
*/
function remove_row($row) {
function remove_row(array $row) {
$this->remove['data'][] = $row;
}

/**
* @param array $updated
* @param array $where
*/
function update_row($updated,$where,$from) {
function update_row(array $updated,array $where,array $from) {
$this->update['data'][] = array("updated"=>$updated,"where"=>$where,"from"=>$from);
}

Expand Down
2 changes: 1 addition & 1 deletion Modyllic/Generator/AssertMySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Modyllic_Generator_AssertMySQL extends Modyllic_Generator_MySQL {
// We include weak constraints as well as regular ones
function ignore_index( $index ) {
function ignore_index( Modyllic_Schema_Index $index ) {
return false;
}
}
14 changes: 7 additions & 7 deletions Modyllic/Generator/ModyllicSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
require_once "Modyllic/Schema.php";

class Modyllic_Generator_ModyllicSQL extends Modyllic_Generator_MySQL {
function sqlmeta_exists($schema) {
function sqlmeta_exists(Modyllic_Schema $schema) {
return false;
}

// We include weak constraints as well as regular ones
function ignore_index( $index ) {
function ignore_index(Modyllic_Schema_Index $index ) {
return false;
}

function create_sqlmeta() {}
function insert_meta($kind,$which,array $what) {}
function delete_meta($kind,$which) {}
function update_meta($kind,$which,array $meta) {}
function add_column( $column ) {
function add_column( Modyllic_Schema_Column $column ) {
parent::add_column( $column );
$this->column_aliases($column);
}
function create_column( $column ) {
function create_column( Modyllic_Schema_Column $column ) {
parent::create_column( $column );
$this->column_aliases($column);
}
function column_aliases( $column ) {
function column_aliases( Modyllic_Schema_Column $column ) {
if ( count($column->aliases) ) {
$this->add( " ALIASES (" );
foreach ( $column->aliases as $num=>$alias ) {
Expand All @@ -42,7 +42,7 @@ function column_aliases( $column ) {
$this->add( ")" );
}
}
function foreign_key($index) {
function foreign_key(Modyllic_Schema_Index $index) {
if ( $index->weak != Modyllic_Schema_Index_Foreign::WEAK_DEFAULT ) {
$this->add( " WEAKLY REFERENCES %id", $index->references['table'] );
}
Expand All @@ -58,7 +58,7 @@ function foreign_key($index) {
$this->add( " ON UPDATE %lit", $index->references['on_update'] );
}
}
function routine_attrs( $routine ) {
function routine_attrs( Modyllic_Schema_Routine $routine ) {
if ( $routine->args_type != Modyllic_Schema_Routine::ARGS_TYPE_DEFAULT ) {
$this->extend("ARGS %lit",$routine->args_type);
}
Expand Down
8 changes: 4 additions & 4 deletions Modyllic/Generator/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function table_meta($table) {
}
}

function create_table( $table, $schema ) {
function create_table( Modyllic_Schema_Table $table, Modyllic_Schema $schema ) {
$this->begin_cmd();
$this->table_docs( $table );
$this->extend( "CREATE TABLE %id (", $table->name );
Expand Down Expand Up @@ -544,7 +544,7 @@ function alter_table( $table ) {
return $this;
}

function drop_table( $table ) {
function drop_table( Modyllic_Schema_Table $table ) {
$this->cmd( "DROP TABLE IF EXISTS %id", $table->name );
if ( count($this->table_meta($table)) > 0 ) {
$this->delete_meta("TABLE",$table->name);
Expand All @@ -558,7 +558,7 @@ function drop_table( $table ) {
return $this;
}

function column_meta($col) {
function column_meta( Modyllic_Schema_Column $col) {
if ( count($col->aliases) ) {
return array( "aliases" => $col->aliases );
}
Expand All @@ -567,7 +567,7 @@ function column_meta($col) {
}
}

function add_column( $column ) {
function add_column( Modyllic_Schema_Column $column ) {
$this->partial("ADD COLUMN " );
$this->create_column($column);
if ( $column->after == "" ) {
Expand Down
Loading

0 comments on commit 8a65dc6

Please sign in to comment.