Skip to content

Commit

Permalink
Merge pull request #12382 from SidRoberts/v4-parameter-return
Browse files Browse the repository at this point in the history
[4.0.0] Strengthened parameter/return types
  • Loading branch information
sergeyklay authored Sep 2, 2017
2 parents 88fd295 + ff6012d commit e71f3cc
Show file tree
Hide file tree
Showing 164 changed files with 504 additions and 1,967 deletions.
4 changes: 1 addition & 3 deletions phalcon/annotations/adapter/apc.zep
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ class Apc extends Adapter

/**
* Phalcon\Annotations\Adapter\Apc constructor
*
* @param array options
*/
public function __construct(options = null)
public function __construct(array options = [])
{
var prefix, ttl;

Expand Down
14 changes: 4 additions & 10 deletions phalcon/annotations/adapter/files.zep
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,18 @@ class Files extends Adapter

/**
* Phalcon\Annotations\Adapter\Files constructor
*
* @param array options
*/
public function __construct(options = null)
public function __construct(array options = [])
{
var annotationsDir;
if typeof options == "array" {
if fetch annotationsDir, options["annotationsDir"] {
let this->_annotationsDir = annotationsDir;
}

if fetch annotationsDir, options["annotationsDir"] {
let this->_annotationsDir = annotationsDir;
}
}

/**
* Reads parsed annotations from files
*
* @param string key
* @return \Phalcon\Annotations\Reflection
*/
public function read(string key) -> <Reflection> | boolean | int
{
Expand Down
3 changes: 0 additions & 3 deletions phalcon/annotations/adapter/xcache.zep
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class Xcache extends Adapter
{
/**
* Reads parsed annotations from XCache
*
* @param string key
* @return \Phalcon\Annotations\Reflection
*/
public function read(string! key) -> <Reflection> | boolean
{
Expand Down
6 changes: 2 additions & 4 deletions phalcon/annotations/adapterinterface.zep
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ interface AdapterInterface

/**
* Parses or retrieves all the annotations found in a class
*
* @param string|object className
*/
public function get(className) -> <Reflection>;
*/
public function get(string className) -> <Reflection>;

/**
* Returns the annotations found in all the class' methods
Expand Down
2 changes: 0 additions & 2 deletions phalcon/annotations/annotation.zep
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class Annotation
/**
* Resolves an annotation expression
*
* @param array expr
* @return mixed
*/
public function getExpression(array! expr)
Expand Down Expand Up @@ -183,7 +182,6 @@ class Annotation
* Returns an argument in a specific position
*
* @param int|string position
* @return boolean
*/
public function hasArgument(var position) -> boolean
{
Expand Down
16 changes: 5 additions & 11 deletions phalcon/annotations/collection.zep
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,16 @@ class Collection implements \Iterator, \Countable
*
* @param array reflectionData
*/
public function __construct(var reflectionData = null)
public function __construct(array reflectionData = [])
{
var annotations, annotationData;

if typeof reflectionData != "null" && typeof reflectionData != "array" {
throw new Exception("Reflection data must be an array");
}

let annotations = [];
if typeof reflectionData == "array" {
for annotationData in reflectionData {
let annotations[] = new Annotation(annotationData);
}

for annotationData in reflectionData {
let annotations[] = new Annotation(annotationData);
}

let this->_annotations = annotations;
}

Expand All @@ -87,8 +83,6 @@ class Collection implements \Iterator, \Countable

/**
* Returns the current annotation in the iterator
*
* @return \Phalcon\Annotations\Annotation
*/
public function current() -> <Annotation> | boolean
{
Expand Down
28 changes: 9 additions & 19 deletions phalcon/annotations/reflection.zep
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,10 @@ class Reflection

/**
* Phalcon\Annotations\Reflection constructor
*
* @param array reflectionData
*/
public function __construct(reflectionData = null)
public function __construct(array reflectionData = [])
{
if typeof reflectionData == "array" {
let this->_reflectionData = reflectionData;
}
let this->_reflectionData = reflectionData;
}

/**
Expand Down Expand Up @@ -141,30 +137,24 @@ class Reflection

/**
* Returns the raw parsing intermediate definitions used to construct the reflection
*
* @return array
*/
public function getReflectionData()
public function getReflectionData() -> array
{
return this->_reflectionData;
}

/**
* Restores the state of a Phalcon\Annotations\Reflection variable export
*
* @return array data
*/
public static function __set_state(data) -> <Reflection>
public static function __set_state(array! data) -> <Reflection>
{
var reflectionData;

if typeof data == "array" {
/**
* Check for a '_reflectionData' in the array to build the Reflection
*/
if fetch reflectionData, data["_reflectionData"] {
return new self(reflectionData);
}
/**
* Check for a '_reflectionData' in the array to build the Reflection
*/
if fetch reflectionData, data["_reflectionData"] {
return new self(reflectionData);
}

return new self();
Expand Down
10 changes: 2 additions & 8 deletions phalcon/assets/collection.zep
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,9 @@ class Collection implements \Countable, \Iterator
/**
* Adds a javascript resource to the collection
*
* @param string path
* @param boolean local
* @param boolean filter
* @param array attributes
* @return \Phalcon\Assets\Collection
*/
public function addJs(string! path, var local = null, boolean filter = true, attributes = null) -> <Collection>
public function addJs(string! path, boolean local = null, boolean filter = true, attributes = null) -> <Collection>
{
var collectionLocal, collectionAttributes;

Expand Down Expand Up @@ -227,10 +223,8 @@ class Collection implements \Countable, \Iterator

/**
* Returns the current position/key in the iterator
*
* @return int
*/
public function key()
public function key() -> int
{
return this->_position;
}
Expand Down
13 changes: 3 additions & 10 deletions phalcon/assets/inline.zep
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,13 @@ class $Inline implements ResourceInterface

/**
* Phalcon\Assets\Inline constructor
*
* @param string type
* @param string content
* @param boolean filter
* @param array attributes
*/
public function __construct(string type, string content, boolean filter = true, attributes = null)
public function __construct(string type, string content, boolean filter = true, array attributes = [])
{
let this->_type = type,
this->_content = content,
this->_filter = filter;
if typeof attributes == "array" {
let this->_attributes = attributes;
}
this->_filter = filter,
this->_attributes = attributes;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions phalcon/assets/inline/css.zep
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Css extends InlineBase
/**
* Phalcon\Assets\Inline\Css
*
* @param string content
* @param boolean filter
* @param array attributes
*/
public function __construct(string content, boolean filter = true, attributes = null)
Expand Down
2 changes: 0 additions & 2 deletions phalcon/assets/inline/js.zep
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Js extends InlineBase
/**
* Phalcon\Assets\Inline\Js
*
* @param string content
* @param boolean filter
* @param array attributes
*/
public function __construct(string content, boolean filter = true, var attributes = null)
Expand Down
26 changes: 6 additions & 20 deletions phalcon/assets/manager.zep
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ class Manager

/**
* Phalcon\Assets\Manager
*
* @param array options
*/
public function __construct(options = null)
public function __construct(array options = [])
{
if typeof options == "array" {
let this->_options = options;
}
let this->_options = options;
}

/**
Expand Down Expand Up @@ -302,7 +298,6 @@ class Manager
/**
* Traverses a collection calling the callback to generate its HTML
*
* @param \Phalcon\Assets\Collection collection
* @param callback callback
* @param string type
*/
Expand Down Expand Up @@ -712,7 +707,6 @@ class Manager
/**
* Traverses a collection and generate its HTML
*
* @param \Phalcon\Assets\Collection collection
* @param string type
*/
public function outputInline(<Collection> collection, type) -> string
Expand Down Expand Up @@ -772,10 +766,8 @@ class Manager

/**
* Prints the HTML for CSS resources
*
* @param string collectionName
*/
public function outputCss(collectionName = null) -> string
public function outputCss(string collectionName = null) -> string
{
var collection;

Expand All @@ -790,10 +782,8 @@ class Manager

/**
* Prints the HTML for inline CSS
*
* @param string collectionName
*/
public function outputInlineCss(collectionName = null) -> string
public function outputInlineCss(string collectionName = null) -> string
{
var collection;

Expand All @@ -808,10 +798,8 @@ class Manager

/**
* Prints the HTML for JS resources
*
* @param string collectionName
*/
public function outputJs(collectionName = null) -> string
public function outputJs(string collectionName = null) -> string
{
var collection;

Expand All @@ -826,10 +814,8 @@ class Manager

/**
* Prints the HTML for inline JS
*
* @param string collectionName
*/
public function outputInlineJs(collectionName = null) -> string
public function outputInlineJs(string collectionName = null) -> string
{
var collection;

Expand Down
14 changes: 3 additions & 11 deletions phalcon/assets/resource.zep
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,14 @@ class $Resource implements ResourceInterface

/**
* Phalcon\Assets\Resource constructor
*
* @param string type
* @param string path
* @param boolean local
* @param boolean filter
* @param array attributes
*/
public function __construct(string type, string path, boolean local = true, boolean filter = true, attributes = null)
public function __construct(string type, string path, boolean local = true, boolean filter = true, array attributes = [])
{
let this->_type = type,
this->_path = path,
this->_local = local,
this->_filter = filter;
if typeof attributes == "array" {
let this->_attributes = attributes;
}
this->_filter = filter,
this->_attributes = attributes;
}

/**
Expand Down
7 changes: 1 addition & 6 deletions phalcon/assets/resource/css.zep
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ class Css extends ResourceBase

/**
* Phalcon\Assets\Resource\Css
*
* @param string path
* @param boolean local
* @param boolean filter
* @param array attributes
*/
public function __construct(string! path, boolean local = true, boolean filter = true, attributes = null)
public function __construct(string! path, boolean local = true, boolean filter = true, array attributes = [])
{
parent::__construct("css", path, local, filter, attributes);
}
Expand Down
7 changes: 1 addition & 6 deletions phalcon/assets/resource/js.zep
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ class Js extends ResourceBase

/**
* Phalcon\Assets\Resource\Js
*
* @param string path
* @param boolean local
* @param boolean filter
* @param array attributes
*/
public function __construct(path, local = true, filter = true, attributes = null)
public function __construct(string! path, boolean local = true, boolean filter = true, array attributes = [])
{
parent::__construct("js", path, local, filter, attributes);
}
Expand Down
7 changes: 1 addition & 6 deletions phalcon/cache/backend.zep
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ abstract class Backend implements BackendInterface

/**
* Phalcon\Cache\Backend constructor
*
* @param \Phalcon\Cache\FrontendInterface frontend
* @param array options
*/
public function __construct(<FrontendInterface> frontend, options = null)
public function __construct(<FrontendInterface> frontend, array options = [])
{
var prefix;

Expand Down Expand Up @@ -129,8 +126,6 @@ abstract class Backend implements BackendInterface

/**
* Gets the last lifetime set
*
* @return int
*/
public function getLifetime() -> int
{
Expand Down
Loading

0 comments on commit e71f3cc

Please sign in to comment.