repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
philiplb/CRUDlex
src/CRUDlex/YamlReader.php
YamlReader.readFromCache
protected function readFromCache($fileName) { $cacheFile = $this->getCacheFile($fileName); if (file_exists($cacheFile) && is_readable($cacheFile)) { include($cacheFile); if (isset($crudlexCacheContent)) { return $crudlexCacheContent; } } return null; }
php
protected function readFromCache($fileName) { $cacheFile = $this->getCacheFile($fileName); if (file_exists($cacheFile) && is_readable($cacheFile)) { include($cacheFile); if (isset($crudlexCacheContent)) { return $crudlexCacheContent; } } return null; }
[ "protected", "function", "readFromCache", "(", "$", "fileName", ")", "{", "$", "cacheFile", "=", "$", "this", "->", "getCacheFile", "(", "$", "fileName", ")", ";", "if", "(", "file_exists", "(", "$", "cacheFile", ")", "&&", "is_readable", "(", "$", "cach...
Reads the content of the cached file if it exists. @param string $fileName the cache file to read from @return null|array the cached data structure or null if the cache file was not available
[ "Reads", "the", "content", "of", "the", "cached", "file", "if", "it", "exists", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/YamlReader.php#L50-L60
train
philiplb/CRUDlex
src/CRUDlex/YamlReader.php
YamlReader.writeToCache
protected function writeToCache($fileName, $content) { if ($this->cachePath === null || !is_dir($this->cachePath) || !is_writable($this->cachePath)) { return; } $encoder = new \Riimu\Kit\PHPEncoder\PHPEncoder(); $contentPHP = $encoder->encode($content, [ 'whitespace' => false, 'recursion.detect' => false ]); $cache = '<?php $crudlexCacheContent = '.$contentPHP.';'; file_put_contents($this->getCacheFile($fileName), $cache); }
php
protected function writeToCache($fileName, $content) { if ($this->cachePath === null || !is_dir($this->cachePath) || !is_writable($this->cachePath)) { return; } $encoder = new \Riimu\Kit\PHPEncoder\PHPEncoder(); $contentPHP = $encoder->encode($content, [ 'whitespace' => false, 'recursion.detect' => false ]); $cache = '<?php $crudlexCacheContent = '.$contentPHP.';'; file_put_contents($this->getCacheFile($fileName), $cache); }
[ "protected", "function", "writeToCache", "(", "$", "fileName", ",", "$", "content", ")", "{", "if", "(", "$", "this", "->", "cachePath", "===", "null", "||", "!", "is_dir", "(", "$", "this", "->", "cachePath", ")", "||", "!", "is_writable", "(", "$", ...
Writes the given content to a cached PHP file. @param string $fileName the original filename @param array $content the content to cache
[ "Writes", "the", "given", "content", "to", "a", "cached", "PHP", "file", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/YamlReader.php#L70-L82
train
philiplb/CRUDlex
src/CRUDlex/YamlReader.php
YamlReader.read
public function read($fileName) { $parsedYaml = $this->readFromCache($fileName); if ($parsedYaml !== null) { return $parsedYaml; } try { $fileContent = file_get_contents($fileName); $parsedYaml = Yaml::parse($fileContent); if (!is_array($parsedYaml)) { $parsedYaml = []; } $this->writeToCache($fileName, $parsedYaml); return $parsedYaml; } catch (\Exception $e) { throw new \RuntimeException('Could not read Yaml file '.$fileName, $e->getCode(), $e); } }
php
public function read($fileName) { $parsedYaml = $this->readFromCache($fileName); if ($parsedYaml !== null) { return $parsedYaml; } try { $fileContent = file_get_contents($fileName); $parsedYaml = Yaml::parse($fileContent); if (!is_array($parsedYaml)) { $parsedYaml = []; } $this->writeToCache($fileName, $parsedYaml); return $parsedYaml; } catch (\Exception $e) { throw new \RuntimeException('Could not read Yaml file '.$fileName, $e->getCode(), $e); } }
[ "public", "function", "read", "(", "$", "fileName", ")", "{", "$", "parsedYaml", "=", "$", "this", "->", "readFromCache", "(", "$", "fileName", ")", ";", "if", "(", "$", "parsedYaml", "!==", "null", ")", "{", "return", "$", "parsedYaml", ";", "}", "t...
Reads and returns the contents of the given Yaml file. If it goes wrong, it throws an exception. @param string $fileName the file to read @return array the file contents @throws \RuntimeException thrown if the file could not be read or parsed
[ "Reads", "and", "returns", "the", "contents", "of", "the", "given", "Yaml", "file", ".", "If", "it", "goes", "wrong", "it", "throws", "an", "exception", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/YamlReader.php#L107-L125
train
philiplb/CRUDlex
src/CRUDlex/Entity.php
Entity.toType
protected function toType($value, $type) { if (in_array($type, ['integer', 'float']) && !in_array($value, ['', null], true)) { settype($value, $type); } else if ($type == 'boolean') { $value = (bool)$value; } else if ($type == 'many') { $value = $value ?: []; } return $value === '' ? null : $value; }
php
protected function toType($value, $type) { if (in_array($type, ['integer', 'float']) && !in_array($value, ['', null], true)) { settype($value, $type); } else if ($type == 'boolean') { $value = (bool)$value; } else if ($type == 'many') { $value = $value ?: []; } return $value === '' ? null : $value; }
[ "protected", "function", "toType", "(", "$", "value", ",", "$", "type", ")", "{", "if", "(", "in_array", "(", "$", "type", ",", "[", "'integer'", ",", "'float'", "]", ")", "&&", "!", "in_array", "(", "$", "value", ",", "[", "''", ",", "null", "]"...
Converts a given value to the given type. @param mixed $value the value to convert @param string $type the type to convert to like 'integer' or 'float' @return mixed the converted value
[ "Converts", "a", "given", "value", "to", "the", "given", "type", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/Entity.php#L48-L58
train
philiplb/CRUDlex
src/CRUDlex/Entity.php
Entity.getRaw
public function getRaw($field) { if (!array_key_exists($field, $this->entity)) { return null; } return $this->entity[$field]; }
php
public function getRaw($field) { if (!array_key_exists($field, $this->entity)) { return null; } return $this->entity[$field]; }
[ "public", "function", "getRaw", "(", "$", "field", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "entity", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "entity", "[", "$", "field...
Gets the raw value of a field no matter what type it is. This is usefull for input validation for example. @param string $field the field @return mixed null on invalid field or else the raw value
[ "Gets", "the", "raw", "value", "of", "a", "field", "no", "matter", "what", "type", "it", "is", ".", "This", "is", "usefull", "for", "input", "validation", "for", "example", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/Entity.php#L96-L102
train
philiplb/CRUDlex
src/CRUDlex/Entity.php
Entity.get
public function get($field) { if ($this->definition->getField($field, 'value') !== null) { return $this->definition->getField($field, 'value'); } if (!array_key_exists($field, $this->entity)) { return null; } $type = $this->definition->getType($field); $value = $this->toType($this->entity[$field], $type); return $value; }
php
public function get($field) { if ($this->definition->getField($field, 'value') !== null) { return $this->definition->getField($field, 'value'); } if (!array_key_exists($field, $this->entity)) { return null; } $type = $this->definition->getType($field); $value = $this->toType($this->entity[$field], $type); return $value; }
[ "public", "function", "get", "(", "$", "field", ")", "{", "if", "(", "$", "this", "->", "definition", "->", "getField", "(", "$", "field", ",", "'value'", ")", "!==", "null", ")", "{", "return", "$", "this", "->", "definition", "->", "getField", "(",...
Gets the value of a field in its specific type. @param string $field the field @return mixed null on invalid field, an integer if the definition says that the type of the field is an integer, a boolean if the field is a boolean or else the raw value
[ "Gets", "the", "value", "of", "a", "field", "in", "its", "specific", "type", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/Entity.php#L115-L128
train
philiplb/CRUDlex
src/CRUDlex/Entity.php
Entity.populateViaRequest
public function populateViaRequest(Request $request) { $fields = $this->definition->getEditableFieldNames(); foreach ($fields as $field) { $type = $this->definition->getType($field); if ($type === 'file') { $file = $request->files->get($field); if ($file) { $this->set($field, $file->getClientOriginalName()); } } else if ($type === 'reference') { $value = $request->get($field); if ($value === '') { $value = null; } $this->set($field, ['id' => $value]); } else if ($type === 'many') { $array = $request->get($field, []); if (is_array($array)) { $many = array_map(function($id) { return ['id' => $id]; }, $array); $this->set($field, $many); } } else { $this->set($field, $request->get($field)); } } }
php
public function populateViaRequest(Request $request) { $fields = $this->definition->getEditableFieldNames(); foreach ($fields as $field) { $type = $this->definition->getType($field); if ($type === 'file') { $file = $request->files->get($field); if ($file) { $this->set($field, $file->getClientOriginalName()); } } else if ($type === 'reference') { $value = $request->get($field); if ($value === '') { $value = null; } $this->set($field, ['id' => $value]); } else if ($type === 'many') { $array = $request->get($field, []); if (is_array($array)) { $many = array_map(function($id) { return ['id' => $id]; }, $array); $this->set($field, $many); } } else { $this->set($field, $request->get($field)); } } }
[ "public", "function", "populateViaRequest", "(", "Request", "$", "request", ")", "{", "$", "fields", "=", "$", "this", "->", "definition", "->", "getEditableFieldNames", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "ty...
Populates the entities fields from the requests parameters. @param Request $request the request to take the field data from
[ "Populates", "the", "entities", "fields", "from", "the", "requests", "parameters", "." ]
6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc
https://github.com/philiplb/CRUDlex/blob/6c6c9fe554134e6b300d576a1cf4447f3c7aa1dc/src/CRUDlex/Entity.php#L147-L175
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.get
public function get($property, $default = null) { $this->storage->openReader(); $object = $this->getObjectSafely('openReader'); $this->storage->close(); $data = $object->getData(); if (!property_exists($data, $property)) { return $default; } return $data->{$property}; }
php
public function get($property, $default = null) { $this->storage->openReader(); $object = $this->getObjectSafely('openReader'); $this->storage->close(); $data = $object->getData(); if (!property_exists($data, $property)) { return $default; } return $data->{$property}; }
[ "public", "function", "get", "(", "$", "property", ",", "$", "default", "=", "null", ")", "{", "$", "this", "->", "storage", "->", "openReader", "(", ")", ";", "$", "object", "=", "$", "this", "->", "getObjectSafely", "(", "'openReader'", ")", ";", "...
Returns a value from the shared object @access public @param mixed $property @param mixed $default @return mixed @throws \Exception
[ "Returns", "a", "value", "from", "the", "shared", "object" ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L131-L144
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.set
public function set($property, $value) { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $data = $object->getData(); $data->{$property} = $value; $object->setData($data); $this->storage->setObject($object); $this->storage->close(); return $value; }
php
public function set($property, $value) { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $data = $object->getData(); $data->{$property} = $value; $object->setData($data); $this->storage->setObject($object); $this->storage->close(); return $value; }
[ "public", "function", "set", "(", "$", "property", ",", "$", "value", ")", "{", "$", "this", "->", "storage", "->", "openWriter", "(", ")", ";", "$", "object", "=", "$", "this", "->", "getObjectSafely", "(", "'openWriter'", ")", ";", "$", "data", "="...
Add a new property to the shared object. @access public @param mixed $property @param mixed $value @return self @throws \Exception
[ "Add", "a", "new", "property", "to", "the", "shared", "object", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L189-L199
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.remove
public function remove($property) { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $data = $object->getData(); if (property_exists($data, $property)) { unset($data->{$property}); } $object->setData($data); $this->storage->setObject($object); $this->storage->close(); return $this; }
php
public function remove($property) { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $data = $object->getData(); if (property_exists($data, $property)) { unset($data->{$property}); } $object->setData($data); $this->storage->setObject($object); $this->storage->close(); return $this; }
[ "public", "function", "remove", "(", "$", "property", ")", "{", "$", "this", "->", "storage", "->", "openWriter", "(", ")", ";", "$", "object", "=", "$", "this", "->", "getObjectSafely", "(", "'openWriter'", ")", ";", "$", "data", "=", "$", "object", ...
Removes a value from the shared object. @access public @param mixed $property @return self @throws \Exception
[ "Removes", "a", "value", "from", "the", "shared", "object", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L238-L251
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.lock
public function lock($timeout = 0, $interval = 50000) { if ((!is_numeric($timeout)) || ($timeout < 0)) { throw new \Exception("Lock timeout should be an integer greater or equals to 0."); } if ((!is_numeric($interval)) || ($interval < 5000)) { throw new \Exception("Lock check interval should be an integer greater or equals to 5000."); } $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $object->setLocked(true); $object->setTimeout($timeout); $object->setInterval($interval); $this->lock = true; $this->storage->setObject($object); $this->storage->close(); }
php
public function lock($timeout = 0, $interval = 50000) { if ((!is_numeric($timeout)) || ($timeout < 0)) { throw new \Exception("Lock timeout should be an integer greater or equals to 0."); } if ((!is_numeric($interval)) || ($interval < 5000)) { throw new \Exception("Lock check interval should be an integer greater or equals to 5000."); } $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $object->setLocked(true); $object->setTimeout($timeout); $object->setInterval($interval); $this->lock = true; $this->storage->setObject($object); $this->storage->close(); }
[ "public", "function", "lock", "(", "$", "timeout", "=", "0", ",", "$", "interval", "=", "50000", ")", "{", "if", "(", "(", "!", "is_numeric", "(", "$", "timeout", ")", ")", "||", "(", "$", "timeout", "<", "0", ")", ")", "{", "throw", "new", "\\...
Locks synchronized variable to the current process. This is useful to avoid concurrent accesses, such as : if (is_null($shared->check)) { $shared->data = "something"; } In the example above, the condition can be true for several processes if $shared->check is accessed simultaneously. @access public @param int $timeout Define how many seconds the shared variable should be locked (0 = unlimited) @param int $interval Microseconds between each lock check when a process awaits unlock @return self @throws \Exception
[ "Locks", "synchronized", "variable", "to", "the", "current", "process", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L271-L293
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.unlock
public function unlock() { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $object->setLocked(false); $this->lock = false; $this->storage->setObject($object); $this->storage->close(); return $this; }
php
public function unlock() { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $object->setLocked(false); $this->lock = false; $this->storage->setObject($object); $this->storage->close(); return $this; }
[ "public", "function", "unlock", "(", ")", "{", "$", "this", "->", "storage", "->", "openWriter", "(", ")", ";", "$", "object", "=", "$", "this", "->", "getObjectSafely", "(", "'openWriter'", ")", ";", "$", "object", "->", "setLocked", "(", "false", ")"...
Unlocks synchronized variable, making it available for all processes that uses it. Note that any app using a shared object can unlock it. @access public @return self
[ "Unlocks", "synchronized", "variable", "making", "it", "available", "for", "all", "processes", "that", "uses", "it", ".", "Note", "that", "any", "app", "using", "a", "shared", "object", "can", "unlock", "it", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L303-L312
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.getData
public function getData() { $this->storage->openReader(); $object = $this->getObjectSafely('openReader'); $this->storage->close(); return $object->getData(); }
php
public function getData() { $this->storage->openReader(); $object = $this->getObjectSafely('openReader'); $this->storage->close(); return $object->getData(); }
[ "public", "function", "getData", "(", ")", "{", "$", "this", "->", "storage", "->", "openReader", "(", ")", ";", "$", "object", "=", "$", "this", "->", "getObjectSafely", "(", "'openReader'", ")", ";", "$", "this", "->", "storage", "->", "close", "(", ...
Get the whole object, raw, for quicker access to its properties. This class delivers objects designed to be always safely synchronized with a file, to allow safe concurrent accesses. To avoid getting in trouble, you should use lock() method before using getData and unlock() method after using setData. @access public @return \stdClass @throws \Exception
[ "Get", "the", "whole", "object", "raw", "for", "quicker", "access", "to", "its", "properties", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L362-L368
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.setData
public function setData(\stdClass $data) { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $object->setData($data); $this->storage->setObject($object); $this->storage->close(); return $this; }
php
public function setData(\stdClass $data) { $this->storage->openWriter(); $object = $this->getObjectSafely('openWriter'); $object->setData($data); $this->storage->setObject($object); $this->storage->close(); return $this; }
[ "public", "function", "setData", "(", "\\", "stdClass", "$", "data", ")", "{", "$", "this", "->", "storage", "->", "openWriter", "(", ")", ";", "$", "object", "=", "$", "this", "->", "getObjectSafely", "(", "'openWriter'", ")", ";", "$", "object", "->"...
Set the whole object, replacing all its properties and values by the new ones. This class delivers objects designed to be always safely synchronized with a file, to allow safe concurrent accesses. To avoid getting in trouble, you should use lock() method before using getData and unlock() method after using setData. @access public @param \stdClass $data @return self @throws \Exception
[ "Set", "the", "whole", "object", "replacing", "all", "its", "properties", "and", "values", "by", "the", "new", "ones", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L383-L391
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.getObject
protected function getObject() { $object = $this->storage->getObject(); if (!($object instanceof StoredEntity)) { $object = new StoredEntity(); } return $object; }
php
protected function getObject() { $object = $this->storage->getObject(); if (!($object instanceof StoredEntity)) { $object = new StoredEntity(); } return $object; }
[ "protected", "function", "getObject", "(", ")", "{", "$", "object", "=", "$", "this", "->", "storage", "->", "getObject", "(", ")", ";", "if", "(", "!", "(", "$", "object", "instanceof", "StoredEntity", ")", ")", "{", "$", "object", "=", "new", "Stor...
Creates or validates an object coming from storage. @access protected @return StoredEntity
[ "Creates", "or", "validates", "an", "object", "coming", "from", "storage", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L399-L407
train
ninsuo/php-shared-memory
src/Fuz/Component/SharedMemory/SharedMemory.php
SharedMemory.getObjectSafely
protected function getObjectSafely($openCallback) { $elapsed = 0; $object = $this->getObject(); if ($this->lock === false) { while ($object->isLocked()) { $this->storage->close(); usleep($object->getInterval()); $this->storage->{$openCallback}(); $object = $this->getObject(); if ($object->getTimeout() > 0) { $elapsed += $object->getInterval(); if (floor($elapsed / 1000000) >= $object->getTimeout()) { throw new \Exception(sprintf("Can't access shared object, it is still locked after %d second(s).", $object->getTimeout())); } } } } return $object; }
php
protected function getObjectSafely($openCallback) { $elapsed = 0; $object = $this->getObject(); if ($this->lock === false) { while ($object->isLocked()) { $this->storage->close(); usleep($object->getInterval()); $this->storage->{$openCallback}(); $object = $this->getObject(); if ($object->getTimeout() > 0) { $elapsed += $object->getInterval(); if (floor($elapsed / 1000000) >= $object->getTimeout()) { throw new \Exception(sprintf("Can't access shared object, it is still locked after %d second(s).", $object->getTimeout())); } } } } return $object; }
[ "protected", "function", "getObjectSafely", "(", "$", "openCallback", ")", "{", "$", "elapsed", "=", "0", ";", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "if", "(", "$", "this", "->", "lock", "===", "false", ")", "{", "while",...
Recovers the object if the mutex-style lock is released. @access protected @param callable $openCallback @return StoredEntity @throws \Exception
[ "Recovers", "the", "object", "if", "the", "mutex", "-", "style", "lock", "is", "released", "." ]
ff08f15fe010ad07063f287363e692f9e7816b0d
https://github.com/ninsuo/php-shared-memory/blob/ff08f15fe010ad07063f287363e692f9e7816b0d/src/Fuz/Component/SharedMemory/SharedMemory.php#L417-L441
train
enniel/ami
src/Providers/AmiServiceProvider.php
AmiServiceProvider.registerAmiAction
protected function registerAmiAction() { $this->app->singleton(AmiAction::class, function ($app) { return new AmiAction($app['events'], $app['ami.eventloop'], $app['ami.factory'], $app['config']['ami']); }); $this->app->alias(AmiAction::class, 'command.ami.action'); }
php
protected function registerAmiAction() { $this->app->singleton(AmiAction::class, function ($app) { return new AmiAction($app['events'], $app['ami.eventloop'], $app['ami.factory'], $app['config']['ami']); }); $this->app->alias(AmiAction::class, 'command.ami.action'); }
[ "protected", "function", "registerAmiAction", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "AmiAction", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "AmiAction", "(", "$", "app", "[", "'events'", "]", ...
Register the ami action sender.
[ "Register", "the", "ami", "action", "sender", "." ]
090442334a28a6b3f4236823c22fd8142199edbf
https://github.com/enniel/ami/blob/090442334a28a6b3f4236823c22fd8142199edbf/src/Providers/AmiServiceProvider.php#L86-L92
train
enniel/ami
src/Providers/AmiServiceProvider.php
AmiServiceProvider.registerDongleSms
protected function registerDongleSms() { $this->app->singleton(AmiSms::class, function ($app) { return new AmiSms($app['events'], $app['ami.eventloop'], $app['ami.factory'], $app['config']['ami']); }); $this->app->alias(AmiSms::class, 'command.ami.dongle.sms'); }
php
protected function registerDongleSms() { $this->app->singleton(AmiSms::class, function ($app) { return new AmiSms($app['events'], $app['ami.eventloop'], $app['ami.factory'], $app['config']['ami']); }); $this->app->alias(AmiSms::class, 'command.ami.dongle.sms'); }
[ "protected", "function", "registerDongleSms", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "AmiSms", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "AmiSms", "(", "$", "app", "[", "'events'", "]", ",", ...
Register the dongle sms.
[ "Register", "the", "dongle", "sms", "." ]
090442334a28a6b3f4236823c22fd8142199edbf
https://github.com/enniel/ami/blob/090442334a28a6b3f4236823c22fd8142199edbf/src/Providers/AmiServiceProvider.php#L97-L103
train
enniel/ami
src/Providers/AmiServiceProvider.php
AmiServiceProvider.registerDongleUssd
protected function registerDongleUssd() { $this->app->singleton(AmiUssd::class, function ($app) { return new AmiUssd(); }); $this->app->alias(AmiUssd::class, 'command.ami.dongle.ussd'); }
php
protected function registerDongleUssd() { $this->app->singleton(AmiUssd::class, function ($app) { return new AmiUssd(); }); $this->app->alias(AmiUssd::class, 'command.ami.dongle.ussd'); }
[ "protected", "function", "registerDongleUssd", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "AmiUssd", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "AmiUssd", "(", ")", ";", "}", ")", ";", "$", "this...
Register the dongle ussd.
[ "Register", "the", "dongle", "ussd", "." ]
090442334a28a6b3f4236823c22fd8142199edbf
https://github.com/enniel/ami/blob/090442334a28a6b3f4236823c22fd8142199edbf/src/Providers/AmiServiceProvider.php#L108-L114
train
enniel/ami
src/Providers/AmiServiceProvider.php
AmiServiceProvider.registerEventLoop
protected function registerEventLoop() { $this->app->singleton(LoopInterface::class, function () { return new StreamSelectLoop(); }); $this->app->alias(LoopInterface::class, 'ami.eventloop'); }
php
protected function registerEventLoop() { $this->app->singleton(LoopInterface::class, function () { return new StreamSelectLoop(); }); $this->app->alias(LoopInterface::class, 'ami.eventloop'); }
[ "protected", "function", "registerEventLoop", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "LoopInterface", "::", "class", ",", "function", "(", ")", "{", "return", "new", "StreamSelectLoop", "(", ")", ";", "}", ")", ";", "$", "this",...
Register event loop.
[ "Register", "event", "loop", "." ]
090442334a28a6b3f4236823c22fd8142199edbf
https://github.com/enniel/ami/blob/090442334a28a6b3f4236823c22fd8142199edbf/src/Providers/AmiServiceProvider.php#L119-L125
train
enniel/ami
src/Providers/AmiServiceProvider.php
AmiServiceProvider.registerConnector
protected function registerConnector() { $this->app->singleton(ConnectorInterface::class, function ($app) { $loop = $app[LoopInterface::class]; return new Connector($loop, (new DnsResolver())->create('8.8.8.8', $loop)); }); $this->app->alias(ConnectorInterface::class, 'ami.connector'); }
php
protected function registerConnector() { $this->app->singleton(ConnectorInterface::class, function ($app) { $loop = $app[LoopInterface::class]; return new Connector($loop, (new DnsResolver())->create('8.8.8.8', $loop)); }); $this->app->alias(ConnectorInterface::class, 'ami.connector'); }
[ "protected", "function", "registerConnector", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "ConnectorInterface", "::", "class", ",", "function", "(", "$", "app", ")", "{", "$", "loop", "=", "$", "app", "[", "LoopInterface", "::", "cla...
Register connector.
[ "Register", "connector", "." ]
090442334a28a6b3f4236823c22fd8142199edbf
https://github.com/enniel/ami/blob/090442334a28a6b3f4236823c22fd8142199edbf/src/Providers/AmiServiceProvider.php#L130-L138
train
enniel/ami
src/Providers/AmiServiceProvider.php
AmiServiceProvider.registerFactory
protected function registerFactory() { $this->app->singleton(Factory::class, function ($app) { return new Factory($app[LoopInterface::class], $app[ConnectorInterface::class]); }); $this->app->alias(Factory::class, 'ami.factory'); }
php
protected function registerFactory() { $this->app->singleton(Factory::class, function ($app) { return new Factory($app[LoopInterface::class], $app[ConnectorInterface::class]); }); $this->app->alias(Factory::class, 'ami.factory'); }
[ "protected", "function", "registerFactory", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "Factory", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Factory", "(", "$", "app", "[", "LoopInterface", "::", ...
Register factory.
[ "Register", "factory", "." ]
090442334a28a6b3f4236823c22fd8142199edbf
https://github.com/enniel/ami/blob/090442334a28a6b3f4236823c22fd8142199edbf/src/Providers/AmiServiceProvider.php#L143-L149
train
LasseRafn/php-initials
src/Initials.php
Initials.length
public function length($length = 2) { $this->length = (int) $length; $this->initials = $this->generateInitials(); return $this; }
php
public function length($length = 2) { $this->length = (int) $length; $this->initials = $this->generateInitials(); return $this; }
[ "public", "function", "length", "(", "$", "length", "=", "2", ")", "{", "$", "this", "->", "length", "=", "(", "int", ")", "$", "length", ";", "$", "this", "->", "initials", "=", "$", "this", "->", "generateInitials", "(", ")", ";", "return", "$", ...
Set the length of the generated initials. @param int $length @return Initials
[ "Set", "the", "length", "of", "the", "generated", "initials", "." ]
ba4669e77552986998a9d1b34515a4e0c0f7acd2
https://github.com/LasseRafn/php-initials/blob/ba4669e77552986998a9d1b34515a4e0c0f7acd2/src/Initials.php#L48-L54
train
LasseRafn/php-initials
src/Initials.php
Initials.generate
public function generate($name = null) { if ($name !== null) { $this->name = $name; $this->initials = $this->generateInitials(); } return (string) $this; }
php
public function generate($name = null) { if ($name !== null) { $this->name = $name; $this->initials = $this->generateInitials(); } return (string) $this; }
[ "public", "function", "generate", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "!==", "null", ")", "{", "$", "this", "->", "name", "=", "$", "name", ";", "$", "this", "->", "initials", "=", "$", "this", "->", "generateInitials",...
Generate the initials. @param null|string $name @return string
[ "Generate", "the", "initials", "." ]
ba4669e77552986998a9d1b34515a4e0c0f7acd2
https://github.com/LasseRafn/php-initials/blob/ba4669e77552986998a9d1b34515a4e0c0f7acd2/src/Initials.php#L63-L71
train
LasseRafn/php-initials
src/Initials.php
Initials.getUrlfriendlyInitials
public function getUrlfriendlyInitials() { $urlFriendlyInitials = $this->convertToUrlFriendlyString($this->getInitials()); $urlFriendlyInitials = mb_substr($urlFriendlyInitials, 0, $this->length); return $urlFriendlyInitials; }
php
public function getUrlfriendlyInitials() { $urlFriendlyInitials = $this->convertToUrlFriendlyString($this->getInitials()); $urlFriendlyInitials = mb_substr($urlFriendlyInitials, 0, $this->length); return $urlFriendlyInitials; }
[ "public", "function", "getUrlfriendlyInitials", "(", ")", "{", "$", "urlFriendlyInitials", "=", "$", "this", "->", "convertToUrlFriendlyString", "(", "$", "this", "->", "getInitials", "(", ")", ")", ";", "$", "urlFriendlyInitials", "=", "mb_substr", "(", "$", ...
Will return the generated initials, without special characters. @return string
[ "Will", "return", "the", "generated", "initials", "without", "special", "characters", "." ]
ba4669e77552986998a9d1b34515a4e0c0f7acd2
https://github.com/LasseRafn/php-initials/blob/ba4669e77552986998a9d1b34515a4e0c0f7acd2/src/Initials.php#L89-L96
train
LasseRafn/php-initials
src/Initials.php
Initials.generateInitials
private function generateInitials() { $nameOrInitials = trim($this->name); if( !$this->keepCase ) { $nameOrInitials = mb_strtoupper($nameOrInitials); } $names = explode(' ', $nameOrInitials); $initials = $nameOrInitials; $assignedNames = 0; if (count($names) > 1) { $initials = ''; $start = 0; for ($i = 0; $i < $this->length; $i++) { $index = $i; if (($index === ($this->length - 1) && $index > 0) || ($index > (count($names) - 1))) { $index = count($names) - 1; } if ($assignedNames >= count($names)) { $start++; } $initials .= mb_substr($names[$index], $start, 1); $assignedNames++; } } $initials = mb_substr($initials, 0, $this->length); return $initials; }
php
private function generateInitials() { $nameOrInitials = trim($this->name); if( !$this->keepCase ) { $nameOrInitials = mb_strtoupper($nameOrInitials); } $names = explode(' ', $nameOrInitials); $initials = $nameOrInitials; $assignedNames = 0; if (count($names) > 1) { $initials = ''; $start = 0; for ($i = 0; $i < $this->length; $i++) { $index = $i; if (($index === ($this->length - 1) && $index > 0) || ($index > (count($names) - 1))) { $index = count($names) - 1; } if ($assignedNames >= count($names)) { $start++; } $initials .= mb_substr($names[$index], $start, 1); $assignedNames++; } } $initials = mb_substr($initials, 0, $this->length); return $initials; }
[ "private", "function", "generateInitials", "(", ")", "{", "$", "nameOrInitials", "=", "trim", "(", "$", "this", "->", "name", ")", ";", "if", "(", "!", "$", "this", "->", "keepCase", ")", "{", "$", "nameOrInitials", "=", "mb_strtoupper", "(", "$", "nam...
Generate a two-letter initial from a name, and if no name, assume its already initials. For safety, we limit it to two characters, in case its a single, but long, name. @return string
[ "Generate", "a", "two", "-", "letter", "initial", "from", "a", "name", "and", "if", "no", "name", "assume", "its", "already", "initials", ".", "For", "safety", "we", "limit", "it", "to", "two", "characters", "in", "case", "its", "a", "single", "but", "...
ba4669e77552986998a9d1b34515a4e0c0f7acd2
https://github.com/LasseRafn/php-initials/blob/ba4669e77552986998a9d1b34515a4e0c0f7acd2/src/Initials.php#L116-L151
train
LasseRafn/php-initials
src/Initials.php
Initials.convertToUrlFriendlyString
private function convertToUrlFriendlyString($string) { foreach (static::charsArray() as $key => $val) { $string = str_replace($val, mb_substr($key, 0, 1), $string); } return preg_replace('/[^\x20-\x7E]/u', '', $string); }
php
private function convertToUrlFriendlyString($string) { foreach (static::charsArray() as $key => $val) { $string = str_replace($val, mb_substr($key, 0, 1), $string); } return preg_replace('/[^\x20-\x7E]/u', '', $string); }
[ "private", "function", "convertToUrlFriendlyString", "(", "$", "string", ")", "{", "foreach", "(", "static", "::", "charsArray", "(", ")", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "string", "=", "str_replace", "(", "$", "val", ",", "mb_substr",...
Converts specialcharacters to url-friendly characters. Copied from: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Support/Str.php#L56 @param $string @return string
[ "Converts", "specialcharacters", "to", "url", "-", "friendly", "characters", "." ]
ba4669e77552986998a9d1b34515a4e0c0f7acd2
https://github.com/LasseRafn/php-initials/blob/ba4669e77552986998a9d1b34515a4e0c0f7acd2/src/Initials.php#L162-L169
train
merorafael/yii2-monolog
src/Mero/Monolog/Handler/Strategy.php
Strategy.hasFactory
protected function hasFactory($type) { if (!array_key_exists($type, $this->factories)) { throw new HandlerNotFoundException( sprintf("Type '%s' not found in handler factory", $type) ); } $factoryClass = &$this->factories[$type]; if (!class_exists($factoryClass)) { throw new \BadMethodCallException( sprintf("Type '%s' not implemented", $type) ); } return true; }
php
protected function hasFactory($type) { if (!array_key_exists($type, $this->factories)) { throw new HandlerNotFoundException( sprintf("Type '%s' not found in handler factory", $type) ); } $factoryClass = &$this->factories[$type]; if (!class_exists($factoryClass)) { throw new \BadMethodCallException( sprintf("Type '%s' not implemented", $type) ); } return true; }
[ "protected", "function", "hasFactory", "(", "$", "type", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "factories", ")", ")", "{", "throw", "new", "HandlerNotFoundException", "(", "sprintf", "(", "\"Type '%s' not fou...
Verifies that the factory class exists. @param string $type Name of type @return bool @throws HandlerNotFoundException When handler factory not found @throws \BadMethodCallException When handler not implemented
[ "Verifies", "that", "the", "factory", "class", "exists", "." ]
c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7
https://github.com/merorafael/yii2-monolog/blob/c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7/src/Mero/Monolog/Handler/Strategy.php#L80-L95
train
merorafael/yii2-monolog
src/Mero/Monolog/Handler/Strategy.php
Strategy.createFactory
public function createFactory(array $config) { if (!array_key_exists('type', $config)) { throw new ParameterNotFoundException( sprintf("Parameter '%s' not found in handler configuration", 'type') ); } $this->hasFactory($config['type']); if (isset($config['level'])) { $config['level'] = Logger::toMonologLevel($config['level']); } $factoryClass = &$this->factories[$config['type']]; return new $factoryClass($config); }
php
public function createFactory(array $config) { if (!array_key_exists('type', $config)) { throw new ParameterNotFoundException( sprintf("Parameter '%s' not found in handler configuration", 'type') ); } $this->hasFactory($config['type']); if (isset($config['level'])) { $config['level'] = Logger::toMonologLevel($config['level']); } $factoryClass = &$this->factories[$config['type']]; return new $factoryClass($config); }
[ "public", "function", "createFactory", "(", "array", "$", "config", ")", "{", "if", "(", "!", "array_key_exists", "(", "'type'", ",", "$", "config", ")", ")", "{", "throw", "new", "ParameterNotFoundException", "(", "sprintf", "(", "\"Parameter '%s' not found in ...
Create a factory object. @param array $config Configuration parameters @return AbstractFactory Factory object @throws ParameterNotFoundException When required parameter not found
[ "Create", "a", "factory", "object", "." ]
c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7
https://github.com/merorafael/yii2-monolog/blob/c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7/src/Mero/Monolog/Handler/Strategy.php#L106-L121
train
merorafael/yii2-monolog
src/Mero/Monolog/MonologComponent.php
MonologComponent.createChannel
public function createChannel($name, array $config) { $handlers = []; $processors = []; if (!empty($config['handler']) && is_array($config['handler'])) { foreach ($config['handler'] as $handler) { if (!is_array($handler) && !$handler instanceof AbstractHandler) { throw new HandlerNotFoundException(); } if (is_array($handler)) { $handlerObject = $this->createHandlerInstance($handler); if (array_key_exists('formatter', $handler) && $handler['formatter'] instanceof FormatterInterface ) { $handlerObject->setFormatter($handler['formatter']); } } else { $handlerObject = $handler; } $handlers[] = $handlerObject; } } if (!empty($config['processor']) && is_array($config['processor'])) { $processors = $config['processor']; } $this->openChannel($name, $handlers, $processors); return; }
php
public function createChannel($name, array $config) { $handlers = []; $processors = []; if (!empty($config['handler']) && is_array($config['handler'])) { foreach ($config['handler'] as $handler) { if (!is_array($handler) && !$handler instanceof AbstractHandler) { throw new HandlerNotFoundException(); } if (is_array($handler)) { $handlerObject = $this->createHandlerInstance($handler); if (array_key_exists('formatter', $handler) && $handler['formatter'] instanceof FormatterInterface ) { $handlerObject->setFormatter($handler['formatter']); } } else { $handlerObject = $handler; } $handlers[] = $handlerObject; } } if (!empty($config['processor']) && is_array($config['processor'])) { $processors = $config['processor']; } $this->openChannel($name, $handlers, $processors); return; }
[ "public", "function", "createChannel", "(", "$", "name", ",", "array", "$", "config", ")", "{", "$", "handlers", "=", "[", "]", ";", "$", "processors", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'handler'", "]", ")", "...
Create a logger channel. @param string $name Logger channel name @param array $config Logger channel configuration @throws \InvalidArgumentException When the channel already exists @throws HandlerNotFoundException When a handler configuration is invalid
[ "Create", "a", "logger", "channel", "." ]
c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7
https://github.com/merorafael/yii2-monolog/blob/c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7/src/Mero/Monolog/MonologComponent.php#L67-L95
train
merorafael/yii2-monolog
src/Mero/Monolog/MonologComponent.php
MonologComponent.openChannel
protected function openChannel($name, array $handlers, array $processors) { if (isset($this->channels[$name]) && $this->channels[$name] instanceof Logger) { throw new \InvalidArgumentException("Channel '{$name}' already exists"); } $this->channels[$name] = new Logger($name, $handlers, $processors); return; }
php
protected function openChannel($name, array $handlers, array $processors) { if (isset($this->channels[$name]) && $this->channels[$name] instanceof Logger) { throw new \InvalidArgumentException("Channel '{$name}' already exists"); } $this->channels[$name] = new Logger($name, $handlers, $processors); return; }
[ "protected", "function", "openChannel", "(", "$", "name", ",", "array", "$", "handlers", ",", "array", "$", "processors", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "channels", "[", "$", "name", "]", ")", "&&", "$", "this", "->", "channels...
Open a new logger channel. @param string $name Logger channel name @param array $handlers Handlers collection @param array $processors Processors collection
[ "Open", "a", "new", "logger", "channel", "." ]
c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7
https://github.com/merorafael/yii2-monolog/blob/c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7/src/Mero/Monolog/MonologComponent.php#L104-L113
train
merorafael/yii2-monolog
src/Mero/Monolog/MonologComponent.php
MonologComponent.hasLogger
public function hasLogger($name) { return isset($this->channels[$name]) && ($this->channels[$name] instanceof Logger); }
php
public function hasLogger($name) { return isset($this->channels[$name]) && ($this->channels[$name] instanceof Logger); }
[ "public", "function", "hasLogger", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "channels", "[", "$", "name", "]", ")", "&&", "(", "$", "this", "->", "channels", "[", "$", "name", "]", "instanceof", "Logger", ")", ";", "}"...
Checks if the given logger exists. @param string $name Logger name @return bool
[ "Checks", "if", "the", "given", "logger", "exists", "." ]
c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7
https://github.com/merorafael/yii2-monolog/blob/c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7/src/Mero/Monolog/MonologComponent.php#L150-L153
train
merorafael/yii2-monolog
src/Mero/Monolog/MonologComponent.php
MonologComponent.getLogger
public function getLogger($name = 'main') { if (!$this->hasLogger($name)) { throw new LoggerNotFoundException(sprintf("Logger instance '%s' not found", $name)); } return $this->channels[$name]; }
php
public function getLogger($name = 'main') { if (!$this->hasLogger($name)) { throw new LoggerNotFoundException(sprintf("Logger instance '%s' not found", $name)); } return $this->channels[$name]; }
[ "public", "function", "getLogger", "(", "$", "name", "=", "'main'", ")", "{", "if", "(", "!", "$", "this", "->", "hasLogger", "(", "$", "name", ")", ")", "{", "throw", "new", "LoggerNotFoundException", "(", "sprintf", "(", "\"Logger instance '%s' not found\"...
Return logger object. @param string $name Logger name @return Logger Logger object @throws LoggerNotFoundException
[ "Return", "logger", "object", "." ]
c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7
https://github.com/merorafael/yii2-monolog/blob/c3aaa8bb3bfa51c50e44672a134221dde2fcb2a7/src/Mero/Monolog/MonologComponent.php#L164-L171
train
raulfraile/distill
src/Method/AbstractMethod.php
AbstractMethod.guessType
protected function guessType() { $os = strtolower(PHP_OS); if (false !== strpos($os, 'cygwin')) { return self::OS_TYPE_CYGWIN; } if (false !== strpos($os, 'darwin')) { return self::OS_TYPE_DARWIN; } if (false !== strpos($os, 'bsd')) { return self::OS_TYPE_BSD; } if (0 === strpos($os, 'win')) { return self::OS_TYPE_WINDOWS; } return self::OS_TYPE_UNIX; }
php
protected function guessType() { $os = strtolower(PHP_OS); if (false !== strpos($os, 'cygwin')) { return self::OS_TYPE_CYGWIN; } if (false !== strpos($os, 'darwin')) { return self::OS_TYPE_DARWIN; } if (false !== strpos($os, 'bsd')) { return self::OS_TYPE_BSD; } if (0 === strpos($os, 'win')) { return self::OS_TYPE_WINDOWS; } return self::OS_TYPE_UNIX; }
[ "protected", "function", "guessType", "(", ")", "{", "$", "os", "=", "strtolower", "(", "PHP_OS", ")", ";", "if", "(", "false", "!==", "strpos", "(", "$", "os", ",", "'cygwin'", ")", ")", "{", "return", "self", "::", "OS_TYPE_CYGWIN", ";", "}", "if",...
Guesses OS type. @return int
[ "Guesses", "OS", "type", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Method/AbstractMethod.php#L92-L109
train
raulfraile/distill
src/Method/Native/TarExtractor.php
TarExtractor.calculateChecksum
protected function calculateChecksum($headerBlock) { $checksum = 0; for ($i = 0; $i<self::SIZE_HEADER_BLOCK; $i++) { if ($i < 148 || $i >= 156) { $checksum += ord($headerBlock[$i]); } else { $checksum += 32; } } return $checksum; }
php
protected function calculateChecksum($headerBlock) { $checksum = 0; for ($i = 0; $i<self::SIZE_HEADER_BLOCK; $i++) { if ($i < 148 || $i >= 156) { $checksum += ord($headerBlock[$i]); } else { $checksum += 32; } } return $checksum; }
[ "protected", "function", "calculateChecksum", "(", "$", "headerBlock", ")", "{", "$", "checksum", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "self", "::", "SIZE_HEADER_BLOCK", ";", "$", "i", "++", ")", "{", "if", "(", "$", ...
Calculates the checksum of the header block. The checksum is calculated by taking the sum of the unsigned byte values of the header record with the eight checksum bytes taken to be ascii spaces (decimal value 32). @param string $headerBlock @return int
[ "Calculates", "the", "checksum", "of", "the", "header", "block", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Method/Native/TarExtractor.php#L131-L143
train
raulfraile/distill
src/Method/Native/GzipExtractor.php
GzipExtractor.getFixedHuffmanTrees
protected function getFixedHuffmanTrees() { return [ HuffmanTree::createFromLengths(array_merge( array_fill_keys(range(0, 143), 8), array_fill_keys(range(144, 255), 9), array_fill_keys(range(256, 279), 7), array_fill_keys(range(280, 287), 8) )), HuffmanTree::createFromLengths(array_fill_keys(range(0, 31), 5)) ]; }
php
protected function getFixedHuffmanTrees() { return [ HuffmanTree::createFromLengths(array_merge( array_fill_keys(range(0, 143), 8), array_fill_keys(range(144, 255), 9), array_fill_keys(range(256, 279), 7), array_fill_keys(range(280, 287), 8) )), HuffmanTree::createFromLengths(array_fill_keys(range(0, 31), 5)) ]; }
[ "protected", "function", "getFixedHuffmanTrees", "(", ")", "{", "return", "[", "HuffmanTree", "::", "createFromLengths", "(", "array_merge", "(", "array_fill_keys", "(", "range", "(", "0", ",", "143", ")", ",", "8", ")", ",", "array_fill_keys", "(", "range", ...
Creates the Huffman codes for literals and distances for fixed Huffman compression. @return HuffmanTree[] Literals tree and distances tree.
[ "Creates", "the", "Huffman", "codes", "for", "literals", "and", "distances", "for", "fixed", "Huffman", "compression", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Method/Native/GzipExtractor.php#L238-L249
train
raulfraile/distill
src/Extractor/Util/Filesystem.php
Filesystem.unlink
private function unlink($path) { if (!@$this->unlinkImplementation($path)) { // retry after a bit on windows since it tends to be touchy with mass removals if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(350000) && !@$this->unlinkImplementation($path))) { $error = error_get_last(); $message = 'Could not delete '.$path.': '.@$error['message']; if (defined('PHP_WINDOWS_VERSION_BUILD')) { $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed"; } throw new \RuntimeException($message); } } return true; }
php
private function unlink($path) { if (!@$this->unlinkImplementation($path)) { // retry after a bit on windows since it tends to be touchy with mass removals if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(350000) && !@$this->unlinkImplementation($path))) { $error = error_get_last(); $message = 'Could not delete '.$path.': '.@$error['message']; if (defined('PHP_WINDOWS_VERSION_BUILD')) { $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed"; } throw new \RuntimeException($message); } } return true; }
[ "private", "function", "unlink", "(", "$", "path", ")", "{", "if", "(", "!", "@", "$", "this", "->", "unlinkImplementation", "(", "$", "path", ")", ")", "{", "// retry after a bit on windows since it tends to be touchy with mass removals", "if", "(", "!", "defined...
Attempts to unlink a file and in case of failure retries after 350ms on windows @param string $path @return bool @throws \RuntimeException
[ "Attempts", "to", "unlink", "a", "file", "and", "in", "case", "of", "failure", "retries", "after", "350ms", "on", "windows" ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Extractor/Util/Filesystem.php#L140-L156
train
raulfraile/distill
src/Extractor/Util/Filesystem.php
Filesystem.rmdir
private function rmdir($path) { if (!@rmdir($path)) { // retry after a bit on windows since it tends to be touchy with mass removals if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(350000) && !@rmdir($path))) { $error = error_get_last(); $message = 'Could not delete '.$path.': '.@$error['message']; if (defined('PHP_WINDOWS_VERSION_BUILD')) { $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed"; } throw new \RuntimeException($message); } } return true; }
php
private function rmdir($path) { if (!@rmdir($path)) { // retry after a bit on windows since it tends to be touchy with mass removals if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(350000) && !@rmdir($path))) { $error = error_get_last(); $message = 'Could not delete '.$path.': '.@$error['message']; if (defined('PHP_WINDOWS_VERSION_BUILD')) { $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed"; } throw new \RuntimeException($message); } } return true; }
[ "private", "function", "rmdir", "(", "$", "path", ")", "{", "if", "(", "!", "@", "rmdir", "(", "$", "path", ")", ")", "{", "// retry after a bit on windows since it tends to be touchy with mass removals", "if", "(", "!", "defined", "(", "'PHP_WINDOWS_VERSION_BUILD'"...
Attempts to rmdir a file and in case of failure retries after 350ms on windows @param string $path @return bool @throws \RuntimeException
[ "Attempts", "to", "rmdir", "a", "file", "and", "in", "case", "of", "failure", "retries", "after", "350ms", "on", "windows" ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Extractor/Util/Filesystem.php#L166-L182
train
raulfraile/distill
src/Extractor/Util/ProcessExecutor.php
ProcessExecutor.execute
public function execute($command, &$output = null, $cwd = null) { // make sure that null translate to the proper directory in case the dir is a symlink // and we call a git command, because msysgit does not handle symlinks properly if (null === $cwd && defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($command, 'git') && getcwd()) { $cwd = realpath(getcwd()); } $this->captureOutput = count(func_get_args()) > 1; $this->errorOutput = null; $process = new Process($command, $cwd, null, null, static::getTimeout()); $callback = is_callable($output) ? $output : array($this, 'outputHandler'); $process->run($callback); if ($this->captureOutput && !is_callable($output)) { $output = $process->getOutput(); } $this->errorOutput = $process->getErrorOutput(); return $process->getExitCode(); }
php
public function execute($command, &$output = null, $cwd = null) { // make sure that null translate to the proper directory in case the dir is a symlink // and we call a git command, because msysgit does not handle symlinks properly if (null === $cwd && defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($command, 'git') && getcwd()) { $cwd = realpath(getcwd()); } $this->captureOutput = count(func_get_args()) > 1; $this->errorOutput = null; $process = new Process($command, $cwd, null, null, static::getTimeout()); $callback = is_callable($output) ? $output : array($this, 'outputHandler'); $process->run($callback); if ($this->captureOutput && !is_callable($output)) { $output = $process->getOutput(); } $this->errorOutput = $process->getErrorOutput(); return $process->getExitCode(); }
[ "public", "function", "execute", "(", "$", "command", ",", "&", "$", "output", "=", "null", ",", "$", "cwd", "=", "null", ")", "{", "// make sure that null translate to the proper directory in case the dir is a symlink", "// and we call a git command, because msysgit does not...
runs a process on the commandline @param string $command the command to execute @param mixed $output the output will be written into this var if passed by ref if a callable is passed it will be used as output handler @param string $cwd the working directory @return int statuscode
[ "runs", "a", "process", "on", "the", "commandline" ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Extractor/Util/ProcessExecutor.php#L37-L59
train
raulfraile/distill
src/ContainerProvider.php
ContainerProvider.registerFormats
protected function registerFormats(Container $container) { foreach ($this->formats as $formatClass) { $container['format.'.$formatClass::getName()] = $container->factory(function() use ($formatClass) { return new $formatClass(); }); } }
php
protected function registerFormats(Container $container) { foreach ($this->formats as $formatClass) { $container['format.'.$formatClass::getName()] = $container->factory(function() use ($formatClass) { return new $formatClass(); }); } }
[ "protected", "function", "registerFormats", "(", "Container", "$", "container", ")", "{", "foreach", "(", "$", "this", "->", "formats", "as", "$", "formatClass", ")", "{", "$", "container", "[", "'format.'", ".", "$", "formatClass", "::", "getName", "(", "...
Registers the formats. @param Container $container Container
[ "Registers", "the", "formats", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/ContainerProvider.php#L152-L159
train
raulfraile/distill
src/ContainerProvider.php
ContainerProvider.registerMethods
protected function registerMethods(Container $container) { $orderedMethods = []; foreach ($this->methods as $methodClass) { /** @var MethodInterface $method */ $method = new $methodClass(); if ($method->isSupported()) { $container['method.'.$method->getName()] = function() use ($methodClass) { return new $methodClass(); }; $orderedMethods[] = 'method.'.$method->getName(); } } // order methods usort($orderedMethods, function ($methodName1, $methodName2) use ($container) { $value1 = ((int) $container[$methodName1]->isSupported()) + ($container[$methodName1]->getUncompressionSpeedLevel() / 10); $value2 = ((int) $container[$methodName2]->isSupported()) + ($container[$methodName2]->getUncompressionSpeedLevel() / 10); if ($value1 == $value2) { return 0; } return ($value1 > $value2) ? -1 : 1; }); $container['method.__ordered'] = $orderedMethods; }
php
protected function registerMethods(Container $container) { $orderedMethods = []; foreach ($this->methods as $methodClass) { /** @var MethodInterface $method */ $method = new $methodClass(); if ($method->isSupported()) { $container['method.'.$method->getName()] = function() use ($methodClass) { return new $methodClass(); }; $orderedMethods[] = 'method.'.$method->getName(); } } // order methods usort($orderedMethods, function ($methodName1, $methodName2) use ($container) { $value1 = ((int) $container[$methodName1]->isSupported()) + ($container[$methodName1]->getUncompressionSpeedLevel() / 10); $value2 = ((int) $container[$methodName2]->isSupported()) + ($container[$methodName2]->getUncompressionSpeedLevel() / 10); if ($value1 == $value2) { return 0; } return ($value1 > $value2) ? -1 : 1; }); $container['method.__ordered'] = $orderedMethods; }
[ "protected", "function", "registerMethods", "(", "Container", "$", "container", ")", "{", "$", "orderedMethods", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "methods", "as", "$", "methodClass", ")", "{", "/** @var MethodInterface $method */", "$", "...
Register the uncompression methods. @param Container $container
[ "Register", "the", "uncompression", "methods", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/ContainerProvider.php#L165-L195
train
raulfraile/distill
src/Distill.php
Distill.initialize
protected function initialize() { $this->container = new Container(); $containerProvider = new ContainerProvider($this->disabledMethods, $this->disabledFormats); $this->container->register($containerProvider); $this->initialized = false; }
php
protected function initialize() { $this->container = new Container(); $containerProvider = new ContainerProvider($this->disabledMethods, $this->disabledFormats); $this->container->register($containerProvider); $this->initialized = false; }
[ "protected", "function", "initialize", "(", ")", "{", "$", "this", "->", "container", "=", "new", "Container", "(", ")", ";", "$", "containerProvider", "=", "new", "ContainerProvider", "(", "$", "this", "->", "disabledMethods", ",", "$", "this", "->", "dis...
Initialize the DIC.
[ "Initialize", "the", "DIC", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Distill.php#L97-L105
train
raulfraile/distill
src/Method/Native/GzipExtractor/BitReader.php
BitReader.readByte
protected function readByte() { if (feof($this->fileHandler)) { return false; } $data = unpack('C1byte', fread($this->fileHandler, 1)); $this->currentByte = $data['byte']; $this->currentBitPosition = 0; return true; }
php
protected function readByte() { if (feof($this->fileHandler)) { return false; } $data = unpack('C1byte', fread($this->fileHandler, 1)); $this->currentByte = $data['byte']; $this->currentBitPosition = 0; return true; }
[ "protected", "function", "readByte", "(", ")", "{", "if", "(", "feof", "(", "$", "this", "->", "fileHandler", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "unpack", "(", "'C1byte'", ",", "fread", "(", "$", "this", "->", "fileHandler"...
Reads a byte from the file. @return bool
[ "Reads", "a", "byte", "from", "the", "file", "." ]
9ab33b98651bd15c2d6d70bf8c78eda0068fe52b
https://github.com/raulfraile/distill/blob/9ab33b98651bd15c2d6d70bf8c78eda0068fe52b/src/Method/Native/GzipExtractor/BitReader.php#L105-L116
train
AydinHassan/magento-core-composer-installer
src/Exclude.php
Exclude.exclude
public function exclude($filePath) { foreach ($this->excludes as $exclude) { if ($this->isExcludeDir($exclude)) { if (substr($filePath, 0, strlen($exclude)) === $exclude) { return true; } } elseif ($exclude === $filePath) { return true; } } return false; }
php
public function exclude($filePath) { foreach ($this->excludes as $exclude) { if ($this->isExcludeDir($exclude)) { if (substr($filePath, 0, strlen($exclude)) === $exclude) { return true; } } elseif ($exclude === $filePath) { return true; } } return false; }
[ "public", "function", "exclude", "(", "$", "filePath", ")", "{", "foreach", "(", "$", "this", "->", "excludes", "as", "$", "exclude", ")", "{", "if", "(", "$", "this", "->", "isExcludeDir", "(", "$", "exclude", ")", ")", "{", "if", "(", "substr", "...
Should we exclude this file from the install? @param string $filePath @return bool
[ "Should", "we", "exclude", "this", "file", "from", "the", "install?" ]
3e986ad18ff57847f543a850bc48b62ece411a23
https://github.com/AydinHassan/magento-core-composer-installer/blob/3e986ad18ff57847f543a850bc48b62ece411a23/src/Exclude.php#L40-L54
train
AydinHassan/magento-core-composer-installer
src/GitIgnore.php
GitIgnore.addEntriesForDirectoriesToIgnoreEntirely
protected function addEntriesForDirectoriesToIgnoreEntirely() { foreach ($this->directoriesToIgnoreEntirely as $directory) { if (!in_array($directory, $this->lines)) { $this->lines[] = $directory; $this->hasChanges = true; } } }
php
protected function addEntriesForDirectoriesToIgnoreEntirely() { foreach ($this->directoriesToIgnoreEntirely as $directory) { if (!in_array($directory, $this->lines)) { $this->lines[] = $directory; $this->hasChanges = true; } } }
[ "protected", "function", "addEntriesForDirectoriesToIgnoreEntirely", "(", ")", "{", "foreach", "(", "$", "this", "->", "directoriesToIgnoreEntirely", "as", "$", "directory", ")", "{", "if", "(", "!", "in_array", "(", "$", "directory", ",", "$", "this", "->", "...
Add entries to for all directories ignored entirely.
[ "Add", "entries", "to", "for", "all", "directories", "ignored", "entirely", "." ]
3e986ad18ff57847f543a850bc48b62ece411a23
https://github.com/AydinHassan/magento-core-composer-installer/blob/3e986ad18ff57847f543a850bc48b62ece411a23/src/GitIgnore.php#L135-L143
train
AydinHassan/magento-core-composer-installer
src/CoreManager.php
CoreManager.getSubscribedEvents
public static function getSubscribedEvents() { return array( InstallerEvents::POST_DEPENDENCIES_SOLVING => array( array('checkCoreDependencies', 0) ), PackageEvents::POST_PACKAGE_INSTALL => array( array('installCore', 0) ), PackageEvents::PRE_PACKAGE_UPDATE => array( array('uninstallCore', 0) ), PackageEvents::POST_PACKAGE_UPDATE => array( array('installCore', 0) ), PackageEvents::PRE_PACKAGE_UNINSTALL => array( array('uninstallCore', 0) ), ); }
php
public static function getSubscribedEvents() { return array( InstallerEvents::POST_DEPENDENCIES_SOLVING => array( array('checkCoreDependencies', 0) ), PackageEvents::POST_PACKAGE_INSTALL => array( array('installCore', 0) ), PackageEvents::PRE_PACKAGE_UPDATE => array( array('uninstallCore', 0) ), PackageEvents::POST_PACKAGE_UPDATE => array( array('installCore', 0) ), PackageEvents::PRE_PACKAGE_UNINSTALL => array( array('uninstallCore', 0) ), ); }
[ "public", "static", "function", "getSubscribedEvents", "(", ")", "{", "return", "array", "(", "InstallerEvents", "::", "POST_DEPENDENCIES_SOLVING", "=>", "array", "(", "array", "(", "'checkCoreDependencies'", ",", "0", ")", ")", ",", "PackageEvents", "::", "POST_P...
Tell event dispatcher what events we want to subscribe to @return array
[ "Tell", "event", "dispatcher", "what", "events", "we", "want", "to", "subscribe", "to" ]
3e986ad18ff57847f543a850bc48b62ece411a23
https://github.com/AydinHassan/magento-core-composer-installer/blob/3e986ad18ff57847f543a850bc48b62ece411a23/src/CoreManager.php#L97-L116
train
AydinHassan/magento-core-composer-installer
src/CoreManager.php
CoreManager.checkCoreDependencies
public function checkCoreDependencies(InstallerEvent $event) { $options = new Options($this->composer->getPackage()->getExtra()); $installedCorePackages = array(); foreach ($event->getInstalledRepo()->getPackages() as $package) { if ($package->getType() === $options->getMagentoCorePackageType()) { $installedCorePackages[$package->getName()] = $package; } } $operations = array_filter($event->getOperations(), function (OperationInterface $o) { return in_array($o->getJobType(), array('install', 'uninstall')); }); foreach ($operations as $operation) { $p = $operation->getPackage(); if ($package->getType() === $options->getMagentoCorePackageType()) { switch ($operation->getJobType()) { case "uninstall": unset($installedCorePackages[$p->getName()]); break; case "install": $installedCorePackages[$p->getName()] = $p; break; } } } if (count($installedCorePackages) > 1) { throw new \RuntimeException("Cannot use more than 1 core package"); } }
php
public function checkCoreDependencies(InstallerEvent $event) { $options = new Options($this->composer->getPackage()->getExtra()); $installedCorePackages = array(); foreach ($event->getInstalledRepo()->getPackages() as $package) { if ($package->getType() === $options->getMagentoCorePackageType()) { $installedCorePackages[$package->getName()] = $package; } } $operations = array_filter($event->getOperations(), function (OperationInterface $o) { return in_array($o->getJobType(), array('install', 'uninstall')); }); foreach ($operations as $operation) { $p = $operation->getPackage(); if ($package->getType() === $options->getMagentoCorePackageType()) { switch ($operation->getJobType()) { case "uninstall": unset($installedCorePackages[$p->getName()]); break; case "install": $installedCorePackages[$p->getName()] = $p; break; } } } if (count($installedCorePackages) > 1) { throw new \RuntimeException("Cannot use more than 1 core package"); } }
[ "public", "function", "checkCoreDependencies", "(", "InstallerEvent", "$", "event", ")", "{", "$", "options", "=", "new", "Options", "(", "$", "this", "->", "composer", "->", "getPackage", "(", ")", "->", "getExtra", "(", ")", ")", ";", "$", "installedCore...
Check that there is only 1 core package required
[ "Check", "that", "there", "is", "only", "1", "core", "package", "required" ]
3e986ad18ff57847f543a850bc48b62ece411a23
https://github.com/AydinHassan/magento-core-composer-installer/blob/3e986ad18ff57847f543a850bc48b62ece411a23/src/CoreManager.php#L121-L152
train
AydinHassan/magento-core-composer-installer
src/CoreManager.php
CoreManager.ensureRootDirExists
private function ensureRootDirExists(Options $options) { if (!file_exists($options->getMagentoRootDir())) { mkdir($options->getMagentoRootDir(), 0755, true); } }
php
private function ensureRootDirExists(Options $options) { if (!file_exists($options->getMagentoRootDir())) { mkdir($options->getMagentoRootDir(), 0755, true); } }
[ "private", "function", "ensureRootDirExists", "(", "Options", "$", "options", ")", "{", "if", "(", "!", "file_exists", "(", "$", "options", "->", "getMagentoRootDir", "(", ")", ")", ")", "{", "mkdir", "(", "$", "options", "->", "getMagentoRootDir", "(", ")...
Create root directory if it doesn't exist already @param Options $options
[ "Create", "root", "directory", "if", "it", "doesn", "t", "exist", "already" ]
3e986ad18ff57847f543a850bc48b62ece411a23
https://github.com/AydinHassan/magento-core-composer-installer/blob/3e986ad18ff57847f543a850bc48b62ece411a23/src/CoreManager.php#L224-L229
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProperty.php
MoufReflectionProperty.getDeclaringClassWithoutTraits
public function getDeclaringClassWithoutTraits() { $refClass = parent::getDeclaringClass(); if ($refClass->getName() === $this->className) { if (null === $this->refClass) { $this->refClass = new MoufReflectionClass($this->className); } return $this->refClass; } $moufRefClass = new MoufReflectionClass($refClass->getName()); return $moufRefClass; }
php
public function getDeclaringClassWithoutTraits() { $refClass = parent::getDeclaringClass(); if ($refClass->getName() === $this->className) { if (null === $this->refClass) { $this->refClass = new MoufReflectionClass($this->className); } return $this->refClass; } $moufRefClass = new MoufReflectionClass($refClass->getName()); return $moufRefClass; }
[ "public", "function", "getDeclaringClassWithoutTraits", "(", ")", "{", "$", "refClass", "=", "parent", "::", "getDeclaringClass", "(", ")", ";", "if", "(", "$", "refClass", "->", "getName", "(", ")", "===", "$", "this", "->", "className", ")", "{", "if", ...
Returns the class that declares this parameter @return MoufReflectionClass
[ "Returns", "the", "class", "that", "declares", "this", "parameter" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProperty.php#L215-L228
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProperty.php
MoufReflectionProperty.getDefault
public function getDefault() { if ($this->isPublic() && !$this->isStatic() && $this->refClass->isAbstract() == false) { $className = $this->refClass->getName(); // TODO: find a way to get default value for abstract properties. // TODO: optimize this: we should not have to create one new instance for every property.... /*$instance = new $className(); $property = $this->getName(); return $instance->$property;*/ // In some cases, the call to getDefaultProperties can log NOTICES // in particular if an undefined constant is used as default value. ob_start(); $defaultProperties = $this->refClass->getDefaultProperties(); $possibleError = ob_get_clean(); if ($possibleError) { throw new \Exception($possibleError); } return $defaultProperties[$this->getName()]; } else { return null; } }
php
public function getDefault() { if ($this->isPublic() && !$this->isStatic() && $this->refClass->isAbstract() == false) { $className = $this->refClass->getName(); // TODO: find a way to get default value for abstract properties. // TODO: optimize this: we should not have to create one new instance for every property.... /*$instance = new $className(); $property = $this->getName(); return $instance->$property;*/ // In some cases, the call to getDefaultProperties can log NOTICES // in particular if an undefined constant is used as default value. ob_start(); $defaultProperties = $this->refClass->getDefaultProperties(); $possibleError = ob_get_clean(); if ($possibleError) { throw new \Exception($possibleError); } return $defaultProperties[$this->getName()]; } else { return null; } }
[ "public", "function", "getDefault", "(", ")", "{", "if", "(", "$", "this", "->", "isPublic", "(", ")", "&&", "!", "$", "this", "->", "isStatic", "(", ")", "&&", "$", "this", "->", "refClass", "->", "isAbstract", "(", ")", "==", "false", ")", "{", ...
Returns the default value @return mixed
[ "Returns", "the", "default", "value" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProperty.php#L235-L256
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProperty.php
MoufReflectionProperty.toJson
public function toJson() { $result = array(); $result['name'] = $this->getName(); $result['comment'] = $this->getMoufPhpDocComment()->getJsonArray(); /*$properties = $this->getAnnotations("Property"); if (!empty($properties)) { $result['moufProperty'] = true;*/ try { $result['default'] = $this->getDefault(); // TODO: is there a need to instanciate a MoufPropertyDescriptor? $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ //} return $result; }
php
public function toJson() { $result = array(); $result['name'] = $this->getName(); $result['comment'] = $this->getMoufPhpDocComment()->getJsonArray(); /*$properties = $this->getAnnotations("Property"); if (!empty($properties)) { $result['moufProperty'] = true;*/ try { $result['default'] = $this->getDefault(); // TODO: is there a need to instanciate a MoufPropertyDescriptor? $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ //} return $result; }
[ "public", "function", "toJson", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'name'", "]", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "result", "[", "'comment'", "]", "=", "$", "this", "->", "getMouf...
Returns a PHP array representing the property. @return array
[ "Returns", "a", "PHP", "array", "representing", "the", "property", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProperty.php#L295-L328
train
thecodingmachine/mouf
src/Mouf/Composer/ComposerService.php
ComposerService.registerAutoloader
public static function registerAutoloader() { if (null !== static::$loader) { return static::$loader; } static::$loader = $loader = new \Composer\Autoload\ClassLoader(); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); $map = require 'phar://'.__DIR__.'/../../../composer.phar/vendor/composer/autoload_namespaces.php'; foreach ($map as $namespace => $path) { $loader->set($namespace, $path); } $map = require 'phar://'.__DIR__.'/../../../composer.phar/vendor/composer/autoload_psr4.php'; foreach ($map as $namespace => $path) { $loader->setPsr4($namespace, $path); } $classMap = require 'phar://'.__DIR__.'/../../../composer.phar/vendor/composer/autoload_classmap.php'; if ($classMap) { $loader->addClassMap($classMap); } $loader->register(); return $loader; }
php
public static function registerAutoloader() { if (null !== static::$loader) { return static::$loader; } static::$loader = $loader = new \Composer\Autoload\ClassLoader(); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); $map = require 'phar://'.__DIR__.'/../../../composer.phar/vendor/composer/autoload_namespaces.php'; foreach ($map as $namespace => $path) { $loader->set($namespace, $path); } $map = require 'phar://'.__DIR__.'/../../../composer.phar/vendor/composer/autoload_psr4.php'; foreach ($map as $namespace => $path) { $loader->setPsr4($namespace, $path); } $classMap = require 'phar://'.__DIR__.'/../../../composer.phar/vendor/composer/autoload_classmap.php'; if ($classMap) { $loader->addClassMap($classMap); } $loader->register(); return $loader; }
[ "public", "static", "function", "registerAutoloader", "(", ")", "{", "if", "(", "null", "!==", "static", "::", "$", "loader", ")", "{", "return", "static", "::", "$", "loader", ";", "}", "static", "::", "$", "loader", "=", "$", "loader", "=", "new", ...
Register the autoloader for composer.
[ "Register", "the", "autoloader", "for", "composer", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ComposerService.php#L209-L237
train
thecodingmachine/mouf
src/Mouf/Composer/ComposerService.php
ComposerService.getComposer
public function getComposer() { if (null === $this->composer) { $this->configureEnv(); if ($this->outputBufferedJs) { $this->io = new MoufJsComposerIO(); } else { $this->io = new BufferIO(); } $this->composer = Factory::create($this->io, null, true); } return $this->composer; }
php
public function getComposer() { if (null === $this->composer) { $this->configureEnv(); if ($this->outputBufferedJs) { $this->io = new MoufJsComposerIO(); } else { $this->io = new BufferIO(); } $this->composer = Factory::create($this->io, null, true); } return $this->composer; }
[ "public", "function", "getComposer", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "composer", ")", "{", "$", "this", "->", "configureEnv", "(", ")", ";", "if", "(", "$", "this", "->", "outputBufferedJs", ")", "{", "$", "this", "->", ...
Exposes the Composer object @return Composer
[ "Exposes", "the", "Composer", "object" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ComposerService.php#L244-L257
train
thecodingmachine/mouf
src/Mouf/Composer/ComposerService.php
ComposerService.configureEnv
private function configureEnv() { if ($this->selfEdit) { chdir(__DIR__."/../../.."); \putenv('COMPOSER=composer-mouf.json'); } else { chdir(__DIR__."/../../../../../.."); } $composerHome = getenv('COMPOSER_HOME'); if (!$composerHome) { $composerTmpDir = sys_get_temp_dir().'/.mouf_composer/'; if (function_exists('posix_getpwuid')) { $processUser = posix_getpwuid(posix_geteuid()); $composerTmpDir .= $processUser['name'].'/'; } \putenv('COMPOSER_HOME='.$composerTmpDir); } }
php
private function configureEnv() { if ($this->selfEdit) { chdir(__DIR__."/../../.."); \putenv('COMPOSER=composer-mouf.json'); } else { chdir(__DIR__."/../../../../../.."); } $composerHome = getenv('COMPOSER_HOME'); if (!$composerHome) { $composerTmpDir = sys_get_temp_dir().'/.mouf_composer/'; if (function_exists('posix_getpwuid')) { $processUser = posix_getpwuid(posix_geteuid()); $composerTmpDir .= $processUser['name'].'/'; } \putenv('COMPOSER_HOME='.$composerTmpDir); } }
[ "private", "function", "configureEnv", "(", ")", "{", "if", "(", "$", "this", "->", "selfEdit", ")", "{", "chdir", "(", "__DIR__", ".", "\"/../../..\"", ")", ";", "\\", "putenv", "(", "'COMPOSER=composer-mouf.json'", ")", ";", "}", "else", "{", "chdir", ...
Changes the current working directory and set environment variables to be able to work with Composer.
[ "Changes", "the", "current", "working", "directory", "and", "set", "environment", "variables", "to", "be", "able", "to", "work", "with", "Composer", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ComposerService.php#L262-L280
train
thecodingmachine/mouf
src/Mouf/Composer/ComposerService.php
ComposerService.getLocalPackages
public function getLocalPackages() { $composer = $this->getComposer(); $dispatcher = new EventDispatcher($composer, $this->io); $autoloadGenerator = new \Composer\Autoload\AutoloadGenerator($dispatcher); if ($this->selfEdit) { chdir(__DIR__."/../../.."); \putenv('COMPOSER=composer-mouf.json'); } else { chdir(__DIR__."/../../../../../.."); } //TODO: this call is strange because it will return the same isntance as above. $composer = $this->getComposer(); $localRepos = new CompositeRepository(array($composer->getRepositoryManager()->getLocalRepository())); $package = $composer->getPackage(); $packagesList = $localRepos->getPackages(); $packagesList[] = $package; return $packagesList; }
php
public function getLocalPackages() { $composer = $this->getComposer(); $dispatcher = new EventDispatcher($composer, $this->io); $autoloadGenerator = new \Composer\Autoload\AutoloadGenerator($dispatcher); if ($this->selfEdit) { chdir(__DIR__."/../../.."); \putenv('COMPOSER=composer-mouf.json'); } else { chdir(__DIR__."/../../../../../.."); } //TODO: this call is strange because it will return the same isntance as above. $composer = $this->getComposer(); $localRepos = new CompositeRepository(array($composer->getRepositoryManager()->getLocalRepository())); $package = $composer->getPackage(); $packagesList = $localRepos->getPackages(); $packagesList[] = $package; return $packagesList; }
[ "public", "function", "getLocalPackages", "(", ")", "{", "$", "composer", "=", "$", "this", "->", "getComposer", "(", ")", ";", "$", "dispatcher", "=", "new", "EventDispatcher", "(", "$", "composer", ",", "$", "this", "->", "io", ")", ";", "$", "autolo...
Returns an array of Composer packages currently installed. @return PackageInterface[]
[ "Returns", "an", "array", "of", "Composer", "packages", "currently", "installed", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ComposerService.php#L311-L331
train
thecodingmachine/mouf
src/Mouf/Composer/ComposerService.php
ComposerService.searchPackages
public function searchPackages($text, OnPackageFoundInterface $callback, $onlyName = false, $includeLocal = true) { $this->onPackageFoundCallback = $callback; $composer = $this->getComposer(); $platformRepo = new PlatformRepository; $searched = array(); if ($includeLocal) { $localRepo = $composer->getRepositoryManager()->getLocalRepository(); $searched[] = $localRepo; } $searched[] = $platformRepo; $installedRepo = new CompositeRepository($searched); $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories())); //$this->onlyName = $input->getOption('only-name'); $this->onlyName = $onlyName; //$this->tokens = $input->getArgument('tokens'); $this->tokens = explode(" ", $text); //$this->output = $output; $repos->filterPackages(array($this, 'processPackage'), 'Composer\Package\CompletePackage'); /*foreach ($this->lowMatches as $details) { $output->writeln($details['name'] . '<comment>:</comment> '. $details['description']); }*/ }
php
public function searchPackages($text, OnPackageFoundInterface $callback, $onlyName = false, $includeLocal = true) { $this->onPackageFoundCallback = $callback; $composer = $this->getComposer(); $platformRepo = new PlatformRepository; $searched = array(); if ($includeLocal) { $localRepo = $composer->getRepositoryManager()->getLocalRepository(); $searched[] = $localRepo; } $searched[] = $platformRepo; $installedRepo = new CompositeRepository($searched); $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories())); //$this->onlyName = $input->getOption('only-name'); $this->onlyName = $onlyName; //$this->tokens = $input->getArgument('tokens'); $this->tokens = explode(" ", $text); //$this->output = $output; $repos->filterPackages(array($this, 'processPackage'), 'Composer\Package\CompletePackage'); /*foreach ($this->lowMatches as $details) { $output->writeln($details['name'] . '<comment>:</comment> '. $details['description']); }*/ }
[ "public", "function", "searchPackages", "(", "$", "text", ",", "OnPackageFoundInterface", "$", "callback", ",", "$", "onlyName", "=", "false", ",", "$", "includeLocal", "=", "true", ")", "{", "$", "this", "->", "onPackageFoundCallback", "=", "$", "callback", ...
Returns a list of packages matching the search query. @param string $text @param OnPackageFoundInterface $callback @param bool $onlyName
[ "Returns", "a", "list", "of", "packages", "matching", "the", "search", "query", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ComposerService.php#L356-L382
train
Lecturize/Laravel-Taxonomies
src/TaxonomiesServiceProvider.php
TaxonomiesServiceProvider.handleConfig
private function handleConfig() { $configPath = __DIR__ . '/../config/config.php'; $this->publishes([$configPath => config_path('lecturize.php')]); $this->mergeConfigFrom($configPath, 'lecturize'); }
php
private function handleConfig() { $configPath = __DIR__ . '/../config/config.php'; $this->publishes([$configPath => config_path('lecturize.php')]); $this->mergeConfigFrom($configPath, 'lecturize'); }
[ "private", "function", "handleConfig", "(", ")", "{", "$", "configPath", "=", "__DIR__", ".", "'/../config/config.php'", ";", "$", "this", "->", "publishes", "(", "[", "$", "configPath", "=>", "config_path", "(", "'lecturize.php'", ")", "]", ")", ";", "$", ...
Publish and merge the config file. @return void
[ "Publish", "and", "merge", "the", "config", "file", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/TaxonomiesServiceProvider.php#L41-L48
train
thecodingmachine/mouf
src-dev/Mouf/Menu/DocumentationMenuItem.php
DocumentationMenuItem.getMenuTree
private function getMenuTree() { if ($this->computed) { return parent::getChildren(); } $this->computed = true; $children = $this->cache->get('documentationMenuItem'); if ($children) { return $children; } if (isset($_REQUEST['selfedit']) && $_REQUEST['selfedit'] == 'true') { $selfedit = true; } else { $selfedit = false; } $composerService = new ComposerService($selfedit); $packages = $composerService->getLocalPackages(); $tree = array(); // Let's fill the menu with the packages. foreach ($packages as $package) { $name = $package->getName(); if (strpos($name, '/') === false) { continue; } list($vendorName, $packageName) = explode('/', $name); $items = explode('.', $packageName); array_unshift($items, $vendorName); $node =& $tree; foreach ($items as $str) { if (!isset($node["children"][$str])) { $node["children"][$str] = array(); } $node =& $node["children"][$str]; } $node['package'] = $package; } $this->walkMenuTree($tree, '', $this); // Short lived cache (3 minutes). $this->cache->set('documentationMenuItem', parent::getChildren(), 180); return parent::getChildren(); }
php
private function getMenuTree() { if ($this->computed) { return parent::getChildren(); } $this->computed = true; $children = $this->cache->get('documentationMenuItem'); if ($children) { return $children; } if (isset($_REQUEST['selfedit']) && $_REQUEST['selfedit'] == 'true') { $selfedit = true; } else { $selfedit = false; } $composerService = new ComposerService($selfedit); $packages = $composerService->getLocalPackages(); $tree = array(); // Let's fill the menu with the packages. foreach ($packages as $package) { $name = $package->getName(); if (strpos($name, '/') === false) { continue; } list($vendorName, $packageName) = explode('/', $name); $items = explode('.', $packageName); array_unshift($items, $vendorName); $node =& $tree; foreach ($items as $str) { if (!isset($node["children"][$str])) { $node["children"][$str] = array(); } $node =& $node["children"][$str]; } $node['package'] = $package; } $this->walkMenuTree($tree, '', $this); // Short lived cache (3 minutes). $this->cache->set('documentationMenuItem', parent::getChildren(), 180); return parent::getChildren(); }
[ "private", "function", "getMenuTree", "(", ")", "{", "if", "(", "$", "this", "->", "computed", ")", "{", "return", "parent", "::", "getChildren", "(", ")", ";", "}", "$", "this", "->", "computed", "=", "true", ";", "$", "children", "=", "$", "this", ...
Adds the packages menu to the menu.
[ "Adds", "the", "packages", "menu", "to", "the", "menu", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Menu/DocumentationMenuItem.php#L51-L103
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.initMoufManager
public static function initMoufManager() { if (self::$defaultInstance == null) { self::$defaultInstance = new MoufManager(); self::$defaultInstance->configManager = new MoufConfigManager("../../../../../config.php"); self::$defaultInstance->componentsFileName = "../../../../../mouf/MoufComponents.php"; //self::$defaultInstance->requireFileName = "../MoufRequire.php"; self::$defaultInstance->adminUiFileName = "../../../../../mouf/MoufUI.php"; self::$defaultInstance->mainClassName = "Mouf"; // FIXME: not appscope for sure self::$defaultInstance->scope = MoufManager::SCOPE_APP; } }
php
public static function initMoufManager() { if (self::$defaultInstance == null) { self::$defaultInstance = new MoufManager(); self::$defaultInstance->configManager = new MoufConfigManager("../../../../../config.php"); self::$defaultInstance->componentsFileName = "../../../../../mouf/MoufComponents.php"; //self::$defaultInstance->requireFileName = "../MoufRequire.php"; self::$defaultInstance->adminUiFileName = "../../../../../mouf/MoufUI.php"; self::$defaultInstance->mainClassName = "Mouf"; // FIXME: not appscope for sure self::$defaultInstance->scope = MoufManager::SCOPE_APP; } }
[ "public", "static", "function", "initMoufManager", "(", ")", "{", "if", "(", "self", "::", "$", "defaultInstance", "==", "null", ")", "{", "self", "::", "$", "defaultInstance", "=", "new", "MoufManager", "(", ")", ";", "self", "::", "$", "defaultInstance",...
Instantiates the default instance of the MoufManager. Does nothing if the default instance is already instanciated.
[ "Instantiates", "the", "default", "instance", "of", "the", "MoufManager", ".", "Does", "nothing", "if", "the", "default", "instance", "is", "already", "instanciated", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L84-L96
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.switchToHidden
public static function switchToHidden() { self::$hiddenInstance = self::$defaultInstance; self::$defaultInstance = new MoufManager(); self::$defaultInstance->configManager = new MoufConfigManager("../../config.php"); self::$defaultInstance->componentsFileName = "../../mouf/MoufComponents.php"; //self::$defaultInstance->requireFileName = "MoufAdminRequire.php"; self::$defaultInstance->adminUiFileName = "../../mouf/MoufUI.php"; self::$defaultInstance->mainClassName = "MoufAdmin"; self::$defaultInstance->scope = MoufManager::SCOPE_ADMIN; }
php
public static function switchToHidden() { self::$hiddenInstance = self::$defaultInstance; self::$defaultInstance = new MoufManager(); self::$defaultInstance->configManager = new MoufConfigManager("../../config.php"); self::$defaultInstance->componentsFileName = "../../mouf/MoufComponents.php"; //self::$defaultInstance->requireFileName = "MoufAdminRequire.php"; self::$defaultInstance->adminUiFileName = "../../mouf/MoufUI.php"; self::$defaultInstance->mainClassName = "MoufAdmin"; self::$defaultInstance->scope = MoufManager::SCOPE_ADMIN; }
[ "public", "static", "function", "switchToHidden", "(", ")", "{", "self", "::", "$", "hiddenInstance", "=", "self", "::", "$", "defaultInstance", ";", "self", "::", "$", "defaultInstance", "=", "new", "MoufManager", "(", ")", ";", "self", "::", "$", "defaul...
This function takes the whole configuration stored in the default instance of the Mouf framework and switches it in the hidden instance. The default instance is cleaned afterwards.
[ "This", "function", "takes", "the", "whole", "configuration", "stored", "in", "the", "default", "instance", "of", "the", "Mouf", "framework", "and", "switches", "it", "in", "the", "hidden", "instance", ".", "The", "default", "instance", "is", "cleaned", "after...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L104-L113
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.get
public function get($instanceName) { if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) { $this->instantiateComponent($instanceName); } return $this->objectInstances[$instanceName]; }
php
public function get($instanceName) { if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) { $this->instantiateComponent($instanceName); } return $this->objectInstances[$instanceName]; }
[ "public", "function", "get", "(", "$", "instanceName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "objectInstances", "[", "$", "instanceName", "]", ")", "||", "$", "this", "->", "objectInstances", "[", "$", "instanceName", "]", "==", "n...
Returns the instance of the specified object. @param string $instanceName @return object
[ "Returns", "the", "instance", "of", "the", "specified", "object", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L255-L260
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getInstancesList
public function getInstancesList() { $arr = array(); foreach ($this->declaredInstances as $instanceName=>$classDesc) { //if (!isset($classDesc["class"])) {var_dump($instanceName);var_dump($classDesc);} $arr[$instanceName] = isset($classDesc['class'])?$classDesc['class']:null; } return $arr; }
php
public function getInstancesList() { $arr = array(); foreach ($this->declaredInstances as $instanceName=>$classDesc) { //if (!isset($classDesc["class"])) {var_dump($instanceName);var_dump($classDesc);} $arr[$instanceName] = isset($classDesc['class'])?$classDesc['class']:null; } return $arr; }
[ "public", "function", "getInstancesList", "(", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "declaredInstances", "as", "$", "instanceName", "=>", "$", "classDesc", ")", "{", "//if (!isset($classDesc[\"class\"])) {var_dump...
Returns the list of all instances of objects in Mouf. Objects are not instanciated. Instead, a list containing the name of the instance in the key and the name of the class in the value is returned. @return array<string, string>
[ "Returns", "the", "list", "of", "all", "instances", "of", "objects", "in", "Mouf", ".", "Objects", "are", "not", "instanciated", ".", "Instead", "a", "list", "containing", "the", "name", "of", "the", "instance", "in", "the", "key", "and", "the", "name", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L300-L307
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.declareComponent
public function declareComponent($instanceName, $className, $external = false, $mode = self::DECLARE_ON_EXIST_EXCEPTION, $weak = false) { if (isset($this->declaredInstances[$instanceName])) { if ($mode == self::DECLARE_ON_EXIST_EXCEPTION) { throw new MoufException("Unable to create Mouf instance named '".$instanceName."'. An instance with this name already exists."); } elseif ($mode == self::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS) { $this->declaredInstances[$instanceName]["fieldProperties"] = array(); $this->declaredInstances[$instanceName]["setterProperties"] = array(); $this->declaredInstances[$instanceName]["fieldBinds"] = array(); $this->declaredInstances[$instanceName]["setterBinds"] = array(); $this->declaredInstances[$instanceName]["weak"] = $weak; $this->declaredInstances[$instanceName]["comment"] = ""; } elseif ($mode == self::DECLARE_ON_EXIST_KEEP_ALL) { // Do nothing } } if (strpos($className, '\\' === 0)) { $className = substr($className, 1); } $this->declaredInstances[$instanceName]["class"] = $className; $this->declaredInstances[$instanceName]["external"] = $external; }
php
public function declareComponent($instanceName, $className, $external = false, $mode = self::DECLARE_ON_EXIST_EXCEPTION, $weak = false) { if (isset($this->declaredInstances[$instanceName])) { if ($mode == self::DECLARE_ON_EXIST_EXCEPTION) { throw new MoufException("Unable to create Mouf instance named '".$instanceName."'. An instance with this name already exists."); } elseif ($mode == self::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS) { $this->declaredInstances[$instanceName]["fieldProperties"] = array(); $this->declaredInstances[$instanceName]["setterProperties"] = array(); $this->declaredInstances[$instanceName]["fieldBinds"] = array(); $this->declaredInstances[$instanceName]["setterBinds"] = array(); $this->declaredInstances[$instanceName]["weak"] = $weak; $this->declaredInstances[$instanceName]["comment"] = ""; } elseif ($mode == self::DECLARE_ON_EXIST_KEEP_ALL) { // Do nothing } } if (strpos($className, '\\' === 0)) { $className = substr($className, 1); } $this->declaredInstances[$instanceName]["class"] = $className; $this->declaredInstances[$instanceName]["external"] = $external; }
[ "public", "function", "declareComponent", "(", "$", "instanceName", ",", "$", "className", ",", "$", "external", "=", "false", ",", "$", "mode", "=", "self", "::", "DECLARE_ON_EXIST_EXCEPTION", ",", "$", "weak", "=", "false", ")", "{", "if", "(", "isset", ...
Declares a new component. @param string $instanceName @param string $className @param boolean $external Whether the component is external or not. Defaults to false. @param int $mode Depending on the mode, the behaviour will be different if an instance with the same name already exists. @param bool $weak If the object is weak, it will be destroyed if it is no longer referenced.
[ "Declares", "a", "new", "component", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L330-L352
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.removeComponent
public function removeComponent($instanceName) { unset($this->instanceDescriptors[$instanceName]); unset($this->declaredInstances[$instanceName]); if (isset($this->instanceDescriptors[$instanceName])) { unset($this->instanceDescriptors[$instanceName]); } foreach ($this->declaredInstances as $declaredInstanceName=>$declaredInstance) { if (isset($declaredInstance["constructor"])) { foreach ($declaredInstance["constructor"] as $index=>$propWrapper) { if ($propWrapper['parametertype'] == 'object') { $properties = $propWrapper['value']; if (is_array($properties)) { // If this is an array of properties $keys_matching = array_keys($properties, $instanceName); if (!empty($keys_matching)) { foreach ($keys_matching as $key) { unset($properties[$key]); } $this->setParameterViaConstructor($declaredInstanceName, $index, $properties, 'object'); } } else { // If this is a simple property if ($properties == $instanceName) { $this->setParameterViaConstructor($declaredInstanceName, $index, null, 'object'); } } } } } } foreach ($this->declaredInstances as $declaredInstanceName=>$declaredInstance) { if (isset($declaredInstance["fieldBinds"])) { foreach ($declaredInstance["fieldBinds"] as $paramName=>$properties) { if (is_array($properties)) { // If this is an array of properties $keys_matching = array_keys($properties, $instanceName); if (!empty($keys_matching)) { foreach ($keys_matching as $key) { unset($properties[$key]); } $this->bindComponents($declaredInstanceName, $paramName, $properties); } } else { // If this is a simple property if ($properties == $instanceName) { $this->bindComponent($declaredInstanceName, $paramName, null); } } } } } foreach ($this->declaredInstances as $declaredInstanceName=>$declaredInstance) { if (isset($declaredInstance["setterBinds"])) { foreach ($declaredInstance["setterBinds"] as $setterName=>$properties) { if (is_array($properties)) { // If this is an array of properties $keys_matching = array_keys($properties, $instanceName); if (!empty($keys_matching)) { foreach ($keys_matching as $key) { unset($properties[$key]); } $this->bindComponentsViaSetter($declaredInstanceName, $setterName, $properties); } } else { // If this is a simple property if ($properties == $instanceName) { $this->bindComponentViaSetter($declaredInstanceName, $setterName, null); } } } } } }
php
public function removeComponent($instanceName) { unset($this->instanceDescriptors[$instanceName]); unset($this->declaredInstances[$instanceName]); if (isset($this->instanceDescriptors[$instanceName])) { unset($this->instanceDescriptors[$instanceName]); } foreach ($this->declaredInstances as $declaredInstanceName=>$declaredInstance) { if (isset($declaredInstance["constructor"])) { foreach ($declaredInstance["constructor"] as $index=>$propWrapper) { if ($propWrapper['parametertype'] == 'object') { $properties = $propWrapper['value']; if (is_array($properties)) { // If this is an array of properties $keys_matching = array_keys($properties, $instanceName); if (!empty($keys_matching)) { foreach ($keys_matching as $key) { unset($properties[$key]); } $this->setParameterViaConstructor($declaredInstanceName, $index, $properties, 'object'); } } else { // If this is a simple property if ($properties == $instanceName) { $this->setParameterViaConstructor($declaredInstanceName, $index, null, 'object'); } } } } } } foreach ($this->declaredInstances as $declaredInstanceName=>$declaredInstance) { if (isset($declaredInstance["fieldBinds"])) { foreach ($declaredInstance["fieldBinds"] as $paramName=>$properties) { if (is_array($properties)) { // If this is an array of properties $keys_matching = array_keys($properties, $instanceName); if (!empty($keys_matching)) { foreach ($keys_matching as $key) { unset($properties[$key]); } $this->bindComponents($declaredInstanceName, $paramName, $properties); } } else { // If this is a simple property if ($properties == $instanceName) { $this->bindComponent($declaredInstanceName, $paramName, null); } } } } } foreach ($this->declaredInstances as $declaredInstanceName=>$declaredInstance) { if (isset($declaredInstance["setterBinds"])) { foreach ($declaredInstance["setterBinds"] as $setterName=>$properties) { if (is_array($properties)) { // If this is an array of properties $keys_matching = array_keys($properties, $instanceName); if (!empty($keys_matching)) { foreach ($keys_matching as $key) { unset($properties[$key]); } $this->bindComponentsViaSetter($declaredInstanceName, $setterName, $properties); } } else { // If this is a simple property if ($properties == $instanceName) { $this->bindComponentViaSetter($declaredInstanceName, $setterName, null); } } } } } }
[ "public", "function", "removeComponent", "(", "$", "instanceName", ")", "{", "unset", "(", "$", "this", "->", "instanceDescriptors", "[", "$", "instanceName", "]", ")", ";", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]",...
Removes an instance. Sets to null any property linking to that component. @param string $instanceName
[ "Removes", "an", "instance", ".", "Sets", "to", "null", "any", "property", "linking", "to", "that", "component", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L360-L435
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getInstanceType
public function getInstanceType($instanceName) { if (isset($this->declaredInstances[$instanceName]['class'])) { return $this->declaredInstances[$instanceName]['class']; } else { return null; } }
php
public function getInstanceType($instanceName) { if (isset($this->declaredInstances[$instanceName]['class'])) { return $this->declaredInstances[$instanceName]['class']; } else { return null; } }
[ "public", "function", "getInstanceType", "(", "$", "instanceName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'class'", "]", ")", ")", "{", "return", "$", "this", "->", "declaredInstances...
Return the type of the instance. @param string $instanceName The instance name @return string The class name of the instance
[ "Return", "the", "type", "of", "the", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L542-L548
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.setParameter
public function setParameter($instanceName, $paramName, $paramValue, $type = "string", array $metadata = array()) { if ($type != "string" && $type != "config" && $type != "request" && $type != "session" && $type != "php") { throw new MoufContainerException("Invalid type. Must be one of: string|config|request|session. Value passed: '".$type."'"); } $this->declaredInstances[$instanceName]["fieldProperties"][$paramName]["value"] = $paramValue; $this->declaredInstances[$instanceName]["fieldProperties"][$paramName]["type"] = $type; $this->declaredInstances[$instanceName]["fieldProperties"][$paramName]["metadata"] = $metadata; }
php
public function setParameter($instanceName, $paramName, $paramValue, $type = "string", array $metadata = array()) { if ($type != "string" && $type != "config" && $type != "request" && $type != "session" && $type != "php") { throw new MoufContainerException("Invalid type. Must be one of: string|config|request|session. Value passed: '".$type."'"); } $this->declaredInstances[$instanceName]["fieldProperties"][$paramName]["value"] = $paramValue; $this->declaredInstances[$instanceName]["fieldProperties"][$paramName]["type"] = $type; $this->declaredInstances[$instanceName]["fieldProperties"][$paramName]["metadata"] = $metadata; }
[ "public", "function", "setParameter", "(", "$", "instanceName", ",", "$", "paramName", ",", "$", "paramValue", ",", "$", "type", "=", "\"string\"", ",", "array", "$", "metadata", "=", "array", "(", ")", ")", "{", "if", "(", "$", "type", "!=", "\"string...
Binds a parameter to the instance. @param string $instanceName @param string $paramName @param string $paramValue @param string $type Can be one of "string|config|request|session|php" @param array $metadata An array containing metadata
[ "Binds", "a", "parameter", "to", "the", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L766-L774
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.setParameterViaSetter
public function setParameterViaSetter($instanceName, $setterName, $paramValue, $type = "string", array $metadata = array()) { if ($type != "string" && $type != "config" && $type != "request" && $type != "session" && $type != "php") { throw new MoufContainerException("Invalid type. Must be one of: string|config|request|session"); } $this->declaredInstances[$instanceName]["setterProperties"][$setterName]["value"] = $paramValue; $this->declaredInstances[$instanceName]["setterProperties"][$setterName]["type"] = $type; $this->declaredInstances[$instanceName]["setterProperties"][$setterName]["metadata"] = $metadata; }
php
public function setParameterViaSetter($instanceName, $setterName, $paramValue, $type = "string", array $metadata = array()) { if ($type != "string" && $type != "config" && $type != "request" && $type != "session" && $type != "php") { throw new MoufContainerException("Invalid type. Must be one of: string|config|request|session"); } $this->declaredInstances[$instanceName]["setterProperties"][$setterName]["value"] = $paramValue; $this->declaredInstances[$instanceName]["setterProperties"][$setterName]["type"] = $type; $this->declaredInstances[$instanceName]["setterProperties"][$setterName]["metadata"] = $metadata; }
[ "public", "function", "setParameterViaSetter", "(", "$", "instanceName", ",", "$", "setterName", ",", "$", "paramValue", ",", "$", "type", "=", "\"string\"", ",", "array", "$", "metadata", "=", "array", "(", ")", ")", "{", "if", "(", "$", "type", "!=", ...
Binds a parameter to the instance using a setter. @param string $instanceName @param string $setterName @param string $paramValue @param string $type Can be one of "string|config|request|session|php" @param array $metadata An array containing metadata
[ "Binds", "a", "parameter", "to", "the", "instance", "using", "a", "setter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L785-L793
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.setParameterViaConstructor
public function setParameterViaConstructor($instanceName, $index, $paramValue, $parameterType, $type = "string", array $metadata = array()) { if ($type != "string" && $type != "config" && $type != "request" && $type != "session" && $type != "php") { throw new MoufContainerException("Invalid type. Must be one of: string|config|request|session"); } $this->declaredInstances[$instanceName]['constructor'][$index]["value"] = $paramValue; $this->declaredInstances[$instanceName]['constructor'][$index]["parametertype"] = $parameterType; $this->declaredInstances[$instanceName]['constructor'][$index]["type"] = $type; $this->declaredInstances[$instanceName]['constructor'][$index]["metadata"] = $metadata; // Now, let's make sure that all indexes BEFORE ours are set, and let's order everything by key. for ($i=0; $i<$index; $i++) { if (!isset($this->declaredInstances[$instanceName]['constructor'][$i])) { // If the parameter before does not exist, let's set it to null. $this->declaredInstances[$instanceName]['constructor'][$i]["value"] = null; $this->declaredInstances[$instanceName]['constructor'][$i]["parametertype"] = "primitive"; $this->declaredInstances[$instanceName]['constructor'][$i]["type"] = "string"; $this->declaredInstances[$instanceName]['constructor'][$i]["metadata"] = array(); } } ksort($this->declaredInstances[$instanceName]['constructor']); }
php
public function setParameterViaConstructor($instanceName, $index, $paramValue, $parameterType, $type = "string", array $metadata = array()) { if ($type != "string" && $type != "config" && $type != "request" && $type != "session" && $type != "php") { throw new MoufContainerException("Invalid type. Must be one of: string|config|request|session"); } $this->declaredInstances[$instanceName]['constructor'][$index]["value"] = $paramValue; $this->declaredInstances[$instanceName]['constructor'][$index]["parametertype"] = $parameterType; $this->declaredInstances[$instanceName]['constructor'][$index]["type"] = $type; $this->declaredInstances[$instanceName]['constructor'][$index]["metadata"] = $metadata; // Now, let's make sure that all indexes BEFORE ours are set, and let's order everything by key. for ($i=0; $i<$index; $i++) { if (!isset($this->declaredInstances[$instanceName]['constructor'][$i])) { // If the parameter before does not exist, let's set it to null. $this->declaredInstances[$instanceName]['constructor'][$i]["value"] = null; $this->declaredInstances[$instanceName]['constructor'][$i]["parametertype"] = "primitive"; $this->declaredInstances[$instanceName]['constructor'][$i]["type"] = "string"; $this->declaredInstances[$instanceName]['constructor'][$i]["metadata"] = array(); } } ksort($this->declaredInstances[$instanceName]['constructor']); }
[ "public", "function", "setParameterViaConstructor", "(", "$", "instanceName", ",", "$", "index", ",", "$", "paramValue", ",", "$", "parameterType", ",", "$", "type", "=", "\"string\"", ",", "array", "$", "metadata", "=", "array", "(", ")", ")", "{", "if", ...
Binds a parameter to the instance using a constructor parameter. @param string $instanceName @param string $index @param string $paramValue @param string $parameterType Can be one of "primitive" or "object". @param string $type Can be one of "string|config|request|session|php" @param array $metadata An array containing metadata
[ "Binds", "a", "parameter", "to", "the", "instance", "using", "a", "constructor", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L805-L826
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.isParameterSet
public function isParameterSet($instanceName, $paramName) { return isset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]) || isset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]); }
php
public function isParameterSet($instanceName, $paramName) { return isset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]) || isset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]); }
[ "public", "function", "isParameterSet", "(", "$", "instanceName", ",", "$", "paramName", ")", "{", "return", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'fieldProperties'", "]", "[", "$", "paramName", "]", ")", ...
Returns true if the value of the given parameter is set. False otherwise. @param string $instanceName @param string $paramName @return boolean
[ "Returns", "true", "if", "the", "value", "of", "the", "given", "parameter", "is", "set", ".", "False", "otherwise", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L863-L865
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.unsetParameter
public function unsetParameter($instanceName, $paramName) { unset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]); unset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]); }
php
public function unsetParameter($instanceName, $paramName) { unset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]); unset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]); }
[ "public", "function", "unsetParameter", "(", "$", "instanceName", ",", "$", "paramName", ")", "{", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'fieldProperties'", "]", "[", "$", "paramName", "]", ")", ";", "un...
Completely unset this parameter from the DI container. @param string $instanceName @param string $paramName
[ "Completely", "unset", "this", "parameter", "from", "the", "DI", "container", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L873-L876
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterForSetter
public function getParameterForSetter($instanceName, $setterName) { // todo: improve this if (isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]['value'])) { return $this->declaredInstances[$instanceName]['setterProperties'][$setterName]['value']; } else { return null; } }
php
public function getParameterForSetter($instanceName, $setterName) { // todo: improve this if (isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]['value'])) { return $this->declaredInstances[$instanceName]['setterProperties'][$setterName]['value']; } else { return null; } }
[ "public", "function", "getParameterForSetter", "(", "$", "instanceName", ",", "$", "setterName", ")", "{", "// todo: improve this\r", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'setterProperties'", "]", ...
Returns the value for the given parameter that has been set using a setter. @param string $instanceName @param string $setterName @return mixed
[ "Returns", "the", "value", "for", "the", "given", "parameter", "that", "has", "been", "set", "using", "a", "setter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L885-L892
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.isParameterSetForSetter
public function isParameterSetForSetter($instanceName, $setterName) { return isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]) || isset($this->declaredInstances[$instanceName]['setterBinds'][$setterName]); }
php
public function isParameterSetForSetter($instanceName, $setterName) { return isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]) || isset($this->declaredInstances[$instanceName]['setterBinds'][$setterName]); }
[ "public", "function", "isParameterSetForSetter", "(", "$", "instanceName", ",", "$", "setterName", ")", "{", "return", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'setterProperties'", "]", "[", "$", "setterName", ...
Returns true if the value of the given setter parameter is set. False otherwise. @param string $instanceName @param string $setterName @return boolean
[ "Returns", "true", "if", "the", "value", "of", "the", "given", "setter", "parameter", "is", "set", ".", "False", "otherwise", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L902-L904
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.unsetParameterForSetter
public function unsetParameterForSetter($instanceName, $setterName) { unset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]); unset($this->declaredInstances[$instanceName]['setterBinds'][$setterName]); }
php
public function unsetParameterForSetter($instanceName, $setterName) { unset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]); unset($this->declaredInstances[$instanceName]['setterBinds'][$setterName]); }
[ "public", "function", "unsetParameterForSetter", "(", "$", "instanceName", ",", "$", "setterName", ")", "{", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'setterProperties'", "]", "[", "$", "setterName", "]", ")", ...
Completely unset this setter parameter from the DI container. @param string $instanceName @param string $setterName
[ "Completely", "unset", "this", "setter", "parameter", "from", "the", "DI", "container", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L912-L915
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterForConstructor
public function getParameterForConstructor($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['value'])) { return $this->declaredInstances[$instanceName]['constructor'][$index]['value']; } else { return null; } }
php
public function getParameterForConstructor($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['value'])) { return $this->declaredInstances[$instanceName]['constructor'][$index]['value']; } else { return null; } }
[ "public", "function", "getParameterForConstructor", "(", "$", "instanceName", ",", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'constructor'", "]", "[", "$", "index", "]", "[...
Returns the value for the given parameter that has been set using a constructor. @param string $instanceName @param int $index @return mixed
[ "Returns", "the", "value", "for", "the", "given", "parameter", "that", "has", "been", "set", "using", "a", "constructor", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L924-L930
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.isConstructorParameterObjectOrPrimitive
public function isConstructorParameterObjectOrPrimitive($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['parametertype'])) { return $this->declaredInstances[$instanceName]['constructor'][$index]['parametertype']; } else { return null; } }
php
public function isConstructorParameterObjectOrPrimitive($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['parametertype'])) { return $this->declaredInstances[$instanceName]['constructor'][$index]['parametertype']; } else { return null; } }
[ "public", "function", "isConstructorParameterObjectOrPrimitive", "(", "$", "instanceName", ",", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'constructor'", "]", "[", "$", "index"...
The type of the parameter for a constructor parameter. Can be one of "primitive" or "object". @param string $instanceName @param int $index @return string
[ "The", "type", "of", "the", "parameter", "for", "a", "constructor", "parameter", ".", "Can", "be", "one", "of", "primitive", "or", "object", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L938-L944
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.unsetParameterForConstructor
public function unsetParameterForConstructor($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'])) { $max = count($this->declaredInstances[$instanceName]['constructor']); if($index != $max - 1) { // It is forbidden to unset a parameter that is not the last. // Let set null $this->setParameterViaConstructor($instanceName, $index, null, 'primitive'); } else { unset($this->declaredInstances[$instanceName]['constructor'][$index]); } } }
php
public function unsetParameterForConstructor($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'])) { $max = count($this->declaredInstances[$instanceName]['constructor']); if($index != $max - 1) { // It is forbidden to unset a parameter that is not the last. // Let set null $this->setParameterViaConstructor($instanceName, $index, null, 'primitive'); } else { unset($this->declaredInstances[$instanceName]['constructor'][$index]); } } }
[ "public", "function", "unsetParameterForConstructor", "(", "$", "instanceName", ",", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'constructor'", "]", ")", ")", "{", "$", "max...
Completely unset this constructor parameter from the DI container. @param string $instanceName @param int $index
[ "Completely", "unset", "this", "constructor", "parameter", "from", "the", "DI", "container", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L964-L976
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterMetadata
public function getParameterMetadata($instanceName, $paramName) { if (isset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]['metadata'])) { return $this->declaredInstances[$instanceName]['fieldProperties'][$paramName]['metadata']; } else { return array(); } }
php
public function getParameterMetadata($instanceName, $paramName) { if (isset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]['metadata'])) { return $this->declaredInstances[$instanceName]['fieldProperties'][$paramName]['metadata']; } else { return array(); } }
[ "public", "function", "getParameterMetadata", "(", "$", "instanceName", ",", "$", "paramName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'fieldProperties'", "]", "[", "$", "paramName", "]"...
Returns the metadata for the given parameter. Metadata is an array of key=>value, containing additional info. For instance, it could contain information on the way to represent a field in the UI, etc... @param string $instanceName @param string $paramName @return string
[ "Returns", "the", "metadata", "for", "the", "given", "parameter", ".", "Metadata", "is", "an", "array", "of", "key", "=", ">", "value", "containing", "additional", "info", ".", "For", "instance", "it", "could", "contain", "information", "on", "the", "way", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1066-L1072
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterMetadataForSetter
public function getParameterMetadataForSetter($instanceName, $setterName) { if (isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]['metadata'])) { return $this->declaredInstances[$instanceName]['setterProperties'][$setterName]['metadata']; } else { return array(); } }
php
public function getParameterMetadataForSetter($instanceName, $setterName) { if (isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]['metadata'])) { return $this->declaredInstances[$instanceName]['setterProperties'][$setterName]['metadata']; } else { return array(); } }
[ "public", "function", "getParameterMetadataForSetter", "(", "$", "instanceName", ",", "$", "setterName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'setterProperties'", "]", "[", "$", "setter...
Returns the metadata for the given parameter that has been set using a setter. Metadata is an array of key=>value, containing additional info. For instance, it could contain information on the way to represent a field in the UI, etc... @param string $instanceName @param string $setterName @return string
[ "Returns", "the", "metadata", "for", "the", "given", "parameter", "that", "has", "been", "set", "using", "a", "setter", ".", "Metadata", "is", "an", "array", "of", "key", "=", ">", "value", "containing", "additional", "info", ".", "For", "instance", "it", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1083-L1089
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterMetadataForConstructor
public function getParameterMetadataForConstructor($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['metadata'])) { return $this->declaredInstances[$instanceName]['constructor'][$index]['metadata']; } else { return array(); } }
php
public function getParameterMetadataForConstructor($instanceName, $index) { if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['metadata'])) { return $this->declaredInstances[$instanceName]['constructor'][$index]['metadata']; } else { return array(); } }
[ "public", "function", "getParameterMetadataForConstructor", "(", "$", "instanceName", ",", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'constructor'", "]", "[", "$", "index", "...
Returns the metadata for the given parameter that has been set using a constructor parameter. Metadata is an array of key=>value, containing additional info. For instance, it could contain information on the way to represent a field in the UI, etc... @param string $instanceName @param int $index @return string
[ "Returns", "the", "metadata", "for", "the", "given", "parameter", "that", "has", "been", "set", "using", "a", "constructor", "parameter", ".", "Metadata", "is", "an", "array", "of", "key", "=", ">", "value", "containing", "additional", "info", ".", "For", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1100-L1106
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.bindComponent
public function bindComponent($instanceName, $paramName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["fieldBinds"][$paramName]); } else { $this->declaredInstances[$instanceName]["fieldBinds"][$paramName] = $paramValue; } }
php
public function bindComponent($instanceName, $paramName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["fieldBinds"][$paramName]); } else { $this->declaredInstances[$instanceName]["fieldBinds"][$paramName] = $paramValue; } }
[ "public", "function", "bindComponent", "(", "$", "instanceName", ",", "$", "paramName", ",", "$", "paramValue", ")", "{", "if", "(", "$", "paramValue", "==", "null", ")", "{", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", ...
Binds another instance to the instance. @param string $instanceName @param string $paramName @param string $paramValue the name of the instance to bind to.
[ "Binds", "another", "instance", "to", "the", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1144-L1150
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.bindComponentViaSetter
public function bindComponentViaSetter($instanceName, $setterName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["setterBinds"][$setterName]); } else { $this->declaredInstances[$instanceName]["setterBinds"][$setterName] = $paramValue; } }
php
public function bindComponentViaSetter($instanceName, $setterName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["setterBinds"][$setterName]); } else { $this->declaredInstances[$instanceName]["setterBinds"][$setterName] = $paramValue; } }
[ "public", "function", "bindComponentViaSetter", "(", "$", "instanceName", ",", "$", "setterName", ",", "$", "paramValue", ")", "{", "if", "(", "$", "paramValue", "==", "null", ")", "{", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "insta...
Binds another instance to the instance via a setter. @param string $instanceName @param string $setterName @param string $paramValue the name of the instance to bind to.
[ "Binds", "another", "instance", "to", "the", "instance", "via", "a", "setter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1159-L1165
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.bindComponents
public function bindComponents($instanceName, $paramName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["fieldBinds"][$paramName]); } else { $this->declaredInstances[$instanceName]["fieldBinds"][$paramName] = $paramValue; } }
php
public function bindComponents($instanceName, $paramName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["fieldBinds"][$paramName]); } else { $this->declaredInstances[$instanceName]["fieldBinds"][$paramName] = $paramValue; } }
[ "public", "function", "bindComponents", "(", "$", "instanceName", ",", "$", "paramName", ",", "$", "paramValue", ")", "{", "if", "(", "$", "paramValue", "==", "null", ")", "{", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName",...
Binds an array of instance to the instance. @param string $instanceName @param string $paramName @param array $paramValue an array of names of instance to bind to.
[ "Binds", "an", "array", "of", "instance", "to", "the", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1174-L1180
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.bindComponentsViaSetter
public function bindComponentsViaSetter($instanceName, $setterName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["setterBinds"][$setterName]); } else { $this->declaredInstances[$instanceName]["setterBinds"][$setterName] = $paramValue; } }
php
public function bindComponentsViaSetter($instanceName, $setterName, $paramValue) { if ($paramValue == null) { unset($this->declaredInstances[$instanceName]["setterBinds"][$setterName]); } else { $this->declaredInstances[$instanceName]["setterBinds"][$setterName] = $paramValue; } }
[ "public", "function", "bindComponentsViaSetter", "(", "$", "instanceName", ",", "$", "setterName", ",", "$", "paramValue", ")", "{", "if", "(", "$", "paramValue", "==", "null", ")", "{", "unset", "(", "$", "this", "->", "declaredInstances", "[", "$", "inst...
Binds an array of instance to the instance via a setter. @param string $instanceName @param string $setterName @param array $paramValue an array of names of instance to bind to.
[ "Binds", "an", "array", "of", "instance", "to", "the", "instance", "via", "a", "setter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1189-L1195
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.generateGetterString
private function generateGetterString($instanceName) { $modInstance = str_replace(" ", "", $instanceName); $modInstance = str_replace("\n", "", $modInstance); $modInstance = str_replace("-", "", $modInstance); $modInstance = str_replace(".", "_", $modInstance); // Let's remove anything that is not an authorized character: $modInstance = preg_replace("/[^A-Za-z0-9_]/", "", $modInstance); return "get".strtoupper(substr($modInstance,0,1)).substr($modInstance,1); }
php
private function generateGetterString($instanceName) { $modInstance = str_replace(" ", "", $instanceName); $modInstance = str_replace("\n", "", $modInstance); $modInstance = str_replace("-", "", $modInstance); $modInstance = str_replace(".", "_", $modInstance); // Let's remove anything that is not an authorized character: $modInstance = preg_replace("/[^A-Za-z0-9_]/", "", $modInstance); return "get".strtoupper(substr($modInstance,0,1)).substr($modInstance,1); }
[ "private", "function", "generateGetterString", "(", "$", "instanceName", ")", "{", "$", "modInstance", "=", "str_replace", "(", "\" \"", ",", "\"\"", ",", "$", "instanceName", ")", ";", "$", "modInstance", "=", "str_replace", "(", "\"\\n\"", ",", "\"\"", ","...
Generate the string for the getter by uppercasing the first character and prepending "get". @param string $instanceName @return string
[ "Generate", "the", "string", "for", "the", "getter", "by", "uppercasing", "the", "first", "character", "and", "prepending", "get", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1420-L1430
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getBoundComponents
public function getBoundComponents($instanceName) { // FIXME: not accounting for components bound in constructor // it is likely this method is not used anymore // TODO: check usage and remove. $binds = array(); if (isset($this->declaredInstances[$instanceName]) && isset($this->declaredInstances[$instanceName]['fieldBinds'])) { $binds = $this->declaredInstances[$instanceName]['fieldBinds']; } if (isset($this->declaredInstances[$instanceName]) && isset($this->declaredInstances[$instanceName]['setterBinds'])) { foreach ($this->declaredInstances[$instanceName]['setterBinds'] as $setter=>$bind) { $binds[MoufPropertyDescriptor::getPropertyNameFromSetterName($setter)] = $bind; } } return $binds; }
php
public function getBoundComponents($instanceName) { // FIXME: not accounting for components bound in constructor // it is likely this method is not used anymore // TODO: check usage and remove. $binds = array(); if (isset($this->declaredInstances[$instanceName]) && isset($this->declaredInstances[$instanceName]['fieldBinds'])) { $binds = $this->declaredInstances[$instanceName]['fieldBinds']; } if (isset($this->declaredInstances[$instanceName]) && isset($this->declaredInstances[$instanceName]['setterBinds'])) { foreach ($this->declaredInstances[$instanceName]['setterBinds'] as $setter=>$bind) { $binds[MoufPropertyDescriptor::getPropertyNameFromSetterName($setter)] = $bind; } } return $binds; }
[ "public", "function", "getBoundComponents", "(", "$", "instanceName", ")", "{", "// FIXME: not accounting for components bound in constructor\r", "// it is likely this method is not used anymore\r", "// TODO: check usage and remove.\r", "$", "binds", "=", "array", "(", ")", ";", ...
Returns the list of all components bound to that component. @param string $instanceName @return array<string, comp(s)> where comp(s) is a string or an array<string> if there are many components for that property. The key of the array is the name of the property.
[ "Returns", "the", "list", "of", "all", "components", "bound", "to", "that", "component", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1507-L1521
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getOwnerComponents
public function getOwnerComponents($instanceName) { $instancesList = array(); foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) { if (isset($instanceDesc['fieldBinds'])) { foreach ($instanceDesc['fieldBinds'] as $declaredBindProperty) { if (is_array($declaredBindProperty)) { if (array_search($instanceName, $declaredBindProperty) !== false) { $instancesList[$scannedInstance] = $scannedInstance; break; } } elseif ($declaredBindProperty == $instanceName) { $instancesList[$scannedInstance] = $scannedInstance; } } } } foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) { if (isset($instanceDesc['setterBinds'])) { foreach ($instanceDesc['setterBinds'] as $declaredBindProperty) { if (is_array($declaredBindProperty)) { if (array_search($instanceName, $declaredBindProperty) !== false) { $instancesList[$scannedInstance] = $scannedInstance; break; } } elseif ($declaredBindProperty == $instanceName) { $instancesList[$scannedInstance] = $scannedInstance; } } } } foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) { if (isset($instanceDesc['constructor'])) { foreach ($instanceDesc['constructor'] as $declaredConstructorProperty) { if ($declaredConstructorProperty['parametertype']=='object') { $value = $declaredConstructorProperty['value']; if (is_array($value)) { if (array_search($instanceName, $value) !== false) { $instancesList[$scannedInstance] = $scannedInstance; break; } } elseif ($value == $instanceName) { $instancesList[$scannedInstance] = $scannedInstance; } } } } } return $instancesList; }
php
public function getOwnerComponents($instanceName) { $instancesList = array(); foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) { if (isset($instanceDesc['fieldBinds'])) { foreach ($instanceDesc['fieldBinds'] as $declaredBindProperty) { if (is_array($declaredBindProperty)) { if (array_search($instanceName, $declaredBindProperty) !== false) { $instancesList[$scannedInstance] = $scannedInstance; break; } } elseif ($declaredBindProperty == $instanceName) { $instancesList[$scannedInstance] = $scannedInstance; } } } } foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) { if (isset($instanceDesc['setterBinds'])) { foreach ($instanceDesc['setterBinds'] as $declaredBindProperty) { if (is_array($declaredBindProperty)) { if (array_search($instanceName, $declaredBindProperty) !== false) { $instancesList[$scannedInstance] = $scannedInstance; break; } } elseif ($declaredBindProperty == $instanceName) { $instancesList[$scannedInstance] = $scannedInstance; } } } } foreach ($this->declaredInstances as $scannedInstance=>$instanceDesc) { if (isset($instanceDesc['constructor'])) { foreach ($instanceDesc['constructor'] as $declaredConstructorProperty) { if ($declaredConstructorProperty['parametertype']=='object') { $value = $declaredConstructorProperty['value']; if (is_array($value)) { if (array_search($instanceName, $value) !== false) { $instancesList[$scannedInstance] = $scannedInstance; break; } } elseif ($value == $instanceName) { $instancesList[$scannedInstance] = $scannedInstance; } } } } } return $instancesList; }
[ "public", "function", "getOwnerComponents", "(", "$", "instanceName", ")", "{", "$", "instancesList", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "declaredInstances", "as", "$", "scannedInstance", "=>", "$", "instanceDesc", ")", "{", "if"...
Returns the list of instances that are pointing to this instance through one of their properties. @param string $instanceName @return array<string, string> The instances pointing to the passed instance are returned in key and in the value
[ "Returns", "the", "list", "of", "instances", "that", "are", "pointing", "to", "this", "instance", "through", "one", "of", "their", "properties", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1529-L1582
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.purgeUnreachableWeakInstances
public function purgeUnreachableWeakInstances() { foreach ($this->declaredInstances as $key=>$instance) { if (!isset($instance['weak']) || $instance['weak'] == false) { $this->walkForGarbageCollection($key); } } // At this point any instance with the "noGarbageCollect" attribute should be kept. Others should be eliminated. $keptInstances = array(); foreach ($this->declaredInstances as $key=>$instance) { if (isset($instance['noGarbageCollect']) && $instance['noGarbageCollect'] == true) { // Let's clear the flag unset($this->declaredInstances[$key]['noGarbageCollect']); } else { // Let's delete the weak instance unset($this->declaredInstances[$key]); } } }
php
public function purgeUnreachableWeakInstances() { foreach ($this->declaredInstances as $key=>$instance) { if (!isset($instance['weak']) || $instance['weak'] == false) { $this->walkForGarbageCollection($key); } } // At this point any instance with the "noGarbageCollect" attribute should be kept. Others should be eliminated. $keptInstances = array(); foreach ($this->declaredInstances as $key=>$instance) { if (isset($instance['noGarbageCollect']) && $instance['noGarbageCollect'] == true) { // Let's clear the flag unset($this->declaredInstances[$key]['noGarbageCollect']); } else { // Let's delete the weak instance unset($this->declaredInstances[$key]); } } }
[ "public", "function", "purgeUnreachableWeakInstances", "(", ")", "{", "foreach", "(", "$", "this", "->", "declaredInstances", "as", "$", "key", "=>", "$", "instance", ")", "{", "if", "(", "!", "isset", "(", "$", "instance", "[", "'weak'", "]", ")", "||",...
This function will delete any weak instance that would not be referred anymore. This is used to garbage-collect any unused weak instances. This is public only for test purposes
[ "This", "function", "will", "delete", "any", "weak", "instance", "that", "would", "not", "be", "referred", "anymore", ".", "This", "is", "used", "to", "garbage", "-", "collect", "any", "unused", "weak", "instances", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1739-L1759
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.walkForGarbageCollection
public function walkForGarbageCollection($instanceName) { // In case the instance does not exist (this could happen after a failed merge or a manual edit of MoufComponents.php...) if (!isset($this->declaredInstances[$instanceName])) { return; } $instance = &$this->declaredInstances[$instanceName]; if (isset($instance['noGarbageCollect']) && $instance['noGarbageCollect'] == true) { // No need to go through already visited nodes. return; } $instance['noGarbageCollect'] = true; $declaredInstances = &$this->declaredInstances; $moufManager = $this; if (isset($instance['constructor'])) { foreach ($instance['constructor'] as $argument) { if ($argument["parametertype"] == "object") { $value = $argument["value"]; if(is_array($value)) { array_walk_recursive($value, function($singleValue) use (&$declaredInstances, $moufManager) { if ($singleValue != null) { $moufManager->walkForGarbageCollection($singleValue); } }); /*foreach ($value as $singleValue) { if ($singleValue != null) { $this->walkForGarbageCollection($this->declaredInstances[$singleValue]); } }*/ } else { if ($value != null) { $this->walkForGarbageCollection($value); } } } } } if (isset($instance['fieldBinds'])) { foreach ($instance['fieldBinds'] as $prop) { if(is_array($prop)) { array_walk_recursive($prop, function($singleProp) use (&$declaredInstances, $moufManager) { if ($singleProp != null) { $moufManager->walkForGarbageCollection($singleProp); } }); /*foreach ($prop as $singleProp) { if ($singleProp != null) { $this->walkForGarbageCollection($this->declaredInstances[$singleProp]); } }*/ } else { $this->walkForGarbageCollection($prop); } } } if (isset($instance['setterBinds'])) { foreach ($instance['setterBinds'] as $prop) { if(is_array($prop)) { array_walk_recursive($prop, function($singleProp) use (&$declaredInstances, $moufManager) { if ($singleProp != null) { $moufManager->walkForGarbageCollection($singleProp); } }); /*foreach ($prop as $singleProp) { if ($singleProp != null) { $this->walkForGarbageCollection($this->declaredInstances[$singleProp]); } }*/ } else { $this->walkForGarbageCollection($prop); } } } }
php
public function walkForGarbageCollection($instanceName) { // In case the instance does not exist (this could happen after a failed merge or a manual edit of MoufComponents.php...) if (!isset($this->declaredInstances[$instanceName])) { return; } $instance = &$this->declaredInstances[$instanceName]; if (isset($instance['noGarbageCollect']) && $instance['noGarbageCollect'] == true) { // No need to go through already visited nodes. return; } $instance['noGarbageCollect'] = true; $declaredInstances = &$this->declaredInstances; $moufManager = $this; if (isset($instance['constructor'])) { foreach ($instance['constructor'] as $argument) { if ($argument["parametertype"] == "object") { $value = $argument["value"]; if(is_array($value)) { array_walk_recursive($value, function($singleValue) use (&$declaredInstances, $moufManager) { if ($singleValue != null) { $moufManager->walkForGarbageCollection($singleValue); } }); /*foreach ($value as $singleValue) { if ($singleValue != null) { $this->walkForGarbageCollection($this->declaredInstances[$singleValue]); } }*/ } else { if ($value != null) { $this->walkForGarbageCollection($value); } } } } } if (isset($instance['fieldBinds'])) { foreach ($instance['fieldBinds'] as $prop) { if(is_array($prop)) { array_walk_recursive($prop, function($singleProp) use (&$declaredInstances, $moufManager) { if ($singleProp != null) { $moufManager->walkForGarbageCollection($singleProp); } }); /*foreach ($prop as $singleProp) { if ($singleProp != null) { $this->walkForGarbageCollection($this->declaredInstances[$singleProp]); } }*/ } else { $this->walkForGarbageCollection($prop); } } } if (isset($instance['setterBinds'])) { foreach ($instance['setterBinds'] as $prop) { if(is_array($prop)) { array_walk_recursive($prop, function($singleProp) use (&$declaredInstances, $moufManager) { if ($singleProp != null) { $moufManager->walkForGarbageCollection($singleProp); } }); /*foreach ($prop as $singleProp) { if ($singleProp != null) { $this->walkForGarbageCollection($this->declaredInstances[$singleProp]); } }*/ } else { $this->walkForGarbageCollection($prop); } } } }
[ "public", "function", "walkForGarbageCollection", "(", "$", "instanceName", ")", "{", "// In case the instance does not exist (this could happen after a failed merge or a manual edit of MoufComponents.php...)\r", "if", "(", "!", "isset", "(", "$", "this", "->", "declaredInstances",...
Recursive function that mark this instance as NOT garbage collectable and go through referred nodes. @param string $instanceName
[ "Recursive", "function", "that", "mark", "this", "instance", "as", "NOT", "garbage", "collectable", "and", "go", "through", "referred", "nodes", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1766-L1846
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.isInstanceWeak
public function isInstanceWeak($instanceName) { if (isset($this->declaredInstances[$instanceName]['weak'])) { return $this->declaredInstances[$instanceName]['weak']; } else { return false; } }
php
public function isInstanceWeak($instanceName) { if (isset($this->declaredInstances[$instanceName]['weak'])) { return $this->declaredInstances[$instanceName]['weak']; } else { return false; } }
[ "public", "function", "isInstanceWeak", "(", "$", "instanceName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'weak'", "]", ")", ")", "{", "return", "$", "this", "->", "declaredInstances",...
Returns true if the instance is week @param string $instanceName @return bool
[ "Returns", "true", "if", "the", "instance", "is", "week" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1854-L1860
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.isInstanceAnonymous
public function isInstanceAnonymous($instanceName) { if (isset($this->declaredInstances[$instanceName]['anonymous'])) { return $this->declaredInstances[$instanceName]['anonymous']; } else { return false; } }
php
public function isInstanceAnonymous($instanceName) { if (isset($this->declaredInstances[$instanceName]['anonymous'])) { return $this->declaredInstances[$instanceName]['anonymous']; } else { return false; } }
[ "public", "function", "isInstanceAnonymous", "(", "$", "instanceName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'anonymous'", "]", ")", ")", "{", "return", "$", "this", "->", "declaredI...
Returns true if the instance is anonymous @param string $instanceName @return bool
[ "Returns", "true", "if", "the", "instance", "is", "anonymous" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1878-L1884
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.setInstanceAnonymousness
public function setInstanceAnonymousness($instanceName, $anonymous) { if ($anonymous) { $this->declaredInstances[$instanceName]['anonymous'] = true; // An anonymous object must be weak. $this->declaredInstances[$instanceName]['weak'] = true; } else { unset($this->declaredInstances[$instanceName]['anonymous']); } }
php
public function setInstanceAnonymousness($instanceName, $anonymous) { if ($anonymous) { $this->declaredInstances[$instanceName]['anonymous'] = true; // An anonymous object must be weak. $this->declaredInstances[$instanceName]['weak'] = true; } else { unset($this->declaredInstances[$instanceName]['anonymous']); } }
[ "public", "function", "setInstanceAnonymousness", "(", "$", "instanceName", ",", "$", "anonymous", ")", "{", "if", "(", "$", "anonymous", ")", "{", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "'anonymous'", "]", "=", "true", ...
Decides whether an instance is anonymous or not. @param string $instanceName @param bool $anonymous
[ "Decides", "whether", "an", "instance", "is", "anonymous", "or", "not", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1891-L1899
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.createInstance
public function createInstance($className, $mode = self::DECLARE_ON_EXIST_EXCEPTION) { // FIXME: mode is useless here! We are creating an anonymous instance! $className = ltrim($className, "\\"); $name = $this->getFreeAnonymousName(); $this->declareComponent($name, $className, false, $mode); $this->setInstanceAnonymousness($name, true); return $this->getInstanceDescriptor($name); }
php
public function createInstance($className, $mode = self::DECLARE_ON_EXIST_EXCEPTION) { // FIXME: mode is useless here! We are creating an anonymous instance! $className = ltrim($className, "\\"); $name = $this->getFreeAnonymousName(); $this->declareComponent($name, $className, false, $mode); $this->setInstanceAnonymousness($name, true); return $this->getInstanceDescriptor($name); }
[ "public", "function", "createInstance", "(", "$", "className", ",", "$", "mode", "=", "self", "::", "DECLARE_ON_EXIST_EXCEPTION", ")", "{", "// FIXME: mode is useless here! We are creating an anonymous instance!\r", "$", "className", "=", "ltrim", "(", "$", "className", ...
Creates a new instance and returns the instance descriptor. @param string $className The name of the class of the instance. @param int $mode Depending on the mode, the behaviour will be different if an instance with the same name already exists. @return MoufInstanceDescriptor
[ "Creates", "a", "new", "instance", "and", "returns", "the", "instance", "descriptor", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1956-L1963
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getClassDescriptor
public function getClassDescriptor($className) { if (!isset($this->classDescriptors[$className])) { if (MoufManager::getMoufManager() == null || (MoufManager::getMoufManager()->getScope() == self::SCOPE_APP && $this->getScope() == self::SCOPE_APP) || (MoufManager::getMoufManager()->getScope() == self::SCOPE_ADMIN && $this->getScope() == self::SCOPE_ADMIN)) { // We are fully in the scope of the application: $this->classDescriptors[$className] = new MoufReflectionClass($className); } else { $this->classDescriptors[$className] = MoufReflectionProxy::getClass($className, $this->getScope() == self::SCOPE_ADMIN); } } return $this->classDescriptors[$className]; }
php
public function getClassDescriptor($className) { if (!isset($this->classDescriptors[$className])) { if (MoufManager::getMoufManager() == null || (MoufManager::getMoufManager()->getScope() == self::SCOPE_APP && $this->getScope() == self::SCOPE_APP) || (MoufManager::getMoufManager()->getScope() == self::SCOPE_ADMIN && $this->getScope() == self::SCOPE_ADMIN)) { // We are fully in the scope of the application: $this->classDescriptors[$className] = new MoufReflectionClass($className); } else { $this->classDescriptors[$className] = MoufReflectionProxy::getClass($className, $this->getScope() == self::SCOPE_ADMIN); } } return $this->classDescriptors[$className]; }
[ "public", "function", "getClassDescriptor", "(", "$", "className", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "classDescriptors", "[", "$", "className", "]", ")", ")", "{", "if", "(", "MoufManager", "::", "getMoufManager", "(", ")", "==",...
Returns an object describing the class passed in parameter. This method should only be called in the context of the Mouf administration UI. @param string $className The name of the class to import @return MoufXmlReflectionClass
[ "Returns", "an", "object", "describing", "the", "class", "passed", "in", "parameter", ".", "This", "method", "should", "only", "be", "called", "in", "the", "context", "of", "the", "Mouf", "administration", "UI", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L1994-L2005
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterNames
public function getParameterNames($instanceName) { return array_merge( isset($this->declaredInstances[$instanceName]["fieldProperties"])?array_keys($this->declaredInstances[$instanceName]["fieldProperties"]):array(), isset($this->declaredInstances[$instanceName]["fieldBinds"])?array_keys($this->declaredInstances[$instanceName]["fieldBinds"]):array() ); }
php
public function getParameterNames($instanceName) { return array_merge( isset($this->declaredInstances[$instanceName]["fieldProperties"])?array_keys($this->declaredInstances[$instanceName]["fieldProperties"]):array(), isset($this->declaredInstances[$instanceName]["fieldBinds"])?array_keys($this->declaredInstances[$instanceName]["fieldBinds"]):array() ); }
[ "public", "function", "getParameterNames", "(", "$", "instanceName", ")", "{", "return", "array_merge", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "\"fieldProperties\"", "]", ")", "?", "array_keys", "(", "$",...
Returns the list of public properties' names configured for this instance. @param string $instanceName @return string[]
[ "Returns", "the", "list", "of", "public", "properties", "names", "configured", "for", "this", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L2013-L2018
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.getParameterNamesForSetter
public function getParameterNamesForSetter($instanceName) { return array_merge( isset($this->declaredInstances[$instanceName]["setterProperties"])?array_keys($this->declaredInstances[$instanceName]["setterProperties"]):array(), isset($this->declaredInstances[$instanceName]["setterBinds"])?array_keys($this->declaredInstances[$instanceName]["setterBinds"]):array() ); }
php
public function getParameterNamesForSetter($instanceName) { return array_merge( isset($this->declaredInstances[$instanceName]["setterProperties"])?array_keys($this->declaredInstances[$instanceName]["setterProperties"]):array(), isset($this->declaredInstances[$instanceName]["setterBinds"])?array_keys($this->declaredInstances[$instanceName]["setterBinds"]):array() ); }
[ "public", "function", "getParameterNamesForSetter", "(", "$", "instanceName", ")", "{", "return", "array_merge", "(", "isset", "(", "$", "this", "->", "declaredInstances", "[", "$", "instanceName", "]", "[", "\"setterProperties\"", "]", ")", "?", "array_keys", "...
Returns the list of setters' names configured for this instance. @param string $instanceName @return string[]
[ "Returns", "the", "list", "of", "setters", "names", "configured", "for", "this", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L2026-L2031
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.createInstanceByCode
public function createInstanceByCode() { $name = $this->getFreeAnonymousName(); $this->declaredInstances[$name]["weak"] = false; $this->declaredInstances[$name]["comment"] = ""; $this->declaredInstances[$name]["class"] = null; $this->declaredInstances[$name]["external"] = false; $this->declaredInstances[$name]["code"] = ""; $this->setInstanceAnonymousness($name, true); return $this->getInstanceDescriptor($name); }
php
public function createInstanceByCode() { $name = $this->getFreeAnonymousName(); $this->declaredInstances[$name]["weak"] = false; $this->declaredInstances[$name]["comment"] = ""; $this->declaredInstances[$name]["class"] = null; $this->declaredInstances[$name]["external"] = false; $this->declaredInstances[$name]["code"] = ""; $this->setInstanceAnonymousness($name, true); return $this->getInstanceDescriptor($name); }
[ "public", "function", "createInstanceByCode", "(", ")", "{", "$", "name", "=", "$", "this", "->", "getFreeAnonymousName", "(", ")", ";", "$", "this", "->", "declaredInstances", "[", "$", "name", "]", "[", "\"weak\"", "]", "=", "false", ";", "$", "this", ...
Creates a new instance declared by PHP code. @return MoufInstanceDescriptor
[ "Creates", "a", "new", "instance", "declared", "by", "PHP", "code", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L2052-L2063
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.findInstanceByCallbackType
private function findInstanceByCallbackType($instanceName) { // Note: we execute the code in another thread. Always. // This prevent crashing the main thread. try { $fullyQualifiedClassName = MoufReflectionProxy::getReturnTypeFromCode($this->declaredInstances[$instanceName]["code"], $this->getScope() == self::SCOPE_ADMIN); unset($this->declaredInstances[$instanceName]["error"]); unset($this->declaredInstances[$instanceName]["constructor"]); unset($this->declaredInstances[$instanceName]["fieldProperties"]); unset($this->declaredInstances[$instanceName]["setterProperties"]); unset($this->declaredInstances[$instanceName]["fieldBinds"]); unset($this->declaredInstances[$instanceName]["setterBinds"]); $this->declaredInstances[$instanceName]["class"] = $fullyQualifiedClassName; } catch (\Exception $e) { $this->declaredInstances[$instanceName]["error"] = $e->getMessage(); unset($this->declaredInstances[$instanceName]["class"]); $fullyQualifiedClassName = null; } return $fullyQualifiedClassName; }
php
private function findInstanceByCallbackType($instanceName) { // Note: we execute the code in another thread. Always. // This prevent crashing the main thread. try { $fullyQualifiedClassName = MoufReflectionProxy::getReturnTypeFromCode($this->declaredInstances[$instanceName]["code"], $this->getScope() == self::SCOPE_ADMIN); unset($this->declaredInstances[$instanceName]["error"]); unset($this->declaredInstances[$instanceName]["constructor"]); unset($this->declaredInstances[$instanceName]["fieldProperties"]); unset($this->declaredInstances[$instanceName]["setterProperties"]); unset($this->declaredInstances[$instanceName]["fieldBinds"]); unset($this->declaredInstances[$instanceName]["setterBinds"]); $this->declaredInstances[$instanceName]["class"] = $fullyQualifiedClassName; } catch (\Exception $e) { $this->declaredInstances[$instanceName]["error"] = $e->getMessage(); unset($this->declaredInstances[$instanceName]["class"]); $fullyQualifiedClassName = null; } return $fullyQualifiedClassName; }
[ "private", "function", "findInstanceByCallbackType", "(", "$", "instanceName", ")", "{", "// Note: we execute the code in another thread. Always.\r", "// This prevent crashing the main thread.\r", "try", "{", "$", "fullyQualifiedClassName", "=", "MoufReflectionProxy", "::", "getRet...
Returns the type of an instance defined by callback. For this, the instanciation code will be executed and the result will be returned. @param string $instanceName The name of the instance to analyze. @return string
[ "Returns", "the", "type", "of", "an", "instance", "defined", "by", "callback", ".", "For", "this", "the", "instanciation", "code", "will", "be", "executed", "and", "the", "result", "will", "be", "returned", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L2118-L2136
train
thecodingmachine/mouf
src/Mouf/MoufManager.php
MoufManager.walkConstructorLoop
private function walkConstructorLoop($instanceName, array $path) { if(isset($path[$instanceName])) { $instances = array_keys($path); $instances = array_slice($instances, array_search($instanceName, $instances)); throw new MoufContainerException('A loop was detected on constructor arguments '.implode(' -> ', $instances).' -> '.$instanceName); } $path[$instanceName] = true; $descriptor = $this->declaredInstances[$instanceName]; if(isset($descriptor['constructor'])) { foreach ($descriptor['constructor'] as $constructorArg) { if($constructorArg['parametertype'] == 'object') { if(is_array($constructorArg['value'])) { foreach ($constructorArg['value'] as $subInstanceName) { if($subInstanceName !== null) { $this->walkConstructorLoop($subInstanceName, $path); } } } else { if($constructorArg['value'] !== null) { $this->walkConstructorLoop($constructorArg['value'], $path); } } } } } }
php
private function walkConstructorLoop($instanceName, array $path) { if(isset($path[$instanceName])) { $instances = array_keys($path); $instances = array_slice($instances, array_search($instanceName, $instances)); throw new MoufContainerException('A loop was detected on constructor arguments '.implode(' -> ', $instances).' -> '.$instanceName); } $path[$instanceName] = true; $descriptor = $this->declaredInstances[$instanceName]; if(isset($descriptor['constructor'])) { foreach ($descriptor['constructor'] as $constructorArg) { if($constructorArg['parametertype'] == 'object') { if(is_array($constructorArg['value'])) { foreach ($constructorArg['value'] as $subInstanceName) { if($subInstanceName !== null) { $this->walkConstructorLoop($subInstanceName, $path); } } } else { if($constructorArg['value'] !== null) { $this->walkConstructorLoop($constructorArg['value'], $path); } } } } } }
[ "private", "function", "walkConstructorLoop", "(", "$", "instanceName", ",", "array", "$", "path", ")", "{", "if", "(", "isset", "(", "$", "path", "[", "$", "instanceName", "]", ")", ")", "{", "$", "instances", "=", "array_keys", "(", "$", "path", ")",...
This take a instance name and the path to access. It throw an exception if a loop was detected @param string $instanceName @param array $path @throws MoufContainerException
[ "This", "take", "a", "instance", "name", "and", "the", "path", "to", "access", ".", "It", "throw", "an", "exception", "if", "a", "loop", "was", "detected" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufManager.php#L2166-L2192
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.getClass
public static function getClass($className, $selfEdit) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/get_class.php?class=".$className."&selfedit=".(($selfEdit)?"true":"false"); $response = self::performRequest($url); return new MoufXmlReflectionClass($response); }
php
public static function getClass($className, $selfEdit) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/get_class.php?class=".$className."&selfedit=".(($selfEdit)?"true":"false"); $response = self::performRequest($url); return new MoufXmlReflectionClass($response); }
[ "public", "static", "function", "getClass", "(", "$", "className", ",", "$", "selfEdit", ")", "{", "$", "url", "=", "MoufReflectionProxy", "::", "getLocalUrlToProject", "(", ")", ".", "\"src/direct/get_class.php?class=\"", ".", "$", "className", ".", "\"&selfedit=...
Returns a MoufXmlReflectionClass representing the class we are going to analyze. @param string $className @param boolean $selfEdit @return MoufXmlReflectionClass
[ "Returns", "a", "MoufXmlReflectionClass", "representing", "the", "class", "we", "are", "going", "to", "analyze", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L30-L36
train
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionProxy.php
MoufReflectionProxy.getAllClasses
public static function getAllClasses($selfEdit, $exportMode = MoufReflectionClass::EXPORT_ALL) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/get_all_classes.php?selfedit=".(($selfEdit)?"true":"false")."&export_mode=".$exportMode; $response = self::performRequest($url); $obj = @unserialize($response); if ($obj === false) { throw new Exception("Unable to unserialize message:\n".$response."\n<br/>URL in error: <a href='".plainstring_to_htmlprotected($url, ENT_QUOTES)."'>".plainstring_to_htmlprotected($url, ENT_QUOTES)."</a>"); } return $obj; }
php
public static function getAllClasses($selfEdit, $exportMode = MoufReflectionClass::EXPORT_ALL) { $url = MoufReflectionProxy::getLocalUrlToProject()."src/direct/get_all_classes.php?selfedit=".(($selfEdit)?"true":"false")."&export_mode=".$exportMode; $response = self::performRequest($url); $obj = @unserialize($response); if ($obj === false) { throw new Exception("Unable to unserialize message:\n".$response."\n<br/>URL in error: <a href='".plainstring_to_htmlprotected($url, ENT_QUOTES)."'>".plainstring_to_htmlprotected($url, ENT_QUOTES)."</a>"); } return $obj; }
[ "public", "static", "function", "getAllClasses", "(", "$", "selfEdit", ",", "$", "exportMode", "=", "MoufReflectionClass", "::", "EXPORT_ALL", ")", "{", "$", "url", "=", "MoufReflectionProxy", "::", "getLocalUrlToProject", "(", ")", ".", "\"src/direct/get_all_classe...
Returns the complete list of all classes in a PHP array. @param boolean $selfEdit @return array
[ "Returns", "the", "complete", "list", "of", "all", "classes", "in", "a", "PHP", "array", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionProxy.php#L44-L56
train