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
thelia/core
lib/Thelia/Controller/Admin/CouponController.php
CouponController.getAvailableCoupons
protected function getAvailableCoupons() { /** @var CouponManager $couponManager */ $couponManager = $this->container->get('thelia.coupon.manager'); $availableCoupons = $couponManager->getAvailableCoupons(); $cleanedCoupons = []; /** @var CouponInterface $availableCoupon */ foreach ($availableCoupons as $availableCoupon) { $condition = []; $condition['serviceId'] = $availableCoupon->getServiceId(); $condition['name'] = $availableCoupon->getName(); $condition['toolTip'] = $availableCoupon->getToolTip(); $cleanedCoupons[] = $condition; } return $cleanedCoupons; }
php
protected function getAvailableCoupons() { /** @var CouponManager $couponManager */ $couponManager = $this->container->get('thelia.coupon.manager'); $availableCoupons = $couponManager->getAvailableCoupons(); $cleanedCoupons = []; /** @var CouponInterface $availableCoupon */ foreach ($availableCoupons as $availableCoupon) { $condition = []; $condition['serviceId'] = $availableCoupon->getServiceId(); $condition['name'] = $availableCoupon->getName(); $condition['toolTip'] = $availableCoupon->getToolTip(); $cleanedCoupons[] = $condition; } return $cleanedCoupons; }
[ "protected", "function", "getAvailableCoupons", "(", ")", "{", "/** @var CouponManager $couponManager */", "$", "couponManager", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.coupon.manager'", ")", ";", "$", "availableCoupons", "=", "$", "couponManag...
Get all available coupons @return array
[ "Get", "all", "available", "coupons" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CouponController.php#L581-L598
train
thelia/core
lib/Thelia/Controller/Admin/CouponController.php
CouponController.cleanConditionForTemplate
protected function cleanConditionForTemplate(ConditionCollection $conditions) { $cleanedConditions = []; /** @var $condition ConditionInterface */ foreach ($conditions as $index => $condition) { $temp = [ 'serviceId' => $condition->getServiceId(), 'index' => $index, 'name' => $condition->getName(), 'toolTip' => $condition->getToolTip(), 'summary' => $condition->getSummary(), 'validators' => $condition->getValidators() ]; $cleanedConditions[] = $temp; } return $cleanedConditions; }
php
protected function cleanConditionForTemplate(ConditionCollection $conditions) { $cleanedConditions = []; /** @var $condition ConditionInterface */ foreach ($conditions as $index => $condition) { $temp = [ 'serviceId' => $condition->getServiceId(), 'index' => $index, 'name' => $condition->getName(), 'toolTip' => $condition->getToolTip(), 'summary' => $condition->getSummary(), 'validators' => $condition->getValidators() ]; $cleanedConditions[] = $temp; } return $cleanedConditions; }
[ "protected", "function", "cleanConditionForTemplate", "(", "ConditionCollection", "$", "conditions", ")", "{", "$", "cleanedConditions", "=", "[", "]", ";", "/** @var $condition ConditionInterface */", "foreach", "(", "$", "conditions", "as", "$", "index", "=>", "$", ...
Clean condition for template @param ConditionCollection $conditions Condition collection @return array
[ "Clean", "condition", "for", "template" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CouponController.php#L607-L624
train
thelia/core
lib/Thelia/Controller/Admin/CouponController.php
CouponController.feedCouponCreateOrUpdateEvent
protected function feedCouponCreateOrUpdateEvent(Form $form, Coupon $model = null) { // Get the form field values $data = $form->getData(); $serviceId = $data['type']; /** @var CouponInterface $coupon */ $coupon = $this->container->get($serviceId); $couponEvent = new CouponCreateOrUpdateEvent( $data['code'], $serviceId, $data['title'], $coupon->getEffects($data), $data['shortDescription'], $data['description'], $data['isEnabled'], \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], $data['maxUsage'], $data['locale'], $data['freeShippingForCountries'], $data['freeShippingForModules'], $data['perCustomerUsageCount'], empty($data['startDate']) ? null : \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['startDate']) ); // If Update mode if (isset($model)) { $couponEvent->setCouponModel($model); } return $couponEvent; }
php
protected function feedCouponCreateOrUpdateEvent(Form $form, Coupon $model = null) { // Get the form field values $data = $form->getData(); $serviceId = $data['type']; /** @var CouponInterface $coupon */ $coupon = $this->container->get($serviceId); $couponEvent = new CouponCreateOrUpdateEvent( $data['code'], $serviceId, $data['title'], $coupon->getEffects($data), $data['shortDescription'], $data['description'], $data['isEnabled'], \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], $data['maxUsage'], $data['locale'], $data['freeShippingForCountries'], $data['freeShippingForModules'], $data['perCustomerUsageCount'], empty($data['startDate']) ? null : \DateTime::createFromFormat($this->getDefaultDateFormat(), $data['startDate']) ); // If Update mode if (isset($model)) { $couponEvent->setCouponModel($model); } return $couponEvent; }
[ "protected", "function", "feedCouponCreateOrUpdateEvent", "(", "Form", "$", "form", ",", "Coupon", "$", "model", "=", "null", ")", "{", "// Get the form field values", "$", "data", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "serviceId", "=", "$",...
Feed the Coupon Create or Update event with the User inputs @param Form $form Form containing user data @param Coupon $model Model if in update mode @return CouponCreateOrUpdateEvent
[ "Feed", "the", "Coupon", "Create", "or", "Update", "event", "with", "the", "User", "inputs" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CouponController.php#L704-L739
train
thelia/core
lib/Thelia/Controller/Admin/CouponController.php
CouponController.buildConditionFromRequest
protected function buildConditionFromRequest() { $request = $this->getRequest(); $post = $request->request->getIterator(); $serviceId = $request->request->get('categoryCondition'); $operators = []; $values = []; foreach ($post as $key => $input) { if (isset($input['operator']) && isset($input['value'])) { $operators[$key] = $input['operator']; $values[$key] = $input['value']; } } /** @var ConditionFactory $conditionFactory */ $conditionFactory = $this->container->get('thelia.condition.factory'); $conditionToSave = $conditionFactory->build($serviceId, $operators, $values); return $conditionToSave; }
php
protected function buildConditionFromRequest() { $request = $this->getRequest(); $post = $request->request->getIterator(); $serviceId = $request->request->get('categoryCondition'); $operators = []; $values = []; foreach ($post as $key => $input) { if (isset($input['operator']) && isset($input['value'])) { $operators[$key] = $input['operator']; $values[$key] = $input['value']; } } /** @var ConditionFactory $conditionFactory */ $conditionFactory = $this->container->get('thelia.condition.factory'); $conditionToSave = $conditionFactory->build($serviceId, $operators, $values); return $conditionToSave; }
[ "protected", "function", "buildConditionFromRequest", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "post", "=", "$", "request", "->", "request", "->", "getIterator", "(", ")", ";", "$", "serviceId", "=", "$", ...
Build ConditionInterface from request @return ConditionInterface
[ "Build", "ConditionInterface", "from", "request" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CouponController.php#L746-L765
train
thelia/core
lib/Thelia/Controller/Admin/CouponController.php
CouponController.manageConditionUpdate
protected function manageConditionUpdate(Coupon $coupon, ConditionCollection $conditions) { $couponEvent = new CouponCreateOrUpdateEvent( $coupon->getCode(), $coupon->getType(), $coupon->getTitle(), $coupon->getEffects(), $coupon->getShortDescription(), $coupon->getDescription(), $coupon->getIsEnabled(), $coupon->getExpirationDate(), $coupon->getIsAvailableOnSpecialOffers(), $coupon->getIsCumulative(), $coupon->getIsRemovingPostage(), $coupon->getMaxUsage(), $coupon->getLocale(), $coupon->getFreeShippingForCountries(), $coupon->getFreeShippingForModules(), $coupon->getPerCustomerUsageCount(), $coupon->getStartDate() ); $couponEvent->setCouponModel($coupon); $couponEvent->setConditions($conditions); $eventToDispatch = TheliaEvents::COUPON_CONDITION_UPDATE; // Dispatch Event to the Action $this->dispatch( $eventToDispatch, $couponEvent ); $this->adminLogAppend( AdminResources::COUPON, AccessManager::UPDATE, sprintf( 'Coupon %s (ID %s) conditions updated', $couponEvent->getCouponModel()->getTitle(), $couponEvent->getCouponModel()->getType() ), $couponEvent->getCouponModel()->getId() ); }
php
protected function manageConditionUpdate(Coupon $coupon, ConditionCollection $conditions) { $couponEvent = new CouponCreateOrUpdateEvent( $coupon->getCode(), $coupon->getType(), $coupon->getTitle(), $coupon->getEffects(), $coupon->getShortDescription(), $coupon->getDescription(), $coupon->getIsEnabled(), $coupon->getExpirationDate(), $coupon->getIsAvailableOnSpecialOffers(), $coupon->getIsCumulative(), $coupon->getIsRemovingPostage(), $coupon->getMaxUsage(), $coupon->getLocale(), $coupon->getFreeShippingForCountries(), $coupon->getFreeShippingForModules(), $coupon->getPerCustomerUsageCount(), $coupon->getStartDate() ); $couponEvent->setCouponModel($coupon); $couponEvent->setConditions($conditions); $eventToDispatch = TheliaEvents::COUPON_CONDITION_UPDATE; // Dispatch Event to the Action $this->dispatch( $eventToDispatch, $couponEvent ); $this->adminLogAppend( AdminResources::COUPON, AccessManager::UPDATE, sprintf( 'Coupon %s (ID %s) conditions updated', $couponEvent->getCouponModel()->getTitle(), $couponEvent->getCouponModel()->getType() ), $couponEvent->getCouponModel()->getId() ); }
[ "protected", "function", "manageConditionUpdate", "(", "Coupon", "$", "coupon", ",", "ConditionCollection", "$", "conditions", ")", "{", "$", "couponEvent", "=", "new", "CouponCreateOrUpdateEvent", "(", "$", "coupon", "->", "getCode", "(", ")", ",", "$", "coupon...
Manage how a Condition is updated @param Coupon $coupon Coupon Model @param ConditionCollection $conditions Condition collection
[ "Manage", "how", "a", "Condition", "is", "updated" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Controller/Admin/CouponController.php#L773-L814
train
thelia/core
lib/Thelia/Files/FileManager.php
FileManager.getModelInstance
public function getModelInstance($fileType, $parentType) { if (! isset($this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)])) { throw new FileException( sprintf("Unsupported file type '%s' for parent type '%s'", $fileType, $parentType) ); } $className = $this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)]; $instance = new $className; if (! $instance instanceof FileModelInterface) { throw new FileException( sprintf( "Wrong class type for file type '%s', parent type '%s'. Class '%s' should implements FileModelInterface", $fileType, $parentType, $className ) ); } return $instance; }
php
public function getModelInstance($fileType, $parentType) { if (! isset($this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)])) { throw new FileException( sprintf("Unsupported file type '%s' for parent type '%s'", $fileType, $parentType) ); } $className = $this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)]; $instance = new $className; if (! $instance instanceof FileModelInterface) { throw new FileException( sprintf( "Wrong class type for file type '%s', parent type '%s'. Class '%s' should implements FileModelInterface", $fileType, $parentType, $className ) ); } return $instance; }
[ "public", "function", "getModelInstance", "(", "$", "fileType", ",", "$", "parentType", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "supportedFileModels", "[", "$", "this", "->", "getFileTypeIdentifier", "(", "$", "fileType", ",", "$", "pare...
Create a new FileModelInterface instance, from the supportedFileModels table @param string $fileType the file type, such as document, image, etc. @param string $parentType the parent type, such as product, category, etc. @return FileModelInterface a file model interface instance @throws FileException if the file type is not supported, or if the class does not implements FileModelInterface
[ "Create", "a", "new", "FileModelInterface", "instance", "from", "the", "supportedFileModels", "table" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Files/FileManager.php#L63-L87
train
thelia/core
lib/Thelia/Files/FileManager.php
FileManager.addFileModel
public function addFileModel($fileType, $parentType, $fullyQualifiedClassName) { $this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)] = $fullyQualifiedClassName; }
php
public function addFileModel($fileType, $parentType, $fullyQualifiedClassName) { $this->supportedFileModels[$this->getFileTypeIdentifier($fileType, $parentType)] = $fullyQualifiedClassName; }
[ "public", "function", "addFileModel", "(", "$", "fileType", ",", "$", "parentType", ",", "$", "fullyQualifiedClassName", ")", "{", "$", "this", "->", "supportedFileModels", "[", "$", "this", "->", "getFileTypeIdentifier", "(", "$", "fileType", ",", "$", "paren...
A a new FileModelInterface class name to the supported class list. @param string $fileType the file type, such as document, image, etc. @param string $parentType the parent type, such as Product, Category, etc. @param string $fullyQualifiedClassName the fully qualified class name
[ "A", "a", "new", "FileModelInterface", "class", "name", "to", "the", "supported", "class", "list", "." ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Files/FileManager.php#L96-L99
train
thelia/core
lib/Thelia/Files/FileManager.php
FileManager.copyUploadedFile
public function copyUploadedFile(FileModelInterface $model, UploadedFile $uploadedFile, ConnectionInterface $con = null) { $newUploadedFile = null; if ($uploadedFile !== null) { $directory = $model->getUploadDir(); $fileName = $this->renameFile($model->getId(), $uploadedFile); $newUploadedFile = $uploadedFile->move($directory, $fileName); $model->setFile($fileName); if (!$model->save($con)) { throw new ImageException( sprintf( 'Failed to update model after copy of uploaded file %s to %s', $uploadedFile, $model->getFile() ) ); } } return $newUploadedFile; }
php
public function copyUploadedFile(FileModelInterface $model, UploadedFile $uploadedFile, ConnectionInterface $con = null) { $newUploadedFile = null; if ($uploadedFile !== null) { $directory = $model->getUploadDir(); $fileName = $this->renameFile($model->getId(), $uploadedFile); $newUploadedFile = $uploadedFile->move($directory, $fileName); $model->setFile($fileName); if (!$model->save($con)) { throw new ImageException( sprintf( 'Failed to update model after copy of uploaded file %s to %s', $uploadedFile, $model->getFile() ) ); } } return $newUploadedFile; }
[ "public", "function", "copyUploadedFile", "(", "FileModelInterface", "$", "model", ",", "UploadedFile", "$", "uploadedFile", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "newUploadedFile", "=", "null", ";", "if", "(", "$", "uploadedFile", ...
Copy UploadedFile into the server storage directory @param FileModelInterface $model Model saved @param UploadedFile $uploadedFile Ready to be uploaded file @param ConnectionInterface $con current transaction with database @throws \Thelia\Exception\ImageException @return UploadedFile|null
[ "Copy", "UploadedFile", "into", "the", "server", "storage", "directory" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Files/FileManager.php#L111-L135
train
thelia/core
lib/Thelia/Files/FileManager.php
FileManager.deleteFile
public function deleteFile(FileModelInterface $model) { $url = $model->getUploadDir() . DS . $model->getFile(); @unlink(str_replace('..', '', $url)); $model->delete(); }
php
public function deleteFile(FileModelInterface $model) { $url = $model->getUploadDir() . DS . $model->getFile(); @unlink(str_replace('..', '', $url)); $model->delete(); }
[ "public", "function", "deleteFile", "(", "FileModelInterface", "$", "model", ")", "{", "$", "url", "=", "$", "model", "->", "getUploadDir", "(", ")", ".", "DS", ".", "$", "model", "->", "getFile", "(", ")", ";", "@", "unlink", "(", "str_replace", "(", ...
Delete image from file storage and database @param FileModelInterface $model File being deleted
[ "Delete", "image", "from", "file", "storage", "and", "database" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Files/FileManager.php#L215-L222
train
thelia/core
lib/Thelia/Files/FileManager.php
FileManager.renameFile
public function renameFile($modelId, UploadedFile $uploadedFile) { $extension = $uploadedFile->getClientOriginalExtension(); if (!empty($extension)) { $extension = '.' . strtolower($extension); } $fileName = $this->sanitizeFileName( str_replace( $extension, '', $uploadedFile->getClientOriginalName() ) . '-' . $modelId . $extension ); return $fileName; }
php
public function renameFile($modelId, UploadedFile $uploadedFile) { $extension = $uploadedFile->getClientOriginalExtension(); if (!empty($extension)) { $extension = '.' . strtolower($extension); } $fileName = $this->sanitizeFileName( str_replace( $extension, '', $uploadedFile->getClientOriginalName() ) . '-' . $modelId . $extension ); return $fileName; }
[ "public", "function", "renameFile", "(", "$", "modelId", ",", "UploadedFile", "$", "uploadedFile", ")", "{", "$", "extension", "=", "$", "uploadedFile", "->", "getClientOriginalExtension", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "extension", ")", ...
Rename file with image model id @param int $modelId Model id @param UploadedFile $uploadedFile File being saved @return string
[ "Rename", "file", "with", "image", "model", "id" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Files/FileManager.php#L232-L247
train
thelia/core
lib/Thelia/Files/FileManager.php
FileManager.isImage
public function isImage($mimeType) { $isValid = false; $allowedType = array('image/jpeg' , 'image/png' ,'image/gif'); if (\in_array($mimeType, $allowedType)) { $isValid = true; } return $isValid; }
php
public function isImage($mimeType) { $isValid = false; $allowedType = array('image/jpeg' , 'image/png' ,'image/gif'); if (\in_array($mimeType, $allowedType)) { $isValid = true; } return $isValid; }
[ "public", "function", "isImage", "(", "$", "mimeType", ")", "{", "$", "isValid", "=", "false", ";", "$", "allowedType", "=", "array", "(", "'image/jpeg'", ",", "'image/png'", ",", "'image/gif'", ")", ";", "if", "(", "\\", "in_array", "(", "$", "mimeType"...
Check if a file is an image Check based on mime type @param string $mimeType File mime type @return bool
[ "Check", "if", "a", "file", "is", "an", "image", "Check", "based", "on", "mime", "type" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Files/FileManager.php#L257-L268
train
mglaman/platform-docker
src/Stacks/Drupal.php
Drupal.ensureSettings
protected function ensureSettings() { if (!$this->fs->exists(Platform::webDir() . '/sites/default')) { $this->fs->mkdir(Platform::webDir() . '/sites/default', 0775); } else { // If building from an existing project, Drupal may have fiddled with // the permissions preventing us from writing. $this->fs->chmod(Platform::webDir() . '/sites/default', 0775); } $has_settings = $this->fs->exists(Platform::webDir() . '/sites/default/settings.php'); if ($has_settings) { $this->fs->chmod(Platform::webDir() . '/sites/default/settings.php', 0664); } switch ($this->version) { case DrupalStackHelper::DRUPAL7: if (!$has_settings) { $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal7/settings.php', Platform::webDir() . '/sites/default/settings.php', true); } break; case DrupalStackHelper::DRUPAL8: if (!$has_settings) { $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal8/settings.php', Platform::webDir() . '/sites/default/settings.php', true); } $this->fs->mkdir([ Platform::sharedDir() . '/config', Platform::sharedDir() . '/config/active', Platform::sharedDir() . '/config/staging', ]); break; default: throw new \Exception('Unsupported version of Drupal. Write a pull reuqest!'); } }
php
protected function ensureSettings() { if (!$this->fs->exists(Platform::webDir() . '/sites/default')) { $this->fs->mkdir(Platform::webDir() . '/sites/default', 0775); } else { // If building from an existing project, Drupal may have fiddled with // the permissions preventing us from writing. $this->fs->chmod(Platform::webDir() . '/sites/default', 0775); } $has_settings = $this->fs->exists(Platform::webDir() . '/sites/default/settings.php'); if ($has_settings) { $this->fs->chmod(Platform::webDir() . '/sites/default/settings.php', 0664); } switch ($this->version) { case DrupalStackHelper::DRUPAL7: if (!$has_settings) { $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal7/settings.php', Platform::webDir() . '/sites/default/settings.php', true); } break; case DrupalStackHelper::DRUPAL8: if (!$has_settings) { $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal8/settings.php', Platform::webDir() . '/sites/default/settings.php', true); } $this->fs->mkdir([ Platform::sharedDir() . '/config', Platform::sharedDir() . '/config/active', Platform::sharedDir() . '/config/staging', ]); break; default: throw new \Exception('Unsupported version of Drupal. Write a pull reuqest!'); } }
[ "protected", "function", "ensureSettings", "(", ")", "{", "if", "(", "!", "$", "this", "->", "fs", "->", "exists", "(", "Platform", "::", "webDir", "(", ")", ".", "'/sites/default'", ")", ")", "{", "$", "this", "->", "fs", "->", "mkdir", "(", "Platfo...
Ensures that the Drupal settings.php is available. @throws \Exception
[ "Ensures", "that", "the", "Drupal", "settings", ".", "php", "is", "available", "." ]
217be131f70454a0f2c62a7ae0553c432731bfdf
https://github.com/mglaman/platform-docker/blob/217be131f70454a0f2c62a7ae0553c432731bfdf/src/Stacks/Drupal.php#L41-L74
train
mglaman/platform-docker
src/Stacks/Drupal.php
Drupal.drushrc
public function drushrc() { // @todo: Check if drushrc.php exists, load in any $conf changes. switch ($this->version) { case DrupalStackHelper::DRUPAL7: $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal7/drushrc.php', Platform::sharedDir() . '/drushrc.php', true); break; case DrupalStackHelper::DRUPAL8: $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal8/drushrc.php', Platform::sharedDir() . '/drushrc.php', true); break; default: throw new \Exception('Unsupported version of Drupal. Write a pull reuqest!'); } // Replace template variables. $localSettings = file_get_contents(Platform::sharedDir() . '/drushrc.php'); // @todo this expects proxy to be running. $localSettings = str_replace('{{ project_domain }}', $this->projectName . '.' . $this->projectTld, $localSettings); file_put_contents(Platform::sharedDir() . '/drushrc.php', $localSettings); if (!file_exists(Platform::webDir() . '/sites/default/drushrc.php')) { $this->fs->symlink($this->getRelativeLinkToShared() . 'drushrc.php', Platform::webDir() . '/sites/default/drushrc.php'); } }
php
public function drushrc() { // @todo: Check if drushrc.php exists, load in any $conf changes. switch ($this->version) { case DrupalStackHelper::DRUPAL7: $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal7/drushrc.php', Platform::sharedDir() . '/drushrc.php', true); break; case DrupalStackHelper::DRUPAL8: $this->fs->copy(CLI_ROOT . '/resources/stacks/drupal8/drushrc.php', Platform::sharedDir() . '/drushrc.php', true); break; default: throw new \Exception('Unsupported version of Drupal. Write a pull reuqest!'); } // Replace template variables. $localSettings = file_get_contents(Platform::sharedDir() . '/drushrc.php'); // @todo this expects proxy to be running. $localSettings = str_replace('{{ project_domain }}', $this->projectName . '.' . $this->projectTld, $localSettings); file_put_contents(Platform::sharedDir() . '/drushrc.php', $localSettings); if (!file_exists(Platform::webDir() . '/sites/default/drushrc.php')) { $this->fs->symlink($this->getRelativeLinkToShared() . 'drushrc.php', Platform::webDir() . '/sites/default/drushrc.php'); } }
[ "public", "function", "drushrc", "(", ")", "{", "// @todo: Check if drushrc.php exists, load in any $conf changes.", "switch", "(", "$", "this", "->", "version", ")", "{", "case", "DrupalStackHelper", "::", "DRUPAL7", ":", "$", "this", "->", "fs", "->", "copy", "(...
Write a drushrc
[ "Write", "a", "drushrc" ]
217be131f70454a0f2c62a7ae0553c432731bfdf
https://github.com/mglaman/platform-docker/blob/217be131f70454a0f2c62a7ae0553c432731bfdf/src/Stacks/Drupal.php#L114-L136
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.addPrompt
public function addPrompt( $prompt ) { $added = false; /* * Determine whether to add the new prompt or not. * * If we've already a prompt for user_did_this_x_times, don't add another prompt for the * same thing. * * If a plugin has already been dismissed, no need to add any additional rating prompts, * they will never be showing. */ if ( ! $this->isPrompt( $prompt['name'] ) && ! $this->isPluginDismissed( $prompt['plugin'] ) ) { $prompt['time_added'] = time(); $prompts = $this->getPrompts(); $prompts[] = $prompt; $added = $this->savePrompts( $prompts ); } return $added; }
php
public function addPrompt( $prompt ) { $added = false; /* * Determine whether to add the new prompt or not. * * If we've already a prompt for user_did_this_x_times, don't add another prompt for the * same thing. * * If a plugin has already been dismissed, no need to add any additional rating prompts, * they will never be showing. */ if ( ! $this->isPrompt( $prompt['name'] ) && ! $this->isPluginDismissed( $prompt['plugin'] ) ) { $prompt['time_added'] = time(); $prompts = $this->getPrompts(); $prompts[] = $prompt; $added = $this->savePrompts( $prompts ); } return $added; }
[ "public", "function", "addPrompt", "(", "$", "prompt", ")", "{", "$", "added", "=", "false", ";", "/*\n\t\t * Determine whether to add the new prompt or not.\n\t\t *\n\t\t * If we've already a prompt for user_did_this_x_times, don't add another prompt for the\n\t\t * same thing.\n\t\t *\n\...
Add a prompt. This only adds a prompt if it doesn't already exist by name. @since 2.7.7 @param array $prompt An array of configs for a prompt. @return bool Whether or not the prompt was added.
[ "Add", "a", "prompt", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L84-L107
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.admin_notices
public function admin_notices() { if ( ! current_user_can( $this->userRole ) ) { return; } $prompt = $this->getNext(); if ( empty( $prompt ) ) { return; } $slides = $this->getPromptSlides( $prompt ); if ( ! empty( $slides ) ) { echo '<div class="notice notice-success bglib-rating-prompt is-dismissible" data-slide-name="' . esc_attr( $prompt['name'] ) . '">'; foreach ( $slides as $slide ) { echo $slide; } wp_nonce_field( 'bglib-rating-prompt' ); echo '</div>'; } }
php
public function admin_notices() { if ( ! current_user_can( $this->userRole ) ) { return; } $prompt = $this->getNext(); if ( empty( $prompt ) ) { return; } $slides = $this->getPromptSlides( $prompt ); if ( ! empty( $slides ) ) { echo '<div class="notice notice-success bglib-rating-prompt is-dismissible" data-slide-name="' . esc_attr( $prompt['name'] ) . '">'; foreach ( $slides as $slide ) { echo $slide; } wp_nonce_field( 'bglib-rating-prompt' ); echo '</div>'; } }
[ "public", "function", "admin_notices", "(", ")", "{", "if", "(", "!", "current_user_can", "(", "$", "this", "->", "userRole", ")", ")", "{", "return", ";", "}", "$", "prompt", "=", "$", "this", "->", "getNext", "(", ")", ";", "if", "(", "empty", "(...
Add admin notices. @since 2.7.7
[ "Add", "admin", "notices", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L114-L133
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.ajaxDismiss
public function ajaxDismiss() { if ( ! current_user_can( $this->userRole ) ) { wp_send_json_error( __( 'Permission denied.', 'boldgrid-library' ) ); } if( ! check_ajax_referer( 'bglib-rating-prompt', 'security', false ) ) { wp_send_json_error( __( 'Invalid nonce.', 'boldgrid-library' ) ); } $name = sanitize_text_field( $_POST['name'] ); $type = sanitize_text_field( $_POST['type'] ); $snooze_length = (int) $_POST['length']; switch( $type ) { case 'dismiss': $dismissed = $this->updatePromptKey( $name, 'time_dismissed', time() ); $dismissed ? wp_send_json_success() : wp_send_json_error( __( 'Error dismissing prompt', 'boldgrid-library' ) ); break; case 'snooze': $time_snoozed_set = $this->updatePromptKey( $name, 'time_snoozed', time() ); $snoozed = $this->updatePromptKey( $name, 'time_snoozed_until', time() + $snooze_length ); $time_snoozed_set && $snoozed ? wp_send_json_success() : wp_send_json_error( __( 'Error snoozing prompt', 'boldgrid-library' ) ); break; default: wp_send_json_error( __( 'Unknown action.', 'boldgrid-library' ) ); } }
php
public function ajaxDismiss() { if ( ! current_user_can( $this->userRole ) ) { wp_send_json_error( __( 'Permission denied.', 'boldgrid-library' ) ); } if( ! check_ajax_referer( 'bglib-rating-prompt', 'security', false ) ) { wp_send_json_error( __( 'Invalid nonce.', 'boldgrid-library' ) ); } $name = sanitize_text_field( $_POST['name'] ); $type = sanitize_text_field( $_POST['type'] ); $snooze_length = (int) $_POST['length']; switch( $type ) { case 'dismiss': $dismissed = $this->updatePromptKey( $name, 'time_dismissed', time() ); $dismissed ? wp_send_json_success() : wp_send_json_error( __( 'Error dismissing prompt', 'boldgrid-library' ) ); break; case 'snooze': $time_snoozed_set = $this->updatePromptKey( $name, 'time_snoozed', time() ); $snoozed = $this->updatePromptKey( $name, 'time_snoozed_until', time() + $snooze_length ); $time_snoozed_set && $snoozed ? wp_send_json_success() : wp_send_json_error( __( 'Error snoozing prompt', 'boldgrid-library' ) ); break; default: wp_send_json_error( __( 'Unknown action.', 'boldgrid-library' ) ); } }
[ "public", "function", "ajaxDismiss", "(", ")", "{", "if", "(", "!", "current_user_can", "(", "$", "this", "->", "userRole", ")", ")", "{", "wp_send_json_error", "(", "__", "(", "'Permission denied.'", ",", "'boldgrid-library'", ")", ")", ";", "}", "if", "(...
Dismiss a rating prompt via ajax. @since 2.7.7 @hook wp_ajax_blib_rating_prompt_dismiss
[ "Dismiss", "a", "rating", "prompt", "via", "ajax", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L142-L168
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.getLastDismissal
public function getLastDismissal() { $lastDismissal = 0; $prompts = $this->getPrompts(); foreach ( $prompts as $prompt ) { $promptDismissal = 0; if ( ! empty( $prompt['time_dismissed'] ) ) { $promptDismissal = $prompt['time_dismissed']; } elseif ( ! empty( $prompt['time_snoozed'] ) ) { $promptDismissal = $prompt['time_snoozed']; } $lastDismissal = $promptDismissal > $lastDismissal ? $promptDismissal : $lastDismissal; } return $lastDismissal; }
php
public function getLastDismissal() { $lastDismissal = 0; $prompts = $this->getPrompts(); foreach ( $prompts as $prompt ) { $promptDismissal = 0; if ( ! empty( $prompt['time_dismissed'] ) ) { $promptDismissal = $prompt['time_dismissed']; } elseif ( ! empty( $prompt['time_snoozed'] ) ) { $promptDismissal = $prompt['time_snoozed']; } $lastDismissal = $promptDismissal > $lastDismissal ? $promptDismissal : $lastDismissal; } return $lastDismissal; }
[ "public", "function", "getLastDismissal", "(", ")", "{", "$", "lastDismissal", "=", "0", ";", "$", "prompts", "=", "$", "this", "->", "getPrompts", "(", ")", ";", "foreach", "(", "$", "prompts", "as", "$", "prompt", ")", "{", "$", "promptDismissal", "=...
Get the time of the last dismissal or snooze, whichever is latest. One reason this is used is to ensure prompts don't show one after another for the user. For example, if the user just dismissed a rating prompt, we may not want to show them another prompt for at least 2 days. @since 2.7.7 @return int
[ "Get", "the", "time", "of", "the", "last", "dismissal", "or", "snooze", "whichever", "is", "latest", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L214-L231
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.admin_enqueue_scripts
public function admin_enqueue_scripts() { if ( ! current_user_can( $this->userRole ) ) { return; } $prompt = $this->getNext(); if ( ! empty( $prompt ) ) { wp_enqueue_script( 'bglib-rating-prompt-js', Library\Configs::get( 'libraryUrl' ) . 'src/assets/js/rating-prompt.js', 'jquery', date( 'Ymd' ) ); wp_enqueue_style( 'bglib-rating-prompt-css', Library\Configs::get( 'libraryUrl' ) . 'src/assets/css/rating-prompt.css', array(), date( 'Ymd' ) ); } }
php
public function admin_enqueue_scripts() { if ( ! current_user_can( $this->userRole ) ) { return; } $prompt = $this->getNext(); if ( ! empty( $prompt ) ) { wp_enqueue_script( 'bglib-rating-prompt-js', Library\Configs::get( 'libraryUrl' ) . 'src/assets/js/rating-prompt.js', 'jquery', date( 'Ymd' ) ); wp_enqueue_style( 'bglib-rating-prompt-css', Library\Configs::get( 'libraryUrl' ) . 'src/assets/css/rating-prompt.css', array(), date( 'Ymd' ) ); } }
[ "public", "function", "admin_enqueue_scripts", "(", ")", "{", "if", "(", "!", "current_user_can", "(", "$", "this", "->", "userRole", ")", ")", "{", "return", ";", "}", "$", "prompt", "=", "$", "this", "->", "getNext", "(", ")", ";", "if", "(", "!", ...
Admin enqueue scripts. @since 2.7.7
[ "Admin", "enqueue", "scripts", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L249-L271
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.getPromptSlides
public function getPromptSlides( $prompt ) { $slides = array(); if ( ! empty( $prompt['slides'] ) ) { foreach ( $prompt['slides'] as $slide_id => $slide ) { $slideMarkup = $this->getSlideMarkup( $slide_id, $slide ); $slides[$slide_id] = $slideMarkup; } } return $slides; }
php
public function getPromptSlides( $prompt ) { $slides = array(); if ( ! empty( $prompt['slides'] ) ) { foreach ( $prompt['slides'] as $slide_id => $slide ) { $slideMarkup = $this->getSlideMarkup( $slide_id, $slide ); $slides[$slide_id] = $slideMarkup; } } return $slides; }
[ "public", "function", "getPromptSlides", "(", "$", "prompt", ")", "{", "$", "slides", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "prompt", "[", "'slides'", "]", ")", ")", "{", "foreach", "(", "$", "prompt", "[", "'slides'", "]"...
Return the markup of a prompt's slides. @since 2.7.7 @param array $prompt A prompt. @return string
[ "Return", "the", "markup", "of", "a", "prompt", "s", "slides", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L281-L293
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.getSlideMarkup
public function getSlideMarkup( $slide_id, $slide ) { $slideMarkup = '<div data-slide-id="' . esc_attr( $slide_id ) . '">'; $slideMarkup .= '<p>' . $slide['text'] . '</p>'; if ( ! empty( $slide['decisions'] ) ) { $slide_decisions = array(); foreach( $slide['decisions'] as $decision ) { $attributes = $this->getDecisionAttributes( $decision ); $markup = '<a '; foreach ( $attributes as $key => $value ) { $markup .= $key . '="' . $value . '" '; } $markup .= '>' . esc_html( $decision['text'] ) . '</a>'; $slide_decisions[] = $markup; } $slideMarkup .= '<ul><li>' . implode( '</li><li>', $slide_decisions ) . '</li></ul>'; } $slideMarkup .= '</div>'; return $slideMarkup; }
php
public function getSlideMarkup( $slide_id, $slide ) { $slideMarkup = '<div data-slide-id="' . esc_attr( $slide_id ) . '">'; $slideMarkup .= '<p>' . $slide['text'] . '</p>'; if ( ! empty( $slide['decisions'] ) ) { $slide_decisions = array(); foreach( $slide['decisions'] as $decision ) { $attributes = $this->getDecisionAttributes( $decision ); $markup = '<a '; foreach ( $attributes as $key => $value ) { $markup .= $key . '="' . $value . '" '; } $markup .= '>' . esc_html( $decision['text'] ) . '</a>'; $slide_decisions[] = $markup; } $slideMarkup .= '<ul><li>' . implode( '</li><li>', $slide_decisions ) . '</li></ul>'; } $slideMarkup .= '</div>'; return $slideMarkup; }
[ "public", "function", "getSlideMarkup", "(", "$", "slide_id", ",", "$", "slide", ")", "{", "$", "slideMarkup", "=", "'<div data-slide-id=\"'", ".", "esc_attr", "(", "$", "slide_id", ")", ".", "'\">'", ";", "$", "slideMarkup", ".=", "'<p>'", ".", "$", "slid...
Get the markup for an individual slide. @since 2.7.7 @param string $slide_id The id of a slide. @param array $slide A array of slide configs. @return string
[ "Get", "the", "markup", "for", "an", "individual", "slide", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L304-L329
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.getPrompt
public function getPrompt( $name ) { $prompt_found = array(); $prompts = $this->getPrompts(); foreach( $prompts as $prompt ) { if ( $name === $prompt['name'] ) { $prompt_found = $prompt; break; } } return $prompt_found; }
php
public function getPrompt( $name ) { $prompt_found = array(); $prompts = $this->getPrompts(); foreach( $prompts as $prompt ) { if ( $name === $prompt['name'] ) { $prompt_found = $prompt; break; } } return $prompt_found; }
[ "public", "function", "getPrompt", "(", "$", "name", ")", "{", "$", "prompt_found", "=", "array", "(", ")", ";", "$", "prompts", "=", "$", "this", "->", "getPrompts", "(", ")", ";", "foreach", "(", "$", "prompts", "as", "$", "prompt", ")", "{", "if...
Get a prompt by name. @since 2.7.7 @param string $name The name of a prompt. @return array
[ "Get", "a", "prompt", "by", "name", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L352-L365
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.isPluginDismissed
public function isPluginDismissed( $plugin ) { $dismissed = false; $plugin_prompts = $this->getPluginPrompts( $plugin ); foreach ( $plugin_prompts as $prompt ) { if ( ! empty( $prompt['time_dismissed'] ) ) { $dismissed = true; } } return $dismissed; }
php
public function isPluginDismissed( $plugin ) { $dismissed = false; $plugin_prompts = $this->getPluginPrompts( $plugin ); foreach ( $plugin_prompts as $prompt ) { if ( ! empty( $prompt['time_dismissed'] ) ) { $dismissed = true; } } return $dismissed; }
[ "public", "function", "isPluginDismissed", "(", "$", "plugin", ")", "{", "$", "dismissed", "=", "false", ";", "$", "plugin_prompts", "=", "$", "this", "->", "getPluginPrompts", "(", "$", "plugin", ")", ";", "foreach", "(", "$", "plugin_prompts", "as", "$",...
Determine whether or not a given plugin has any dismissed notices. @since 2.7.7 @param string $plugin A plugin name. @return bool
[ "Determine", "whether", "or", "not", "a", "given", "plugin", "has", "any", "dismissed", "notices", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L386-L398
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.getPluginPrompts
public function getPluginPrompts( $plugin ) { $pluginPrompts = array(); $prompts = $this->getPrompts(); foreach ( $prompts as $prompt ) { if ( $prompt['plugin'] === $plugin ) { $pluginPrompts[] = $prompt; } } return $pluginPrompts; }
php
public function getPluginPrompts( $plugin ) { $pluginPrompts = array(); $prompts = $this->getPrompts(); foreach ( $prompts as $prompt ) { if ( $prompt['plugin'] === $plugin ) { $pluginPrompts[] = $prompt; } } return $pluginPrompts; }
[ "public", "function", "getPluginPrompts", "(", "$", "plugin", ")", "{", "$", "pluginPrompts", "=", "array", "(", ")", ";", "$", "prompts", "=", "$", "this", "->", "getPrompts", "(", ")", ";", "foreach", "(", "$", "prompts", "as", "$", "prompt", ")", ...
Get all prompts for a plugin. @since 2.7.7 @param string $plugin The name of a plugin. @return array
[ "Get", "all", "prompts", "for", "a", "plugin", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L422-L434
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.getNext
public function getNext() { $nextPrompt = array(); $prompts = $this->getPrompts(); foreach ( $prompts as $prompt ) { $isDismissed = isset( $prompt['time_dismissed'] ); $isOlder = empty( $nextPrompt ) || ( ! $isDismissed && $prompt['time_added'] < $nextPrompt['time_added'] ); $isStillSnoozing = ! empty( $prompt['time_snoozed_until'] ) && $prompt['time_snoozed_until'] > time(); if ( ! $isDismissed && $isOlder && ! $isStillSnoozing ) { $nextPrompt = $prompt; } } if ( ! $this->isMinInterval() ) { $nextPrompt = array(); } return $nextPrompt; }
php
public function getNext() { $nextPrompt = array(); $prompts = $this->getPrompts(); foreach ( $prompts as $prompt ) { $isDismissed = isset( $prompt['time_dismissed'] ); $isOlder = empty( $nextPrompt ) || ( ! $isDismissed && $prompt['time_added'] < $nextPrompt['time_added'] ); $isStillSnoozing = ! empty( $prompt['time_snoozed_until'] ) && $prompt['time_snoozed_until'] > time(); if ( ! $isDismissed && $isOlder && ! $isStillSnoozing ) { $nextPrompt = $prompt; } } if ( ! $this->isMinInterval() ) { $nextPrompt = array(); } return $nextPrompt; }
[ "public", "function", "getNext", "(", ")", "{", "$", "nextPrompt", "=", "array", "(", ")", ";", "$", "prompts", "=", "$", "this", "->", "getPrompts", "(", ")", ";", "foreach", "(", "$", "prompts", "as", "$", "prompt", ")", "{", "$", "isDismissed", ...
Get the next prompt to display. We only display one prompt at a time. Get that prompt. @since 2.7.7
[ "Get", "the", "next", "prompt", "to", "display", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L443-L462
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.updatePrompt
public function updatePrompt( $prompt_to_save ) { $found = false; $prompts = $this->getPrompts(); foreach ( $prompts as $key => $prompt ) { if ( $prompt_to_save['name'] === $prompt['name'] ) { $found = true; $prompts[$key] = $prompt_to_save; break; } } return $found ? $this->savePrompts( $prompts ) : false; }
php
public function updatePrompt( $prompt_to_save ) { $found = false; $prompts = $this->getPrompts(); foreach ( $prompts as $key => $prompt ) { if ( $prompt_to_save['name'] === $prompt['name'] ) { $found = true; $prompts[$key] = $prompt_to_save; break; } } return $found ? $this->savePrompts( $prompts ) : false; }
[ "public", "function", "updatePrompt", "(", "$", "prompt_to_save", ")", "{", "$", "found", "=", "false", ";", "$", "prompts", "=", "$", "this", "->", "getPrompts", "(", ")", ";", "foreach", "(", "$", "prompts", "as", "$", "key", "=>", "$", "prompt", "...
Update an existing prompt. If the prompt is not found, this method will not make any changes. @since 2.7.7 @param array $prompt_to_save A prompt. @return bool Whether or not the prompt was found and updated.
[ "Update", "an", "existing", "prompt", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L474-L490
train
BoldGrid/library
src/Library/RatingPrompt.php
RatingPrompt.updatePromptKey
public function updatePromptKey( $name, $key, $value ) { $prompt = $this->getPrompt( $name ); $prompt[$key] = $value; return $this->updatePrompt( $prompt ); }
php
public function updatePromptKey( $name, $key, $value ) { $prompt = $this->getPrompt( $name ); $prompt[$key] = $value; return $this->updatePrompt( $prompt ); }
[ "public", "function", "updatePromptKey", "(", "$", "name", ",", "$", "key", ",", "$", "value", ")", "{", "$", "prompt", "=", "$", "this", "->", "getPrompt", "(", "$", "name", ")", ";", "$", "prompt", "[", "$", "key", "]", "=", "$", "value", ";", ...
Update an attribute for a prompt. Commonly used to set the time a prompt was dismissed. @since 2.7.7 @param string $name The name of a prompt. @param string $key The key to update. @param mixed $value The new value for the key. @return bool Whether or not the prompt was saved successfully.
[ "Update", "an", "attribute", "for", "a", "prompt", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/RatingPrompt.php#L518-L524
train
grom358/pharborist
src/Namespaces/NamespaceNode.php
NamespaceNode.create
public static function create($name) { $name = (string) $name; $name = ltrim($name, '\\'); $namespace_node = Parser::parseSnippet("namespace $name;"); return $namespace_node; }
php
public static function create($name) { $name = (string) $name; $name = ltrim($name, '\\'); $namespace_node = Parser::parseSnippet("namespace $name;"); return $namespace_node; }
[ "public", "static", "function", "create", "(", "$", "name", ")", "{", "$", "name", "=", "(", "string", ")", "$", "name", ";", "$", "name", "=", "ltrim", "(", "$", "name", ",", "'\\\\'", ")", ";", "$", "namespace_node", "=", "Parser", "::", "parseSn...
Create namespace declaration. @param NameNode|string $name Namespace path. @return NamespaceNode
[ "Create", "namespace", "declaration", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Namespaces/NamespaceNode.php#L49-L54
train
thelia/core
lib/Thelia/Module/BaseModule.php
BaseModule.isPaymentModuleFor
public function isPaymentModuleFor(Order $order) { $model = $this->getModuleModel(); return $order->getPaymentModuleId() == $model->getId(); }
php
public function isPaymentModuleFor(Order $order) { $model = $this->getModuleModel(); return $order->getPaymentModuleId() == $model->getId(); }
[ "public", "function", "isPaymentModuleFor", "(", "Order", "$", "order", ")", "{", "$", "model", "=", "$", "this", "->", "getModuleModel", "(", ")", ";", "return", "$", "order", "->", "getPaymentModuleId", "(", ")", "==", "$", "model", "->", "getId", "(",...
Check if this module is the payment module for a given order @param Order $order an order @return bool true if this module is the payment module for the given order.
[ "Check", "if", "this", "module", "is", "the", "payment", "module", "for", "a", "given", "order" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BaseModule.php#L398-L403
train
thelia/core
lib/Thelia/Module/BaseModule.php
BaseModule.isDeliveryModuleFor
public function isDeliveryModuleFor(Order $order) { $model = $this->getModuleModel(); return $order->getDeliveryModuleId() == $model->getId(); }
php
public function isDeliveryModuleFor(Order $order) { $model = $this->getModuleModel(); return $order->getDeliveryModuleId() == $model->getId(); }
[ "public", "function", "isDeliveryModuleFor", "(", "Order", "$", "order", ")", "{", "$", "model", "=", "$", "this", "->", "getModuleModel", "(", ")", ";", "return", "$", "order", "->", "getDeliveryModuleId", "(", ")", "==", "$", "model", "->", "getId", "(...
Check if this module is the delivery module for a given order @param Order $order an order @return bool true if this module is the delivery module for the given order.
[ "Check", "if", "this", "module", "is", "the", "delivery", "module", "for", "a", "given", "order" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BaseModule.php#L411-L416
train
thelia/core
lib/Thelia/Module/BaseModule.php
BaseModule.initializeCoreI18n
private function initializeCoreI18n() { if ($this->hasContainer()) { /** @var Translator $translator */ $translator = $this->container->get('thelia.translator'); if (null !== $translator) { $i18nPath = sprintf('%s%s/I18n/', THELIA_MODULE_DIR, $this->getCode()); $languages = LangQuery::create()->find(); foreach ($languages as $language) { $locale = $language->getLocale(); $i18nFile = sprintf('%s%s.php', $i18nPath, $locale); if (is_file($i18nFile) && is_readable($i18nFile)) { $translator->addResource('php', $i18nFile, $locale, strtolower(self::getModuleCode())); } } } } }
php
private function initializeCoreI18n() { if ($this->hasContainer()) { /** @var Translator $translator */ $translator = $this->container->get('thelia.translator'); if (null !== $translator) { $i18nPath = sprintf('%s%s/I18n/', THELIA_MODULE_DIR, $this->getCode()); $languages = LangQuery::create()->find(); foreach ($languages as $language) { $locale = $language->getLocale(); $i18nFile = sprintf('%s%s.php', $i18nPath, $locale); if (is_file($i18nFile) && is_readable($i18nFile)) { $translator->addResource('php', $i18nFile, $locale, strtolower(self::getModuleCode())); } } } } }
[ "private", "function", "initializeCoreI18n", "(", ")", "{", "if", "(", "$", "this", "->", "hasContainer", "(", ")", ")", "{", "/** @var Translator $translator */", "$", "translator", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.translator'", ...
Add core translations of the module to use in `preActivation` and `postActivation` when the module is not yest activated and translations are not available
[ "Add", "core", "translations", "of", "the", "module", "to", "use", "in", "preActivation", "and", "postActivation", "when", "the", "module", "is", "not", "yest", "activated", "and", "translations", "are", "not", "available" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Module/BaseModule.php#L779-L799
train
BoldGrid/library
src/Library/Api/Call.php
Call.setArgs
protected function setArgs( $args ) { // Check for an API key being stored. if ( $this->getKey() ) { $args = wp_parse_args( $args, array( 'key' => $this->getKey() ) ); } // Check for a site hash being stored. if ( $this->getSiteHash() ) { $args = wp_parse_args( $args, array( 'site_hash' => $this->getSiteHash() ) ); } return $this->args = array( 'timeout' => 15, // Default timeout is 5 seconds, change to 15. 'body' => $args ); }
php
protected function setArgs( $args ) { // Check for an API key being stored. if ( $this->getKey() ) { $args = wp_parse_args( $args, array( 'key' => $this->getKey() ) ); } // Check for a site hash being stored. if ( $this->getSiteHash() ) { $args = wp_parse_args( $args, array( 'site_hash' => $this->getSiteHash() ) ); } return $this->args = array( 'timeout' => 15, // Default timeout is 5 seconds, change to 15. 'body' => $args ); }
[ "protected", "function", "setArgs", "(", "$", "args", ")", "{", "// Check for an API key being stored.", "if", "(", "$", "this", "->", "getKey", "(", ")", ")", "{", "$", "args", "=", "wp_parse_args", "(", "$", "args", ",", "array", "(", "'key'", "=>", "$...
Sets the args class property. These are the arguments being passed for the API call parameters. @since 1.0.0 @param array $args API call arguments. @return array $args The args class property.
[ "Sets", "the", "args", "class", "property", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Api/Call.php#L122-L137
train
BoldGrid/library
src/Library/Api/Call.php
Call.call
private function call() { // Make the request. if ( 'get' === $this->method ) { $response = wp_remote_get( $this->url, $this->args ); } else { $response = wp_remote_post( $this->url, $this->args ); } // Decode the response and set class property. $this->response = json_decode( wp_remote_retrieve_body( $response ) ); // Validate the raw response. if ( $this->validateResponse( $response ) === false ) { return false; } // Response should be an object. if ( ! is_object( $this->response ) ) { $this->error = __( 'An invalid response was returned.', 'boldgrid-library' ); return false; } return true; }
php
private function call() { // Make the request. if ( 'get' === $this->method ) { $response = wp_remote_get( $this->url, $this->args ); } else { $response = wp_remote_post( $this->url, $this->args ); } // Decode the response and set class property. $this->response = json_decode( wp_remote_retrieve_body( $response ) ); // Validate the raw response. if ( $this->validateResponse( $response ) === false ) { return false; } // Response should be an object. if ( ! is_object( $this->response ) ) { $this->error = __( 'An invalid response was returned.', 'boldgrid-library' ); return false; } return true; }
[ "private", "function", "call", "(", ")", "{", "// Make the request.", "if", "(", "'get'", "===", "$", "this", "->", "method", ")", "{", "$", "response", "=", "wp_remote_get", "(", "$", "this", "->", "url", ",", "$", "this", "->", "args", ")", ";", "}...
Makes the API call. @since 1.0.0 @return bool Was the API call successful?
[ "Makes", "the", "API", "call", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Api/Call.php#L158-L181
train
BoldGrid/library
src/Library/Api/Call.php
Call.validateResponse
private function validateResponse( $response ) { // Make sure WordPress errors are handled. if ( is_wp_error( $response ) ) { $this->error = $response->get_error_message(); return false; } // Check for 200 response code from server. $responseCode = wp_remote_retrieve_response_code( $response ); if ( false === strstr( $responseCode, '200' ) ) { $responseMessage = wp_remote_retrieve_response_message( $response ); $this->error = "{$responseCode} {$responseMessage}"; return false; } // Check for nested status code not being successful. if ( isset( $this->response->status ) && 200 !== $this->response->status ) { $this->error = $this->response->result->data; return false; } return true; }
php
private function validateResponse( $response ) { // Make sure WordPress errors are handled. if ( is_wp_error( $response ) ) { $this->error = $response->get_error_message(); return false; } // Check for 200 response code from server. $responseCode = wp_remote_retrieve_response_code( $response ); if ( false === strstr( $responseCode, '200' ) ) { $responseMessage = wp_remote_retrieve_response_message( $response ); $this->error = "{$responseCode} {$responseMessage}"; return false; } // Check for nested status code not being successful. if ( isset( $this->response->status ) && 200 !== $this->response->status ) { $this->error = $this->response->result->data; return false; } return true; }
[ "private", "function", "validateResponse", "(", "$", "response", ")", "{", "// Make sure WordPress errors are handled.", "if", "(", "is_wp_error", "(", "$", "response", ")", ")", "{", "$", "this", "->", "error", "=", "$", "response", "->", "get_error_message", "...
Validates the API response. @since 1.0.0 @param object $response API response object. @return bool
[ "Validates", "the", "API", "response", "." ]
51afe070e211cff9cf78454ff97912a0d943805c
https://github.com/BoldGrid/library/blob/51afe070e211cff9cf78454ff97912a0d943805c/src/Library/Api/Call.php#L192-L215
train
grom358/pharborist
src/Parser.php
Parser.buildTree
public function buildTree(TokenIterator $iterator) { $this->skipped = []; $this->skipParent = NULL; $this->docComment = NULL; $this->skippedDocComment = []; $this->iterator = $iterator; $this->current = $this->iterator->current(); $this->currentType = $this->current ? $this->current->getType() : NULL; $top = new RootNode(); $this->top = $top; if ($this->currentType && $this->currentType !== T_OPEN_TAG) { $node = new TemplateNode(); // Parse any template statements that proceed the opening PHP tag. $this->templateStatementList($node); $top->addChild($node); } if ($this->tryMatch(T_OPEN_TAG, $top, NULL, TRUE, TRUE)) { $this->topStatementList($top); } return $top; }
php
public function buildTree(TokenIterator $iterator) { $this->skipped = []; $this->skipParent = NULL; $this->docComment = NULL; $this->skippedDocComment = []; $this->iterator = $iterator; $this->current = $this->iterator->current(); $this->currentType = $this->current ? $this->current->getType() : NULL; $top = new RootNode(); $this->top = $top; if ($this->currentType && $this->currentType !== T_OPEN_TAG) { $node = new TemplateNode(); // Parse any template statements that proceed the opening PHP tag. $this->templateStatementList($node); $top->addChild($node); } if ($this->tryMatch(T_OPEN_TAG, $top, NULL, TRUE, TRUE)) { $this->topStatementList($top); } return $top; }
[ "public", "function", "buildTree", "(", "TokenIterator", "$", "iterator", ")", "{", "$", "this", "->", "skipped", "=", "[", "]", ";", "$", "this", "->", "skipParent", "=", "NULL", ";", "$", "this", "->", "docComment", "=", "NULL", ";", "$", "this", "...
Build a syntax tree from the token iterator. @param TokenIterator $iterator @return RootNode Root node of the tree
[ "Build", "a", "syntax", "tree", "from", "the", "token", "iterator", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L185-L205
train
grom358/pharborist
src/Parser.php
Parser.parseFile
public static function parseFile($filename) { $source = @file_get_contents($filename); if ($source === FALSE) { return FALSE; } return self::parseSource($source, $filename); }
php
public static function parseFile($filename) { $source = @file_get_contents($filename); if ($source === FALSE) { return FALSE; } return self::parseSource($source, $filename); }
[ "public", "static", "function", "parseFile", "(", "$", "filename", ")", "{", "$", "source", "=", "@", "file_get_contents", "(", "$", "filename", ")", ";", "if", "(", "$", "source", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "return", "self"...
Parse a file and return the parsed tree @param string $filename Path to file @return RootNode|bool The top-level node of the parsed tree or FALSE if the file contents could not be read.
[ "Parse", "a", "file", "and", "return", "the", "parsed", "tree" ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L214-L220
train
grom358/pharborist
src/Parser.php
Parser.parseSource
public static function parseSource($source, $filename = NULL) { static $tokenizer, $parser = NULL; if (!isset($parser)) { $tokenizer = new Tokenizer(); $parser = new self(); } $tokens = $tokenizer->getAll($source, $filename); $parser->filename = $filename; return $parser->buildTree(new TokenIterator($tokens)); }
php
public static function parseSource($source, $filename = NULL) { static $tokenizer, $parser = NULL; if (!isset($parser)) { $tokenizer = new Tokenizer(); $parser = new self(); } $tokens = $tokenizer->getAll($source, $filename); $parser->filename = $filename; return $parser->buildTree(new TokenIterator($tokens)); }
[ "public", "static", "function", "parseSource", "(", "$", "source", ",", "$", "filename", "=", "NULL", ")", "{", "static", "$", "tokenizer", ",", "$", "parser", "=", "NULL", ";", "if", "(", "!", "isset", "(", "$", "parser", ")", ")", "{", "$", "toke...
Parse PHP source code and return the parsed tree. @param string $source PHP source code @param string $filename (Optional) Filename of source. @return RootNode The top-level node of the parsed tree
[ "Parse", "PHP", "source", "code", "and", "return", "the", "parsed", "tree", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L232-L241
train
grom358/pharborist
src/Parser.php
Parser.parseExpression
public static function parseExpression($expression) { $tree = self::parseSource('<?php ' . $expression . ';'); /** @var ExpressionStatementNode $statement_node */ $statement_node = $tree->firstChild()->next(); return $statement_node->getExpression()->remove(); }
php
public static function parseExpression($expression) { $tree = self::parseSource('<?php ' . $expression . ';'); /** @var ExpressionStatementNode $statement_node */ $statement_node = $tree->firstChild()->next(); return $statement_node->getExpression()->remove(); }
[ "public", "static", "function", "parseExpression", "(", "$", "expression", ")", "{", "$", "tree", "=", "self", "::", "parseSource", "(", "'<?php '", ".", "$", "expression", ".", "';'", ")", ";", "/** @var ExpressionStatementNode $statement_node */", "$", "statemen...
Parse a PHP expression. @param string $expression PHP expression snippet. @return ExpressionNode The expression.
[ "Parse", "a", "PHP", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L263-L268
train
grom358/pharborist
src/Parser.php
Parser.templateStatementList
private function templateStatementList(ParentNode $node) { while ($this->current) { if ($this->currentType === T_OPEN_TAG) { return; } elseif ($this->currentType === T_INLINE_HTML) { $node->addChild($this->mustMatchToken(T_INLINE_HTML)); } elseif ($this->currentType === T_OPEN_TAG_WITH_ECHO) { $node->addChild($this->echoTagStatement()); } else { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected PHP opening tag, but got ' . $this->iterator->current()->getText()); } } }
php
private function templateStatementList(ParentNode $node) { while ($this->current) { if ($this->currentType === T_OPEN_TAG) { return; } elseif ($this->currentType === T_INLINE_HTML) { $node->addChild($this->mustMatchToken(T_INLINE_HTML)); } elseif ($this->currentType === T_OPEN_TAG_WITH_ECHO) { $node->addChild($this->echoTagStatement()); } else { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected PHP opening tag, but got ' . $this->iterator->current()->getText()); } } }
[ "private", "function", "templateStatementList", "(", "ParentNode", "$", "node", ")", "{", "while", "(", "$", "this", "->", "current", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "T_OPEN_TAG", ")", "{", "return", ";", "}", "elseif", "(",...
Parse zero or more template statements. @param ParentNode $node Node to append matches to. @throws ParserException
[ "Parse", "zero", "or", "more", "template", "statements", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L275-L294
train
grom358/pharborist
src/Parser.php
Parser.topStatementList
private function topStatementList(StatementBlockNode $node, $terminator = '') { $this->matchHidden($node); while ($this->currentType !== NULL && $this->currentType !== $terminator) { $node->addChild($this->topStatement()); $this->matchHidden($node); } $this->matchHidden($node); $this->matchDocComment($node, NULL); }
php
private function topStatementList(StatementBlockNode $node, $terminator = '') { $this->matchHidden($node); while ($this->currentType !== NULL && $this->currentType !== $terminator) { $node->addChild($this->topStatement()); $this->matchHidden($node); } $this->matchHidden($node); $this->matchDocComment($node, NULL); }
[ "private", "function", "topStatementList", "(", "StatementBlockNode", "$", "node", ",", "$", "terminator", "=", "''", ")", "{", "$", "this", "->", "matchHidden", "(", "$", "node", ")", ";", "while", "(", "$", "this", "->", "currentType", "!==", "NULL", "...
Parse a list of top level statements. @param StatementBlockNode $node Node to append matches to @param string $terminator Character that ends the statement list
[ "Parse", "a", "list", "of", "top", "level", "statements", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L318-L326
train
grom358/pharborist
src/Parser.php
Parser.topStatement
private function topStatement() { switch ($this->currentType) { case T_USE: return $this->useBlock(); case T_CONST: return $this->_const(); case T_ABSTRACT: case T_FINAL: case T_CLASS: return $this->classDeclaration(); case T_INTERFACE: return $this->interfaceDeclaration(); case T_TRAIT: return $this->traitDeclaration(); case T_HALT_COMPILER: $node = new HaltCompilerNode(); $this->mustMatch(T_HALT_COMPILER, $node, 'name'); $this->mustMatch('(', $node, 'openParen'); $this->mustMatch(')', $node, 'closeParen'); $this->endStatement($node); $this->tryMatch(T_INLINE_HTML, $node); return $node; default: if ($this->currentType === T_FUNCTION && $this->isLookAhead(T_STRING, '&')) { return $this->functionDeclaration(); } elseif ($this->currentType === T_NAMESPACE && !$this->isLookAhead(T_NS_SEPARATOR)) { return $this->_namespace(); } return $this->statement(); } }
php
private function topStatement() { switch ($this->currentType) { case T_USE: return $this->useBlock(); case T_CONST: return $this->_const(); case T_ABSTRACT: case T_FINAL: case T_CLASS: return $this->classDeclaration(); case T_INTERFACE: return $this->interfaceDeclaration(); case T_TRAIT: return $this->traitDeclaration(); case T_HALT_COMPILER: $node = new HaltCompilerNode(); $this->mustMatch(T_HALT_COMPILER, $node, 'name'); $this->mustMatch('(', $node, 'openParen'); $this->mustMatch(')', $node, 'closeParen'); $this->endStatement($node); $this->tryMatch(T_INLINE_HTML, $node); return $node; default: if ($this->currentType === T_FUNCTION && $this->isLookAhead(T_STRING, '&')) { return $this->functionDeclaration(); } elseif ($this->currentType === T_NAMESPACE && !$this->isLookAhead(T_NS_SEPARATOR)) { return $this->_namespace(); } return $this->statement(); } }
[ "private", "function", "topStatement", "(", ")", "{", "switch", "(", "$", "this", "->", "currentType", ")", "{", "case", "T_USE", ":", "return", "$", "this", "->", "useBlock", "(", ")", ";", "case", "T_CONST", ":", "return", "$", "this", "->", "_const"...
Parse a top level statement. @return Node
[ "Parse", "a", "top", "level", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L332-L363
train
grom358/pharborist
src/Parser.php
Parser._const
private function _const() { $node = new ConstantDeclarationStatementNode(); $this->matchDocComment($node); $this->mustMatch(T_CONST, $node); $declarations = new CommaListNode(); do { $declarations->addChild($this->constDeclaration()); } while ($this->tryMatch(',', $declarations)); $node->addChild($declarations, 'declarations'); $this->endStatement($node); return $node; }
php
private function _const() { $node = new ConstantDeclarationStatementNode(); $this->matchDocComment($node); $this->mustMatch(T_CONST, $node); $declarations = new CommaListNode(); do { $declarations->addChild($this->constDeclaration()); } while ($this->tryMatch(',', $declarations)); $node->addChild($declarations, 'declarations'); $this->endStatement($node); return $node; }
[ "private", "function", "_const", "(", ")", "{", "$", "node", "=", "new", "ConstantDeclarationStatementNode", "(", ")", ";", "$", "this", "->", "matchDocComment", "(", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "T_CONST", ",", "$", "node"...
Parse a constant declaration list. @return ConstantDeclarationStatementNode
[ "Parse", "a", "constant", "declaration", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L380-L391
train
grom358/pharborist
src/Parser.php
Parser.constDeclaration
private function constDeclaration() { $node = new ConstantDeclarationNode(); $name_node = new NameNode(); $this->mustMatch(T_STRING, $name_node, NULL, TRUE); $node->addChild($name_node, 'name'); if ($this->mustMatch('=', $node)) { $node->addChild($this->staticScalar(), 'value'); } return $node; }
php
private function constDeclaration() { $node = new ConstantDeclarationNode(); $name_node = new NameNode(); $this->mustMatch(T_STRING, $name_node, NULL, TRUE); $node->addChild($name_node, 'name'); if ($this->mustMatch('=', $node)) { $node->addChild($this->staticScalar(), 'value'); } return $node; }
[ "private", "function", "constDeclaration", "(", ")", "{", "$", "node", "=", "new", "ConstantDeclarationNode", "(", ")", ";", "$", "name_node", "=", "new", "NameNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_STRING", ",", "$", "name_node", ...
Parse a constant declaration. @return ConstantDeclarationNode
[ "Parse", "a", "constant", "declaration", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L397-L406
train
grom358/pharborist
src/Parser.php
Parser.statement
private function statement() { switch ($this->currentType) { case T_CLOSE_TAG: // A close tag escapes into template mode. $node = new TemplateNode(); $this->mustMatch(T_CLOSE_TAG, $node); $this->templateStatementList($node); if ($this->iterator->hasNext()) { $this->mustMatch(T_OPEN_TAG, $node, NULL, TRUE, TRUE); } return $node; case T_IF: return $this->_if(); case T_WHILE: return $this->_while(); case T_DO: return $this->doWhile(); case T_FOR: return $this->_for(); case T_SWITCH: return $this->_switch(); case T_BREAK: return $this->_break(); case T_CONTINUE: return $this->_continue(); case T_RETURN: return $this->_return(); case T_YIELD: $node = new YieldStatementNode(); $node->addChild($this->_yield()); $this->endStatement($node); return $node; case T_GLOBAL: return $this->_global(); case T_ECHO: return $this->_echo(); case T_UNSET: return $this->_unset(); case T_FOREACH: return $this->_foreach(); case T_DECLARE: return $this->_declare(); case T_TRY: return $this->_try(); case T_THROW: return $this->_throw(); case T_GOTO: return $this->_goto(); case '{': return $this->innerStatementBlock(); case ';': $node = new BlankStatementNode(); $this->endStatement($node); return $node; case T_STATIC: if ($this->isLookAhead(T_VARIABLE)) { return $this->staticVariableList(); } else { return $this->exprStatement(); } case T_STRING: if ($this->isLookAhead(':')) { $node = new GotoLabelNode(); $this->mustMatch(T_STRING, $node, 'label'); $this->mustMatch(':', $node, NULL, TRUE, TRUE); return $node; } else { return $this->exprStatement(); } default: return $this->exprStatement(); } }
php
private function statement() { switch ($this->currentType) { case T_CLOSE_TAG: // A close tag escapes into template mode. $node = new TemplateNode(); $this->mustMatch(T_CLOSE_TAG, $node); $this->templateStatementList($node); if ($this->iterator->hasNext()) { $this->mustMatch(T_OPEN_TAG, $node, NULL, TRUE, TRUE); } return $node; case T_IF: return $this->_if(); case T_WHILE: return $this->_while(); case T_DO: return $this->doWhile(); case T_FOR: return $this->_for(); case T_SWITCH: return $this->_switch(); case T_BREAK: return $this->_break(); case T_CONTINUE: return $this->_continue(); case T_RETURN: return $this->_return(); case T_YIELD: $node = new YieldStatementNode(); $node->addChild($this->_yield()); $this->endStatement($node); return $node; case T_GLOBAL: return $this->_global(); case T_ECHO: return $this->_echo(); case T_UNSET: return $this->_unset(); case T_FOREACH: return $this->_foreach(); case T_DECLARE: return $this->_declare(); case T_TRY: return $this->_try(); case T_THROW: return $this->_throw(); case T_GOTO: return $this->_goto(); case '{': return $this->innerStatementBlock(); case ';': $node = new BlankStatementNode(); $this->endStatement($node); return $node; case T_STATIC: if ($this->isLookAhead(T_VARIABLE)) { return $this->staticVariableList(); } else { return $this->exprStatement(); } case T_STRING: if ($this->isLookAhead(':')) { $node = new GotoLabelNode(); $this->mustMatch(T_STRING, $node, 'label'); $this->mustMatch(':', $node, NULL, TRUE, TRUE); return $node; } else { return $this->exprStatement(); } default: return $this->exprStatement(); } }
[ "private", "function", "statement", "(", ")", "{", "switch", "(", "$", "this", "->", "currentType", ")", "{", "case", "T_CLOSE_TAG", ":", "// A close tag escapes into template mode.", "$", "node", "=", "new", "TemplateNode", "(", ")", ";", "$", "this", "->", ...
Parse a statement. @return Node
[ "Parse", "a", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L412-L486
train
grom358/pharborist
src/Parser.php
Parser.staticVariableList
private function staticVariableList() { $node = new StaticVariableStatementNode(); $this->matchDocComment($node); $this->mustMatch(T_STATIC, $node); $variables = new CommaListNode(); do { $variables->addChild($this->staticVariable()); } while ($this->tryMatch(',', $variables)); $node->addChild($variables, 'variables'); $this->endStatement($node); return $node; }
php
private function staticVariableList() { $node = new StaticVariableStatementNode(); $this->matchDocComment($node); $this->mustMatch(T_STATIC, $node); $variables = new CommaListNode(); do { $variables->addChild($this->staticVariable()); } while ($this->tryMatch(',', $variables)); $node->addChild($variables, 'variables'); $this->endStatement($node); return $node; }
[ "private", "function", "staticVariableList", "(", ")", "{", "$", "node", "=", "new", "StaticVariableStatementNode", "(", ")", ";", "$", "this", "->", "matchDocComment", "(", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "T_STATIC", ",", "$", ...
Parse a static variable list. @return StaticVariableStatementNode
[ "Parse", "a", "static", "variable", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L492-L503
train
grom358/pharborist
src/Parser.php
Parser.staticVariable
private function staticVariable() { $node = new StaticVariableNode(); $this->mustMatch(T_VARIABLE, $node, 'name', TRUE); if ($this->tryMatch('=', $node)) { $node->addChild($this->staticScalar(), 'initialValue'); } return $node; }
php
private function staticVariable() { $node = new StaticVariableNode(); $this->mustMatch(T_VARIABLE, $node, 'name', TRUE); if ($this->tryMatch('=', $node)) { $node->addChild($this->staticScalar(), 'initialValue'); } return $node; }
[ "private", "function", "staticVariable", "(", ")", "{", "$", "node", "=", "new", "StaticVariableNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_VARIABLE", ",", "$", "node", ",", "'name'", ",", "TRUE", ")", ";", "if", "(", "$", "this", "...
Parse a static variable. @return StaticVariableNode
[ "Parse", "a", "static", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L509-L516
train
grom358/pharborist
src/Parser.php
Parser.exprStatement
private function exprStatement() { $node = new ExpressionStatementNode(); $this->matchDocComment($node); $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
php
private function exprStatement() { $node = new ExpressionStatementNode(); $this->matchDocComment($node); $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
[ "private", "function", "exprStatement", "(", ")", "{", "$", "node", "=", "new", "ExpressionStatementNode", "(", ")", ";", "$", "this", "->", "matchDocComment", "(", "$", "node", ")", ";", "$", "node", "->", "addChild", "(", "$", "this", "->", "expr", "...
Parse expression statement. @return ExpressionStatementNode
[ "Parse", "expression", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L522-L528
train
grom358/pharborist
src/Parser.php
Parser.condition
private function condition(ParentNode $node, $property_name) { $this->mustMatch('(', $node, 'openParen'); if ($this->currentType === T_YIELD) { $node->addChild($this->_yield(), $property_name); } else { $node->addChild($this->expr(), $property_name); } $this->mustMatch(')', $node, 'closeParen'); }
php
private function condition(ParentNode $node, $property_name) { $this->mustMatch('(', $node, 'openParen'); if ($this->currentType === T_YIELD) { $node->addChild($this->_yield(), $property_name); } else { $node->addChild($this->expr(), $property_name); } $this->mustMatch(')', $node, 'closeParen'); }
[ "private", "function", "condition", "(", "ParentNode", "$", "node", ",", "$", "property_name", ")", "{", "$", "this", "->", "mustMatch", "(", "'('", ",", "$", "node", ",", "'openParen'", ")", ";", "if", "(", "$", "this", "->", "currentType", "===", "T_...
Parse condition. @param ParentNode $node @param string $property_name
[ "Parse", "condition", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L535-L544
train
grom358/pharborist
src/Parser.php
Parser._if
private function _if() { $node = new IfNode(); $this->mustMatch(T_IF, $node); $this->condition($node, 'condition'); if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) { $node->addChild($this->innerIfInnerStatementList(), 'then'); while ($this->currentType === T_ELSEIF) { $this->matchHidden($node); $elseIf = new ElseIfNode(); $this->mustMatch(T_ELSEIF, $elseIf); $this->condition($elseIf, 'condition'); $this->mustMatch(':', $elseIf, 'openColon', FALSE, TRUE); $elseIf->addChild($this->innerIfInnerStatementList(), 'then'); $node->addChild($elseIf); } if ($this->tryMatch(T_ELSE, $node, 'elseKeyword')) { $this->mustMatch(':', $node, 'elseColon', FALSE, TRUE); $node->addChild($this->innerStatementListNode(T_ENDIF), 'else'); } $this->mustMatch(T_ENDIF, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->matchHidden($node); $node->addChild($this->statement(), 'then'); while ($this->currentType === T_ELSEIF) { $this->matchHidden($node); $elseIf = new ElseIfNode(); $this->mustMatch(T_ELSEIF, $elseIf); $this->condition($elseIf, 'condition'); $this->matchHidden($elseIf); $elseIf->addChild($this->statement(), 'then'); $node->addChild($elseIf); } if ($this->tryMatch(T_ELSE, $node, 'elseKeyword', FALSE, TRUE)) { $node->addChild($this->statement(), 'else'); } return $node; } }
php
private function _if() { $node = new IfNode(); $this->mustMatch(T_IF, $node); $this->condition($node, 'condition'); if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) { $node->addChild($this->innerIfInnerStatementList(), 'then'); while ($this->currentType === T_ELSEIF) { $this->matchHidden($node); $elseIf = new ElseIfNode(); $this->mustMatch(T_ELSEIF, $elseIf); $this->condition($elseIf, 'condition'); $this->mustMatch(':', $elseIf, 'openColon', FALSE, TRUE); $elseIf->addChild($this->innerIfInnerStatementList(), 'then'); $node->addChild($elseIf); } if ($this->tryMatch(T_ELSE, $node, 'elseKeyword')) { $this->mustMatch(':', $node, 'elseColon', FALSE, TRUE); $node->addChild($this->innerStatementListNode(T_ENDIF), 'else'); } $this->mustMatch(T_ENDIF, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->matchHidden($node); $node->addChild($this->statement(), 'then'); while ($this->currentType === T_ELSEIF) { $this->matchHidden($node); $elseIf = new ElseIfNode(); $this->mustMatch(T_ELSEIF, $elseIf); $this->condition($elseIf, 'condition'); $this->matchHidden($elseIf); $elseIf->addChild($this->statement(), 'then'); $node->addChild($elseIf); } if ($this->tryMatch(T_ELSE, $node, 'elseKeyword', FALSE, TRUE)) { $node->addChild($this->statement(), 'else'); } return $node; } }
[ "private", "function", "_if", "(", ")", "{", "$", "node", "=", "new", "IfNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_IF", ",", "$", "node", ")", ";", "$", "this", "->", "condition", "(", "$", "node", ",", "'condition'", ")", ";"...
Parse if control structure. @return IfNode
[ "Parse", "if", "control", "structure", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L550-L590
train
grom358/pharborist
src/Parser.php
Parser.innerIfInnerStatementList
private function innerIfInnerStatementList() { static $terminators = [T_ELSEIF, T_ELSE, T_ENDIF]; $node = new StatementBlockNode(); while ($this->currentType !== NULL && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerStatement()); } return $node; }
php
private function innerIfInnerStatementList() { static $terminators = [T_ELSEIF, T_ELSE, T_ENDIF]; $node = new StatementBlockNode(); while ($this->currentType !== NULL && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerStatement()); } return $node; }
[ "private", "function", "innerIfInnerStatementList", "(", ")", "{", "static", "$", "terminators", "=", "[", "T_ELSEIF", ",", "T_ELSE", ",", "T_ENDIF", "]", ";", "$", "node", "=", "new", "StatementBlockNode", "(", ")", ";", "while", "(", "$", "this", "->", ...
Parse statements for alternative if syntax. @return Node
[ "Parse", "statements", "for", "alternative", "if", "syntax", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L596-L604
train
grom358/pharborist
src/Parser.php
Parser._while
private function _while() { $node = new WhileNode(); $this->mustMatch(T_WHILE, $node); $this->condition($node, 'condition'); if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDWHILE), 'body'); $this->mustMatch(T_ENDWHILE, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->matchHidden($node); $node->addChild($this->statement(), 'body'); return $node; } }
php
private function _while() { $node = new WhileNode(); $this->mustMatch(T_WHILE, $node); $this->condition($node, 'condition'); if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDWHILE), 'body'); $this->mustMatch(T_ENDWHILE, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->matchHidden($node); $node->addChild($this->statement(), 'body'); return $node; } }
[ "private", "function", "_while", "(", ")", "{", "$", "node", "=", "new", "WhileNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_WHILE", ",", "$", "node", ")", ";", "$", "this", "->", "condition", "(", "$", "node", ",", "'condition'", "...
Parse while control structure. @return WhileNode
[ "Parse", "while", "control", "structure", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L610-L625
train
grom358/pharborist
src/Parser.php
Parser.doWhile
private function doWhile() { $node = new DoWhileNode(); $this->mustMatch(T_DO, $node, NULL, FALSE, TRUE); $node->addChild($this->statement(), 'body'); $this->mustMatch(T_WHILE, $node, 'whileKeyword'); $this->condition($node, 'condition'); $this->endStatement($node); return $node; }
php
private function doWhile() { $node = new DoWhileNode(); $this->mustMatch(T_DO, $node, NULL, FALSE, TRUE); $node->addChild($this->statement(), 'body'); $this->mustMatch(T_WHILE, $node, 'whileKeyword'); $this->condition($node, 'condition'); $this->endStatement($node); return $node; }
[ "private", "function", "doWhile", "(", ")", "{", "$", "node", "=", "new", "DoWhileNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_DO", ",", "$", "node", ",", "NULL", ",", "FALSE", ",", "TRUE", ")", ";", "$", "node", "->", "addChild", ...
Parse do while control stucture. @return DoWhileNode
[ "Parse", "do", "while", "control", "stucture", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L631-L639
train
grom358/pharborist
src/Parser.php
Parser._for
private function _for() { $node = new ForNode(); $this->mustMatch(T_FOR, $node); $this->mustMatch('(', $node, 'openParen'); $this->forExpr($node, ';', 'initial'); $this->forExpr($node, ';', 'condition'); $this->forExpr($node, ')', 'step', TRUE, 'closeParen'); if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDFOR), 'body'); $this->mustMatch(T_ENDFOR, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->matchHidden($node); $node->addChild($this->statement(), 'body'); return $node; } }
php
private function _for() { $node = new ForNode(); $this->mustMatch(T_FOR, $node); $this->mustMatch('(', $node, 'openParen'); $this->forExpr($node, ';', 'initial'); $this->forExpr($node, ';', 'condition'); $this->forExpr($node, ')', 'step', TRUE, 'closeParen'); if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDFOR), 'body'); $this->mustMatch(T_ENDFOR, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->matchHidden($node); $node->addChild($this->statement(), 'body'); return $node; } }
[ "private", "function", "_for", "(", ")", "{", "$", "node", "=", "new", "ForNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_FOR", ",", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "'('", ",", "$", "node", ",", "'openPa...
Parse for control structure. @return ForNode
[ "Parse", "for", "control", "structure", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L645-L663
train
grom358/pharborist
src/Parser.php
Parser.forExpr
private function forExpr(ForNode $parent, $terminator, $property_name, $is_last = FALSE, $terminator_name = NULL) { if ($this->tryMatch($terminator, $parent)) { $parent->addChild(new CommaListNode(), $property_name); return; } $parent->addChild($this->exprList(), $property_name); $this->mustMatch($terminator, $parent, $terminator_name, $is_last, FALSE); }
php
private function forExpr(ForNode $parent, $terminator, $property_name, $is_last = FALSE, $terminator_name = NULL) { if ($this->tryMatch($terminator, $parent)) { $parent->addChild(new CommaListNode(), $property_name); return; } $parent->addChild($this->exprList(), $property_name); $this->mustMatch($terminator, $parent, $terminator_name, $is_last, FALSE); }
[ "private", "function", "forExpr", "(", "ForNode", "$", "parent", ",", "$", "terminator", ",", "$", "property_name", ",", "$", "is_last", "=", "FALSE", ",", "$", "terminator_name", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "tryMatch", "(", "$...
Parse a for expression. @param ForNode $parent Parent for node @param int|string $terminator Token type that terminates the for expression @param string $property_name @param bool $is_last TRUE if last for expression @param string $terminator_name
[ "Parse", "a", "for", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L673-L680
train
grom358/pharborist
src/Parser.php
Parser._switch
private function _switch() { $node = new SwitchNode(); $this->mustMatch(T_SWITCH, $node); $this->condition($node, 'switchOn'); if ($this->tryMatch(':', $node, 'openColon')) { $this->tryMatch(';', $node); while ($this->currentType !== NULL && $this->currentType !== T_ENDSWITCH) { $node->addChild($this->caseStatement(T_ENDSWITCH)); $this->matchHidden($node); } $this->mustMatch(T_ENDSWITCH, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->mustMatch('{', $node); $this->tryMatch(';', $node); while ($this->currentType !== NULL && $this->currentType !== '}') { $node->addChild($this->caseStatement('}')); $this->matchHidden($node); } $this->mustMatch('}', $node, NULL, TRUE); return $node; } }
php
private function _switch() { $node = new SwitchNode(); $this->mustMatch(T_SWITCH, $node); $this->condition($node, 'switchOn'); if ($this->tryMatch(':', $node, 'openColon')) { $this->tryMatch(';', $node); while ($this->currentType !== NULL && $this->currentType !== T_ENDSWITCH) { $node->addChild($this->caseStatement(T_ENDSWITCH)); $this->matchHidden($node); } $this->mustMatch(T_ENDSWITCH, $node, 'endKeyword'); $this->endStatement($node); return $node; } else { $this->mustMatch('{', $node); $this->tryMatch(';', $node); while ($this->currentType !== NULL && $this->currentType !== '}') { $node->addChild($this->caseStatement('}')); $this->matchHidden($node); } $this->mustMatch('}', $node, NULL, TRUE); return $node; } }
[ "private", "function", "_switch", "(", ")", "{", "$", "node", "=", "new", "SwitchNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_SWITCH", ",", "$", "node", ")", ";", "$", "this", "->", "condition", "(", "$", "node", ",", "'switchOn'", ...
Parse a switch control structure. @return SwitchNode
[ "Parse", "a", "switch", "control", "structure", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L686-L710
train
grom358/pharborist
src/Parser.php
Parser.caseStatement
private function caseStatement($terminator) { static $terminators = [T_CASE, T_DEFAULT]; if ($this->currentType === T_CASE) { $node = new CaseNode(); $this->mustMatch(T_CASE, $node); $node->addChild($this->expr(), 'matchOn'); if (!$this->tryMatch(':', $node, NULL, TRUE, TRUE) && !$this->tryMatch(';', $node, NULL, TRUE, TRUE)) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected :'); } if ($this->currentType !== $terminator && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerCaseStatementList($terminator), 'body'); } return $node; } elseif ($this->currentType === T_DEFAULT) { $node = new DefaultNode(); $this->mustMatch(T_DEFAULT, $node); if (!$this->tryMatch(':', $node, NULL, TRUE, TRUE) && !$this->tryMatch(';', $node, NULL, TRUE, TRUE)) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected :'); } if ($this->currentType !== $terminator && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerCaseStatementList($terminator), 'body'); } return $node; } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "expected case or default"); }
php
private function caseStatement($terminator) { static $terminators = [T_CASE, T_DEFAULT]; if ($this->currentType === T_CASE) { $node = new CaseNode(); $this->mustMatch(T_CASE, $node); $node->addChild($this->expr(), 'matchOn'); if (!$this->tryMatch(':', $node, NULL, TRUE, TRUE) && !$this->tryMatch(';', $node, NULL, TRUE, TRUE)) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected :'); } if ($this->currentType !== $terminator && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerCaseStatementList($terminator), 'body'); } return $node; } elseif ($this->currentType === T_DEFAULT) { $node = new DefaultNode(); $this->mustMatch(T_DEFAULT, $node); if (!$this->tryMatch(':', $node, NULL, TRUE, TRUE) && !$this->tryMatch(';', $node, NULL, TRUE, TRUE)) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected :'); } if ($this->currentType !== $terminator && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerCaseStatementList($terminator), 'body'); } return $node; } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "expected case or default"); }
[ "private", "function", "caseStatement", "(", "$", "terminator", ")", "{", "static", "$", "terminators", "=", "[", "T_CASE", ",", "T_DEFAULT", "]", ";", "if", "(", "$", "this", "->", "currentType", "===", "T_CASE", ")", "{", "$", "node", "=", "new", "Ca...
Parse a case statement. @param int|string $terminator Token type that terminates statement list @return CaseNode|DefaultNode @throws ParserException
[ "Parse", "a", "case", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L718-L758
train
grom358/pharborist
src/Parser.php
Parser.innerCaseStatementList
private function innerCaseStatementList($terminator) { static $terminators = [T_CASE, T_DEFAULT]; $node = new StatementBlockNode(); while ($this->currentType !== NULL && $this->currentType !== $terminator && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerStatement()); } return $node; }
php
private function innerCaseStatementList($terminator) { static $terminators = [T_CASE, T_DEFAULT]; $node = new StatementBlockNode(); while ($this->currentType !== NULL && $this->currentType !== $terminator && !in_array($this->currentType, $terminators)) { $this->matchHidden($node); $node->addChild($this->innerStatement()); } return $node; }
[ "private", "function", "innerCaseStatementList", "(", "$", "terminator", ")", "{", "static", "$", "terminators", "=", "[", "T_CASE", ",", "T_DEFAULT", "]", ";", "$", "node", "=", "new", "StatementBlockNode", "(", ")", ";", "while", "(", "$", "this", "->", ...
Parse the inner statements for a case statement. @param int|string $terminator Token type that terminates statement list @return Node
[ "Parse", "the", "inner", "statements", "for", "a", "case", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L765-L773
train
grom358/pharborist
src/Parser.php
Parser._break
private function _break() { $node = new BreakStatementNode(); $this->mustMatch(T_BREAK, $node); if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) { return $node; } $this->parseLevel($node); $this->endStatement($node); return $node; }
php
private function _break() { $node = new BreakStatementNode(); $this->mustMatch(T_BREAK, $node); if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) { return $node; } $this->parseLevel($node); $this->endStatement($node); return $node; }
[ "private", "function", "_break", "(", ")", "{", "$", "node", "=", "new", "BreakStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_BREAK", ",", "$", "node", ")", ";", "if", "(", "$", "this", "->", "tryMatch", "(", "';'", ",", "$"...
Parse a break statement. @return BreakStatementNode
[ "Parse", "a", "break", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L779-L788
train
grom358/pharborist
src/Parser.php
Parser._continue
private function _continue() { $node = new ContinueStatementNode(); $this->mustMatch(T_CONTINUE, $node); if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) { return $node; } $this->parseLevel($node); $this->endStatement($node); return $node; }
php
private function _continue() { $node = new ContinueStatementNode(); $this->mustMatch(T_CONTINUE, $node); if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) { return $node; } $this->parseLevel($node); $this->endStatement($node); return $node; }
[ "private", "function", "_continue", "(", ")", "{", "$", "node", "=", "new", "ContinueStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_CONTINUE", ",", "$", "node", ")", ";", "if", "(", "$", "this", "->", "tryMatch", "(", "';'", "...
Parse a continue statement. @return ContinueStatementNode
[ "Parse", "a", "continue", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L794-L803
train
grom358/pharborist
src/Parser.php
Parser._return
private function _return() { $node = new ReturnStatementNode(); $this->mustMatch(T_RETURN, $node); if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) { return $node; } $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
php
private function _return() { $node = new ReturnStatementNode(); $this->mustMatch(T_RETURN, $node); if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) { return $node; } $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
[ "private", "function", "_return", "(", ")", "{", "$", "node", "=", "new", "ReturnStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_RETURN", ",", "$", "node", ")", ";", "if", "(", "$", "this", "->", "tryMatch", "(", "';'", ",", ...
Parse a return statement. @return ReturnStatementNode
[ "Parse", "a", "return", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L823-L832
train
grom358/pharborist
src/Parser.php
Parser._yield
private function _yield() { $node = new YieldNode(); $this->mustMatch(T_YIELD, $node); $expr = $this->expr(); if ($this->tryMatch(T_DOUBLE_ARROW, $node)) { $node->addChild($expr, 'key'); $node->addChild($this->expr(), 'value'); } else { $node->addChild($expr, 'value'); } return $node; }
php
private function _yield() { $node = new YieldNode(); $this->mustMatch(T_YIELD, $node); $expr = $this->expr(); if ($this->tryMatch(T_DOUBLE_ARROW, $node)) { $node->addChild($expr, 'key'); $node->addChild($this->expr(), 'value'); } else { $node->addChild($expr, 'value'); } return $node; }
[ "private", "function", "_yield", "(", ")", "{", "$", "node", "=", "new", "YieldNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_YIELD", ",", "$", "node", ")", ";", "$", "expr", "=", "$", "this", "->", "expr", "(", ")", ";", "if", "...
Parse a yield expression. @return YieldNode
[ "Parse", "a", "yield", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L838-L850
train
grom358/pharborist
src/Parser.php
Parser._global
private function _global() { $node = new GlobalStatementNode(); $this->mustMatch(T_GLOBAL, $node); $variables = new CommaListNode(); do { $variables->addChild($this->globalVar()); } while ($this->tryMatch(',', $variables)); $node->addChild($variables, 'variables'); $this->endStatement($node); return $node; }
php
private function _global() { $node = new GlobalStatementNode(); $this->mustMatch(T_GLOBAL, $node); $variables = new CommaListNode(); do { $variables->addChild($this->globalVar()); } while ($this->tryMatch(',', $variables)); $node->addChild($variables, 'variables'); $this->endStatement($node); return $node; }
[ "private", "function", "_global", "(", ")", "{", "$", "node", "=", "new", "GlobalStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_GLOBAL", ",", "$", "node", ")", ";", "$", "variables", "=", "new", "CommaListNode", "(", ")", ";", ...
Parse a global variable declaration list. @return GlobalStatementNode
[ "Parse", "a", "global", "variable", "declaration", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L856-L866
train
grom358/pharborist
src/Parser.php
Parser.globalVar
private function globalVar() { if ($this->currentType === T_VARIABLE) { return $this->mustMatchToken(T_VARIABLE); } elseif ($this->currentType === '$') { if ($this->isLookAhead('{')) { return $this->_compoundVariable(); } else { $node = new VariableVariableNode(); $this->mustMatch('$', $node); $node->addChild($this->variable()); return $node; } } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected a global variable (eg. T_VARIABLE)'); }
php
private function globalVar() { if ($this->currentType === T_VARIABLE) { return $this->mustMatchToken(T_VARIABLE); } elseif ($this->currentType === '$') { if ($this->isLookAhead('{')) { return $this->_compoundVariable(); } else { $node = new VariableVariableNode(); $this->mustMatch('$', $node); $node->addChild($this->variable()); return $node; } } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected a global variable (eg. T_VARIABLE)'); }
[ "private", "function", "globalVar", "(", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "T_VARIABLE", ")", "{", "return", "$", "this", "->", "mustMatchToken", "(", "T_VARIABLE", ")", ";", "}", "elseif", "(", "$", "this", "->", "currentType...
Parse global variable. @return Node @throws ParserException
[ "Parse", "global", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L873-L893
train
grom358/pharborist
src/Parser.php
Parser._echo
private function _echo() { $node = new EchoStatementNode(); $this->mustMatch(T_ECHO, $node); $expressions = new CommaListNode(); do { $expressions->addChild($this->expr()); } while ($this->tryMatch(',', $expressions)); $node->addChild($expressions, 'expressions'); $this->endStatement($node); return $node; }
php
private function _echo() { $node = new EchoStatementNode(); $this->mustMatch(T_ECHO, $node); $expressions = new CommaListNode(); do { $expressions->addChild($this->expr()); } while ($this->tryMatch(',', $expressions)); $node->addChild($expressions, 'expressions'); $this->endStatement($node); return $node; }
[ "private", "function", "_echo", "(", ")", "{", "$", "node", "=", "new", "EchoStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_ECHO", ",", "$", "node", ")", ";", "$", "expressions", "=", "new", "CommaListNode", "(", ")", ";", "do...
Parse echo statement. @return EchoStatementNode
[ "Parse", "echo", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L899-L909
train
grom358/pharborist
src/Parser.php
Parser._unset
private function _unset() { $statement_node = new UnsetStatementNode(); $node = new UnsetNode(); $this->mustMatch(T_UNSET, $node, 'name'); $arguments = new CommaListNode(); $this->mustMatch('(', $node, 'openParen'); $node->addChild($arguments, 'arguments'); do { $arguments->addChild($this->variable()); } while ($this->tryMatch(',', $arguments)); $this->mustMatch(')', $node, 'closeParen', FALSE); $statement_node->addChild($node, 'functionCall'); $this->endStatement($statement_node); return $statement_node; }
php
private function _unset() { $statement_node = new UnsetStatementNode(); $node = new UnsetNode(); $this->mustMatch(T_UNSET, $node, 'name'); $arguments = new CommaListNode(); $this->mustMatch('(', $node, 'openParen'); $node->addChild($arguments, 'arguments'); do { $arguments->addChild($this->variable()); } while ($this->tryMatch(',', $arguments)); $this->mustMatch(')', $node, 'closeParen', FALSE); $statement_node->addChild($node, 'functionCall'); $this->endStatement($statement_node); return $statement_node; }
[ "private", "function", "_unset", "(", ")", "{", "$", "statement_node", "=", "new", "UnsetStatementNode", "(", ")", ";", "$", "node", "=", "new", "UnsetNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_UNSET", ",", "$", "node", ",", "'name'"...
Parse an unset statement. @return UnsetStatementNode
[ "Parse", "an", "unset", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L915-L929
train
grom358/pharborist
src/Parser.php
Parser._foreach
private function _foreach() { $node = new ForeachNode(); $this->mustMatch(T_FOREACH, $node); $this->mustMatch('(', $node, 'openParen'); $node->addChild($this->expr(), 'onEach'); $this->mustMatch(T_AS, $node); $value = $this->foreachVariable(); if ($this->currentType === T_DOUBLE_ARROW) { $node->addChild($value, 'key'); $this->mustMatch(T_DOUBLE_ARROW, $node); $node->addChild($this->foreachVariable(), 'value'); } else { $node->addChild($value, 'value'); } $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE); if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDFOREACH), 'body'); $this->mustMatch(T_ENDFOREACH, $node); $this->endStatement($node); return $node; } else { $node->addChild($this->statement(), 'body'); return $node; } }
php
private function _foreach() { $node = new ForeachNode(); $this->mustMatch(T_FOREACH, $node); $this->mustMatch('(', $node, 'openParen'); $node->addChild($this->expr(), 'onEach'); $this->mustMatch(T_AS, $node); $value = $this->foreachVariable(); if ($this->currentType === T_DOUBLE_ARROW) { $node->addChild($value, 'key'); $this->mustMatch(T_DOUBLE_ARROW, $node); $node->addChild($this->foreachVariable(), 'value'); } else { $node->addChild($value, 'value'); } $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE); if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDFOREACH), 'body'); $this->mustMatch(T_ENDFOREACH, $node); $this->endStatement($node); return $node; } else { $node->addChild($this->statement(), 'body'); return $node; } }
[ "private", "function", "_foreach", "(", ")", "{", "$", "node", "=", "new", "ForeachNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_FOREACH", ",", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "'('", ",", "$", "node", ","...
Parse foreach control structure. @return ForeachNode
[ "Parse", "foreach", "control", "structure", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L935-L961
train
grom358/pharborist
src/Parser.php
Parser.foreachVariable
private function foreachVariable() { if ($this->currentType === T_LIST) { return $this->_list(); } else { if ($this->currentType === '&') { return $this->writeVariable(); } else { return $this->variable(); } } }
php
private function foreachVariable() { if ($this->currentType === T_LIST) { return $this->_list(); } else { if ($this->currentType === '&') { return $this->writeVariable(); } else { return $this->variable(); } } }
[ "private", "function", "foreachVariable", "(", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "T_LIST", ")", "{", "return", "$", "this", "->", "_list", "(", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "currentType", "==="...
Parse a foreach variable. @return Node
[ "Parse", "a", "foreach", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L967-L979
train
grom358/pharborist
src/Parser.php
Parser._declare
private function _declare() { $node = new DeclareNode(); $this->mustMatch(T_DECLARE, $node); $this->mustMatch('(', $node, 'openParen'); $directives = new CommaListNode(); $node->addChild($directives, 'directives'); if (!$this->tryMatch(')', $node, 'closeParen', FALSE, TRUE)) { do { $declare_directive = new DeclareDirectiveNode(); $this->tryMatch(T_STRING, $declare_directive, 'name'); if ($this->tryMatch('=', $declare_directive)) { $declare_directive->addChild($this->staticScalar(), 'value'); } $directives->addChild($declare_directive); } while ($this->tryMatch(',', $directives)); $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE); } if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDDECLARE), 'body'); $this->mustMatch(T_ENDDECLARE, $node); $this->endStatement($node); return $node; } else { $node->addChild($this->statement(), 'body'); return $node; } }
php
private function _declare() { $node = new DeclareNode(); $this->mustMatch(T_DECLARE, $node); $this->mustMatch('(', $node, 'openParen'); $directives = new CommaListNode(); $node->addChild($directives, 'directives'); if (!$this->tryMatch(')', $node, 'closeParen', FALSE, TRUE)) { do { $declare_directive = new DeclareDirectiveNode(); $this->tryMatch(T_STRING, $declare_directive, 'name'); if ($this->tryMatch('=', $declare_directive)) { $declare_directive->addChild($this->staticScalar(), 'value'); } $directives->addChild($declare_directive); } while ($this->tryMatch(',', $directives)); $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE); } if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDDECLARE), 'body'); $this->mustMatch(T_ENDDECLARE, $node); $this->endStatement($node); return $node; } else { $node->addChild($this->statement(), 'body'); return $node; } }
[ "private", "function", "_declare", "(", ")", "{", "$", "node", "=", "new", "DeclareNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_DECLARE", ",", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "'('", ",", "$", "node", ","...
Parse a declare statement. @return DeclareNode
[ "Parse", "a", "declare", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1020-L1047
train
grom358/pharborist
src/Parser.php
Parser._try
private function _try() { $node = new TryCatchNode(); $this->mustMatch(T_TRY, $node); $node->addChild($this->innerStatementBlock(), 'try'); $catch_node = new CatchNode(); while ($this->tryMatch(T_CATCH, $catch_node)) { $this->mustMatch('(', $catch_node, 'openParen'); $catch_node->addChild($this->name(), 'exceptionType'); $this->mustMatch(T_VARIABLE, $catch_node, 'variable'); $this->mustMatch(')', $catch_node, 'closeParen', FALSE, TRUE); $catch_node->addChild($this->innerStatementBlock(), 'body'); $node->addChild($catch_node); $catch_node = new CatchNode(); } if ($this->tryMatch(T_FINALLY, $node)) { $node->addChild($this->innerStatementBlock(), 'finally'); } return $node; }
php
private function _try() { $node = new TryCatchNode(); $this->mustMatch(T_TRY, $node); $node->addChild($this->innerStatementBlock(), 'try'); $catch_node = new CatchNode(); while ($this->tryMatch(T_CATCH, $catch_node)) { $this->mustMatch('(', $catch_node, 'openParen'); $catch_node->addChild($this->name(), 'exceptionType'); $this->mustMatch(T_VARIABLE, $catch_node, 'variable'); $this->mustMatch(')', $catch_node, 'closeParen', FALSE, TRUE); $catch_node->addChild($this->innerStatementBlock(), 'body'); $node->addChild($catch_node); $catch_node = new CatchNode(); } if ($this->tryMatch(T_FINALLY, $node)) { $node->addChild($this->innerStatementBlock(), 'finally'); } return $node; }
[ "private", "function", "_try", "(", ")", "{", "$", "node", "=", "new", "TryCatchNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_TRY", ",", "$", "node", ")", ";", "$", "node", "->", "addChild", "(", "$", "this", "->", "innerStatementBloc...
Parse a try control structure. @return TryCatchNode
[ "Parse", "a", "try", "control", "structure", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1053-L1071
train
grom358/pharborist
src/Parser.php
Parser._throw
private function _throw() { $node = new ThrowStatementNode(); $this->mustMatch(T_THROW, $node); $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
php
private function _throw() { $node = new ThrowStatementNode(); $this->mustMatch(T_THROW, $node); $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
[ "private", "function", "_throw", "(", ")", "{", "$", "node", "=", "new", "ThrowStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_THROW", ",", "$", "node", ")", ";", "$", "node", "->", "addChild", "(", "$", "this", "->", "expr", ...
Parse a throw statement. @return ThrowStatementNode
[ "Parse", "a", "throw", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1077-L1083
train
grom358/pharborist
src/Parser.php
Parser._goto
private function _goto() { $node = new GotoStatementNode(); $this->mustMatch(T_GOTO, $node); $this->mustMatch(T_STRING, $node, 'label'); $this->endStatement($node); return $node; }
php
private function _goto() { $node = new GotoStatementNode(); $this->mustMatch(T_GOTO, $node); $this->mustMatch(T_STRING, $node, 'label'); $this->endStatement($node); return $node; }
[ "private", "function", "_goto", "(", ")", "{", "$", "node", "=", "new", "GotoStatementNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_GOTO", ",", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "T_STRING", ",", "$", "node", ...
Parse a goto statement. @return GotoStatementNode
[ "Parse", "a", "goto", "statement", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1089-L1095
train
grom358/pharborist
src/Parser.php
Parser.exprList
private function exprList() { $node = new CommaListNode(); do { $node->addChild($this->expr()); } while ($this->tryMatch(',', $node)); return $node; }
php
private function exprList() { $node = new CommaListNode(); do { $node->addChild($this->expr()); } while ($this->tryMatch(',', $node)); return $node; }
[ "private", "function", "exprList", "(", ")", "{", "$", "node", "=", "new", "CommaListNode", "(", ")", ";", "do", "{", "$", "node", "->", "addChild", "(", "$", "this", "->", "expr", "(", ")", ")", ";", "}", "while", "(", "$", "this", "->", "tryMat...
Parse a list of expressions. @return CommaListNode
[ "Parse", "a", "list", "of", "expressions", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1101-L1107
train
grom358/pharborist
src/Parser.php
Parser.staticScalar
private function staticScalar() { if ($this->currentType === T_ARRAY) { $node = new ArrayNode(); $this->mustMatch(T_ARRAY, $node); $this->mustMatch('(', $node, 'openParen'); $this->staticArrayPairList($node, ')'); $this->mustMatch(')', $node, 'closeParen', TRUE); return $node; } elseif ($this->currentType === '[') { $node = new ArrayNode(); $this->mustMatch('[', $node); $this->staticArrayPairList($node, ']'); $this->mustMatch(']', $node, NULL, TRUE); return $node; } else { return $this->expr(TRUE); } }
php
private function staticScalar() { if ($this->currentType === T_ARRAY) { $node = new ArrayNode(); $this->mustMatch(T_ARRAY, $node); $this->mustMatch('(', $node, 'openParen'); $this->staticArrayPairList($node, ')'); $this->mustMatch(')', $node, 'closeParen', TRUE); return $node; } elseif ($this->currentType === '[') { $node = new ArrayNode(); $this->mustMatch('[', $node); $this->staticArrayPairList($node, ']'); $this->mustMatch(']', $node, NULL, TRUE); return $node; } else { return $this->expr(TRUE); } }
[ "private", "function", "staticScalar", "(", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "T_ARRAY", ")", "{", "$", "node", "=", "new", "ArrayNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_ARRAY", ",", "$", "node", ")",...
Parse a static scalar expression. @return Node @throws ParserException
[ "Parse", "a", "static", "scalar", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1114-L1133
train
grom358/pharborist
src/Parser.php
Parser.staticOperand
private function staticOperand() { static $scalar_types = [ T_STRING_VARNAME, T_CLASS_C, T_LNUMBER, T_DNUMBER, T_CONSTANT_ENCAPSED_STRING, T_LINE, T_FILE, T_DIR, T_TRAIT_C, T_METHOD_C, T_FUNC_C, T_NS_C, ]; if ($scalar = $this->tryMatchToken($scalar_types)) { return $scalar; } elseif ($this->currentType === '(') { $node = new ParenthesisNode(); $this->mustMatch('(', $node, 'openParen'); $node->addChild($this->staticScalar(), 'expression'); $this->mustMatch(')', $node, 'closeParen', TRUE); return $node; } elseif (in_array($this->currentType, self::$namespacePathTypes)) { $namespace_path = $this->name(); if ($this->currentType === T_DOUBLE_COLON) { $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_CLASS) { return $this->classNameScalar($namespace_path, $colon_node); } else { $class_constant = $this->mustMatchToken(T_STRING); return $this->classConstant($namespace_path, $colon_node, $class_constant); } } else { $node = new ConstantNode(); $node->addChild($namespace_path, 'constantName'); return $node; } } elseif ($this->currentType === T_STATIC) { $static_node = $this->mustMatchToken(T_STATIC); $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_CLASS) { return $this->classNameScalar($static_node, $colon_node); } else { $class_constant = $this->mustMatchToken(T_STRING); return $this->classConstant($static_node, $colon_node, $class_constant); } } elseif ($this->currentType === T_START_HEREDOC) { $node = new HeredocNode(); $this->mustMatch(T_START_HEREDOC, $node); if ($this->tryMatch(T_END_HEREDOC, $node)) { return $node; } $this->mustMatch(T_ENCAPSED_AND_WHITESPACE, $node); $this->mustMatch(T_END_HEREDOC, $node); return $node; } else { return NULL; } }
php
private function staticOperand() { static $scalar_types = [ T_STRING_VARNAME, T_CLASS_C, T_LNUMBER, T_DNUMBER, T_CONSTANT_ENCAPSED_STRING, T_LINE, T_FILE, T_DIR, T_TRAIT_C, T_METHOD_C, T_FUNC_C, T_NS_C, ]; if ($scalar = $this->tryMatchToken($scalar_types)) { return $scalar; } elseif ($this->currentType === '(') { $node = new ParenthesisNode(); $this->mustMatch('(', $node, 'openParen'); $node->addChild($this->staticScalar(), 'expression'); $this->mustMatch(')', $node, 'closeParen', TRUE); return $node; } elseif (in_array($this->currentType, self::$namespacePathTypes)) { $namespace_path = $this->name(); if ($this->currentType === T_DOUBLE_COLON) { $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_CLASS) { return $this->classNameScalar($namespace_path, $colon_node); } else { $class_constant = $this->mustMatchToken(T_STRING); return $this->classConstant($namespace_path, $colon_node, $class_constant); } } else { $node = new ConstantNode(); $node->addChild($namespace_path, 'constantName'); return $node; } } elseif ($this->currentType === T_STATIC) { $static_node = $this->mustMatchToken(T_STATIC); $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_CLASS) { return $this->classNameScalar($static_node, $colon_node); } else { $class_constant = $this->mustMatchToken(T_STRING); return $this->classConstant($static_node, $colon_node, $class_constant); } } elseif ($this->currentType === T_START_HEREDOC) { $node = new HeredocNode(); $this->mustMatch(T_START_HEREDOC, $node); if ($this->tryMatch(T_END_HEREDOC, $node)) { return $node; } $this->mustMatch(T_ENCAPSED_AND_WHITESPACE, $node); $this->mustMatch(T_END_HEREDOC, $node); return $node; } else { return NULL; } }
[ "private", "function", "staticOperand", "(", ")", "{", "static", "$", "scalar_types", "=", "[", "T_STRING_VARNAME", ",", "T_CLASS_C", ",", "T_LNUMBER", ",", "T_DNUMBER", ",", "T_CONSTANT_ENCAPSED_STRING", ",", "T_LINE", ",", "T_FILE", ",", "T_DIR", ",", "T_TRAIT...
Parse static operand. @return Node
[ "Parse", "static", "operand", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1139-L1208
train
grom358/pharborist
src/Parser.php
Parser.expr
private function expr($static = FALSE) { static $end_expression_types = [':', ';', ',', ')', ']', '}', T_AS, T_DOUBLE_ARROW, T_CLOSE_TAG]; // Group tokens into operands & operators to pass to the expression parser $expression_nodes = []; while ($this->currentType !== NULL && !in_array($this->currentType, $end_expression_types)) { if ($op = $this->exprOperator($static)) { $expression_nodes[] = $op; if ($op->type === T_INSTANCEOF) { $expression_nodes[] = $this->classNameReference(); } } elseif ($operand = ($static ? $this->staticOperand() : $this->exprOperand())) { $expression_nodes[] = $operand; } else { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "invalid expression"); } } return $this->expressionParser->parse($expression_nodes, $this->filename); }
php
private function expr($static = FALSE) { static $end_expression_types = [':', ';', ',', ')', ']', '}', T_AS, T_DOUBLE_ARROW, T_CLOSE_TAG]; // Group tokens into operands & operators to pass to the expression parser $expression_nodes = []; while ($this->currentType !== NULL && !in_array($this->currentType, $end_expression_types)) { if ($op = $this->exprOperator($static)) { $expression_nodes[] = $op; if ($op->type === T_INSTANCEOF) { $expression_nodes[] = $this->classNameReference(); } } elseif ($operand = ($static ? $this->staticOperand() : $this->exprOperand())) { $expression_nodes[] = $operand; } else { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "invalid expression"); } } return $this->expressionParser->parse($expression_nodes, $this->filename); }
[ "private", "function", "expr", "(", "$", "static", "=", "FALSE", ")", "{", "static", "$", "end_expression_types", "=", "[", "':'", ",", "';'", ",", "','", ",", "')'", ",", "']'", ",", "'}'", ",", "T_AS", ",", "T_DOUBLE_ARROW", ",", "T_CLOSE_TAG", "]", ...
Parse an expression. @param bool $static TRUE if static expression @return Node @throws ParserException
[ "Parse", "an", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1216-L1239
train
grom358/pharborist
src/Parser.php
Parser.exprOperator
private function exprOperator($static = FALSE) { $token_type = $this->currentType; if ($operator = OperatorFactory::createOperator($token_type, $static)) { $this->mustMatch($token_type, $operator, 'operator'); if ($token_type === '?') { if ($this->currentType === ':') { $colon = new PartialNode(); $this->mustMatch(':', $colon); return OperatorFactory::createElvisOperator($operator, $colon); } else { $operator->then = $static ? $this->staticScalar() : $this->expr(); $colon = new PartialNode(); $this->mustMatch(':', $colon); $operator->colon = $colon; return $operator; } } elseif ($token_type === '=' && $this->currentType === '&') { $by_ref_node = new PartialNode(); $this->mustMatch('&', $by_ref_node); return OperatorFactory::createAssignReferenceOperator($operator, $by_ref_node); } return $operator; } return NULL; }
php
private function exprOperator($static = FALSE) { $token_type = $this->currentType; if ($operator = OperatorFactory::createOperator($token_type, $static)) { $this->mustMatch($token_type, $operator, 'operator'); if ($token_type === '?') { if ($this->currentType === ':') { $colon = new PartialNode(); $this->mustMatch(':', $colon); return OperatorFactory::createElvisOperator($operator, $colon); } else { $operator->then = $static ? $this->staticScalar() : $this->expr(); $colon = new PartialNode(); $this->mustMatch(':', $colon); $operator->colon = $colon; return $operator; } } elseif ($token_type === '=' && $this->currentType === '&') { $by_ref_node = new PartialNode(); $this->mustMatch('&', $by_ref_node); return OperatorFactory::createAssignReferenceOperator($operator, $by_ref_node); } return $operator; } return NULL; }
[ "private", "function", "exprOperator", "(", "$", "static", "=", "FALSE", ")", "{", "$", "token_type", "=", "$", "this", "->", "currentType", ";", "if", "(", "$", "operator", "=", "OperatorFactory", "::", "createOperator", "(", "$", "token_type", ",", "$", ...
Parse an expression operator. @param bool $static Static operator @return Operator
[ "Parse", "an", "expression", "operator", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1246-L1272
train
grom358/pharborist
src/Parser.php
Parser.backtick
private function backtick() { $node = new BacktickNode(); $this->mustMatch('`', $node); $this->encapsList($node, '`', TRUE); $this->mustMatch('`', $node, NULL, TRUE); return $node; }
php
private function backtick() { $node = new BacktickNode(); $this->mustMatch('`', $node); $this->encapsList($node, '`', TRUE); $this->mustMatch('`', $node, NULL, TRUE); return $node; }
[ "private", "function", "backtick", "(", ")", "{", "$", "node", "=", "new", "BacktickNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "'`'", ",", "$", "node", ")", ";", "$", "this", "->", "encapsList", "(", "$", "node", ",", "'`'", ",", ...
Parse a backtick expression. @return BacktickNode
[ "Parse", "a", "backtick", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1472-L1478
train
grom358/pharborist
src/Parser.php
Parser.anonymousFunction
private function anonymousFunction(Node $static = NULL) { $node = new AnonymousFunctionNode(); if ($static) { $node->addChild($static); } $this->mustMatch(T_FUNCTION, $node); $this->tryMatch('&', $node, 'reference'); $this->parameterList($node); if ($this->tryMatch(T_USE, $node, 'lexicalUse')) { $this->mustMatch('(', $node, 'lexicalOpenParen'); $lexical_vars_node = new CommaListNode(); do { if ($this->currentType === '&') { $var = new ReferenceVariableNode(); $this->mustMatch('&', $var); $this->mustMatch(T_VARIABLE, $var, 'variable', TRUE); $lexical_vars_node->addChild($var); } else { $this->mustMatch(T_VARIABLE, $lexical_vars_node, NULL, TRUE); } } while ($this->tryMatch(',', $lexical_vars_node)); $node->addChild($lexical_vars_node, 'lexicalVariables'); $this->mustMatch(')', $node, 'lexicalCloseParen'); } $this->matchHidden($node); $node->addChild($this->innerStatementBlock(), 'body'); return $node; }
php
private function anonymousFunction(Node $static = NULL) { $node = new AnonymousFunctionNode(); if ($static) { $node->addChild($static); } $this->mustMatch(T_FUNCTION, $node); $this->tryMatch('&', $node, 'reference'); $this->parameterList($node); if ($this->tryMatch(T_USE, $node, 'lexicalUse')) { $this->mustMatch('(', $node, 'lexicalOpenParen'); $lexical_vars_node = new CommaListNode(); do { if ($this->currentType === '&') { $var = new ReferenceVariableNode(); $this->mustMatch('&', $var); $this->mustMatch(T_VARIABLE, $var, 'variable', TRUE); $lexical_vars_node->addChild($var); } else { $this->mustMatch(T_VARIABLE, $lexical_vars_node, NULL, TRUE); } } while ($this->tryMatch(',', $lexical_vars_node)); $node->addChild($lexical_vars_node, 'lexicalVariables'); $this->mustMatch(')', $node, 'lexicalCloseParen'); } $this->matchHidden($node); $node->addChild($this->innerStatementBlock(), 'body'); return $node; }
[ "private", "function", "anonymousFunction", "(", "Node", "$", "static", "=", "NULL", ")", "{", "$", "node", "=", "new", "AnonymousFunctionNode", "(", ")", ";", "if", "(", "$", "static", ")", "{", "$", "node", "->", "addChild", "(", "$", "static", ")", ...
Parse an anonymous function declaration. @param Node $static @return AnonymousFunctionNode
[ "Parse", "an", "anonymous", "function", "declaration", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1485-L1513
train
grom358/pharborist
src/Parser.php
Parser.newExpr
private function newExpr() { $node = new NewNode(); $this->mustMatch(T_NEW, $node); $node->addChild($this->classNameReference(), 'className'); if ($this->currentType === '(') { $this->functionCallParameterList($node); } return $node; }
php
private function newExpr() { $node = new NewNode(); $this->mustMatch(T_NEW, $node); $node->addChild($this->classNameReference(), 'className'); if ($this->currentType === '(') { $this->functionCallParameterList($node); } return $node; }
[ "private", "function", "newExpr", "(", ")", "{", "$", "node", "=", "new", "NewNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_NEW", ",", "$", "node", ")", ";", "$", "node", "->", "addChild", "(", "$", "this", "->", "classNameReference",...
Parse a new expression. @return NewNode
[ "Parse", "a", "new", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1519-L1527
train
grom358/pharborist
src/Parser.php
Parser.classNameReference
private function classNameReference() { switch ($this->currentType) { case T_STRING: case T_NS_SEPARATOR: case T_NAMESPACE: $namespace_path = $this->name(); if ($this->currentType === T_DOUBLE_COLON) { $node = $this->staticMember($namespace_path); return $this->dynamicClassNameReference($node); } else { return $namespace_path; } case T_STATIC: $static_node = $this->mustMatchToken(T_STATIC); if ($this->currentType === T_DOUBLE_COLON) { $node = $this->staticMember($static_node); return $this->dynamicClassNameReference($node); } else { return $static_node; } default: if ($this->currentType === '$' && !$this->isLookAhead('{')) { return $this->dynamicClassNameReference($this->indirectReference()); } $var_node = $this->referenceVariable(); if ($this->currentType === T_DOUBLE_COLON) { $var_node = $this->staticMember($var_node); } return $this->dynamicClassNameReference($var_node); } }
php
private function classNameReference() { switch ($this->currentType) { case T_STRING: case T_NS_SEPARATOR: case T_NAMESPACE: $namespace_path = $this->name(); if ($this->currentType === T_DOUBLE_COLON) { $node = $this->staticMember($namespace_path); return $this->dynamicClassNameReference($node); } else { return $namespace_path; } case T_STATIC: $static_node = $this->mustMatchToken(T_STATIC); if ($this->currentType === T_DOUBLE_COLON) { $node = $this->staticMember($static_node); return $this->dynamicClassNameReference($node); } else { return $static_node; } default: if ($this->currentType === '$' && !$this->isLookAhead('{')) { return $this->dynamicClassNameReference($this->indirectReference()); } $var_node = $this->referenceVariable(); if ($this->currentType === T_DOUBLE_COLON) { $var_node = $this->staticMember($var_node); } return $this->dynamicClassNameReference($var_node); } }
[ "private", "function", "classNameReference", "(", ")", "{", "switch", "(", "$", "this", "->", "currentType", ")", "{", "case", "T_STRING", ":", "case", "T_NS_SEPARATOR", ":", "case", "T_NAMESPACE", ":", "$", "namespace_path", "=", "$", "this", "->", "name", ...
Parse a class name reference. @return Node
[ "Parse", "a", "class", "name", "reference", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1533-L1565
train
grom358/pharborist
src/Parser.php
Parser.staticMember
private function staticMember($var_node) { $node = new ClassMemberLookupNode(); $node->addChild($var_node, 'className'); $this->mustMatch(T_DOUBLE_COLON, $node); $node->addChild($this->indirectReference(), 'memberName'); return $node; }
php
private function staticMember($var_node) { $node = new ClassMemberLookupNode(); $node->addChild($var_node, 'className'); $this->mustMatch(T_DOUBLE_COLON, $node); $node->addChild($this->indirectReference(), 'memberName'); return $node; }
[ "private", "function", "staticMember", "(", "$", "var_node", ")", "{", "$", "node", "=", "new", "ClassMemberLookupNode", "(", ")", ";", "$", "node", "->", "addChild", "(", "$", "var_node", ",", "'className'", ")", ";", "$", "this", "->", "mustMatch", "("...
Parse static member. @param Node $var_node @return ClassMemberLookupNode
[ "Parse", "static", "member", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1572-L1578
train
grom358/pharborist
src/Parser.php
Parser.dynamicClassNameReference
private function dynamicClassNameReference(Node $object) { $node = $object; while ($this->currentType === T_OBJECT_OPERATOR) { $node = new ObjectPropertyNode(); $node->addChild($object, 'object'); $this->mustMatch(T_OBJECT_OPERATOR, $node); $node->addChild($this->objectProperty(), 'property'); $object = $this->offsetVariable($node); } return $node; }
php
private function dynamicClassNameReference(Node $object) { $node = $object; while ($this->currentType === T_OBJECT_OPERATOR) { $node = new ObjectPropertyNode(); $node->addChild($object, 'object'); $this->mustMatch(T_OBJECT_OPERATOR, $node); $node->addChild($this->objectProperty(), 'property'); $object = $this->offsetVariable($node); } return $node; }
[ "private", "function", "dynamicClassNameReference", "(", "Node", "$", "object", ")", "{", "$", "node", "=", "$", "object", ";", "while", "(", "$", "this", "->", "currentType", "===", "T_OBJECT_OPERATOR", ")", "{", "$", "node", "=", "new", "ObjectPropertyNode...
Parse a dynamic class name reference. @param Node $object @return Node
[ "Parse", "a", "dynamic", "class", "name", "reference", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1585-L1595
train
grom358/pharborist
src/Parser.php
Parser.arrayPairList
private function arrayPairList(ArrayNode $node, $terminator) { $elements = new CommaListNode(); do { if ($this->currentType === $terminator) { break; } $this->matchHidden($elements); $elements->addChild($this->arrayPair()); } while ($this->tryMatch(',', $elements, NULL, TRUE)); $node->addChild($elements, 'elements'); }
php
private function arrayPairList(ArrayNode $node, $terminator) { $elements = new CommaListNode(); do { if ($this->currentType === $terminator) { break; } $this->matchHidden($elements); $elements->addChild($this->arrayPair()); } while ($this->tryMatch(',', $elements, NULL, TRUE)); $node->addChild($elements, 'elements'); }
[ "private", "function", "arrayPairList", "(", "ArrayNode", "$", "node", ",", "$", "terminator", ")", "{", "$", "elements", "=", "new", "CommaListNode", "(", ")", ";", "do", "{", "if", "(", "$", "this", "->", "currentType", "===", "$", "terminator", ")", ...
Parse array pair list. @param ArrayNode $node the parent ArrayNode @param int|string $terminator Token type that ends the pair list
[ "Parse", "array", "pair", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1602-L1612
train
grom358/pharborist
src/Parser.php
Parser.staticArrayPairList
private function staticArrayPairList(ArrayNode $node, $terminator) { $elements = new CommaListNode(); do { if ($this->currentType === $terminator) { break; } $this->matchHidden($elements); $value = $this->staticScalar(); if ($this->currentType === T_DOUBLE_ARROW) { $pair = new ArrayPairNode(); $pair->addChild($value, 'key'); $this->mustMatch(T_DOUBLE_ARROW, $pair); $pair->addChild($this->staticScalar(), 'value'); $elements->addChild($pair); } else { $elements->addChild($value); } } while ($this->tryMatch(',', $elements, NULL, TRUE)); $node->addChild($elements, 'elements'); }
php
private function staticArrayPairList(ArrayNode $node, $terminator) { $elements = new CommaListNode(); do { if ($this->currentType === $terminator) { break; } $this->matchHidden($elements); $value = $this->staticScalar(); if ($this->currentType === T_DOUBLE_ARROW) { $pair = new ArrayPairNode(); $pair->addChild($value, 'key'); $this->mustMatch(T_DOUBLE_ARROW, $pair); $pair->addChild($this->staticScalar(), 'value'); $elements->addChild($pair); } else { $elements->addChild($value); } } while ($this->tryMatch(',', $elements, NULL, TRUE)); $node->addChild($elements, 'elements'); }
[ "private", "function", "staticArrayPairList", "(", "ArrayNode", "$", "node", ",", "$", "terminator", ")", "{", "$", "elements", "=", "new", "CommaListNode", "(", ")", ";", "do", "{", "if", "(", "$", "this", "->", "currentType", "===", "$", "terminator", ...
Parse static array pair list. @param ArrayNode $node Array node to add elements to @param int|string $terminator Token type that terminates the array pair list
[ "Parse", "static", "array", "pair", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1619-L1639
train
grom358/pharborist
src/Parser.php
Parser.arrayPair
private function arrayPair() { if ($this->currentType === '&') { return $this->writeVariable(); } $node = $this->expr(); if ($this->currentType === T_DOUBLE_ARROW) { $expr = $node; $node = new ArrayPairNode(); $node->addChild($expr, 'key'); $this->mustMatch(T_DOUBLE_ARROW, $node); if ($this->currentType === '&') { $node->addChild($this->writeVariable(), 'value'); } else { $node->addChild($this->expr(), 'value'); } } return $node; }
php
private function arrayPair() { if ($this->currentType === '&') { return $this->writeVariable(); } $node = $this->expr(); if ($this->currentType === T_DOUBLE_ARROW) { $expr = $node; $node = new ArrayPairNode(); $node->addChild($expr, 'key'); $this->mustMatch(T_DOUBLE_ARROW, $node); if ($this->currentType === '&') { $node->addChild($this->writeVariable(), 'value'); } else { $node->addChild($this->expr(), 'value'); } } return $node; }
[ "private", "function", "arrayPair", "(", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "'&'", ")", "{", "return", "$", "this", "->", "writeVariable", "(", ")", ";", "}", "$", "node", "=", "$", "this", "->", "expr", "(", ")", ";", ...
Parse an array pair. @return Node
[ "Parse", "an", "array", "pair", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1645-L1663
train
grom358/pharborist
src/Parser.php
Parser.writeVariable
private function writeVariable() { $node = new ReferenceVariableNode(); $this->mustMatch('&', $node); $node->addChild($this->variable(), 'variable'); return $node; }
php
private function writeVariable() { $node = new ReferenceVariableNode(); $this->mustMatch('&', $node); $node->addChild($this->variable(), 'variable'); return $node; }
[ "private", "function", "writeVariable", "(", ")", "{", "$", "node", "=", "new", "ReferenceVariableNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "'&'", ",", "$", "node", ")", ";", "$", "node", "->", "addChild", "(", "$", "this", "->", "va...
Parse a write variable. @return ReferenceVariableNode
[ "Parse", "a", "write", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1669-L1674
train
grom358/pharborist
src/Parser.php
Parser.encapsList
private function encapsList($node, $terminator, $encaps_whitespace_allowed = FALSE) { if (!$encaps_whitespace_allowed) { if ($this->tryMatch(T_ENCAPSED_AND_WHITESPACE, $node)) { $node->addChild($this->encapsVar()); } } while ($this->currentType !== NULL && $this->currentType !== $terminator) { $this->tryMatch(T_ENCAPSED_AND_WHITESPACE, $node) || $node->addChild($this->encapsVar()); } }
php
private function encapsList($node, $terminator, $encaps_whitespace_allowed = FALSE) { if (!$encaps_whitespace_allowed) { if ($this->tryMatch(T_ENCAPSED_AND_WHITESPACE, $node)) { $node->addChild($this->encapsVar()); } } while ($this->currentType !== NULL && $this->currentType !== $terminator) { $this->tryMatch(T_ENCAPSED_AND_WHITESPACE, $node) || $node->addChild($this->encapsVar()); } }
[ "private", "function", "encapsList", "(", "$", "node", ",", "$", "terminator", ",", "$", "encaps_whitespace_allowed", "=", "FALSE", ")", "{", "if", "(", "!", "$", "encaps_whitespace_allowed", ")", "{", "if", "(", "$", "this", "->", "tryMatch", "(", "T_ENCA...
Parse an encaps list. @param InterpolatedStringNode|HeredocNode|BacktickNode $node Interpolated string. @param int|string $terminator Token type that terminates the encaps list @param bool $encaps_whitespace_allowed
[ "Parse", "an", "encaps", "list", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1682-L1692
train
grom358/pharborist
src/Parser.php
Parser.encapsVar
private function encapsVar() { static $offset_types = [T_STRING, T_NUM_STRING, T_VARIABLE]; $node = new StringVariableNode(); if ($this->tryMatch(T_DOLLAR_OPEN_CURLY_BRACES, $node)) { if ($this->tryMatch(T_STRING_VARNAME, $node)) { if ($this->tryMatch('[', $node)) { $node->addChild($this->expr()); $this->mustMatch(']', $node); } } else { $node->addChild($this->expr()); } $this->mustMatch('}', $node); return $node; } elseif ($this->tryMatch(T_CURLY_OPEN, $node)) { $node->addChild($this->variable()); $this->mustMatch('}', $node); return $node; } elseif ($this->mustMatch(T_VARIABLE, $node)) { if ($this->tryMatch('[', $node)) { if (!in_array($this->currentType, $offset_types)) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected encaps_var_offset (T_STRING or T_NUM_STRING or T_VARIABLE)'); } $node->addChild($this->tryMatchToken($offset_types)); $this->mustMatch(']', $node); } elseif ($this->tryMatch(T_OBJECT_OPERATOR, $node)) { $this->mustMatch(T_STRING, $node); } return $node; } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected encaps variable'); }
php
private function encapsVar() { static $offset_types = [T_STRING, T_NUM_STRING, T_VARIABLE]; $node = new StringVariableNode(); if ($this->tryMatch(T_DOLLAR_OPEN_CURLY_BRACES, $node)) { if ($this->tryMatch(T_STRING_VARNAME, $node)) { if ($this->tryMatch('[', $node)) { $node->addChild($this->expr()); $this->mustMatch(']', $node); } } else { $node->addChild($this->expr()); } $this->mustMatch('}', $node); return $node; } elseif ($this->tryMatch(T_CURLY_OPEN, $node)) { $node->addChild($this->variable()); $this->mustMatch('}', $node); return $node; } elseif ($this->mustMatch(T_VARIABLE, $node)) { if ($this->tryMatch('[', $node)) { if (!in_array($this->currentType, $offset_types)) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected encaps_var_offset (T_STRING or T_NUM_STRING or T_VARIABLE)'); } $node->addChild($this->tryMatchToken($offset_types)); $this->mustMatch(']', $node); } elseif ($this->tryMatch(T_OBJECT_OPERATOR, $node)) { $this->mustMatch(T_STRING, $node); } return $node; } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected encaps variable'); }
[ "private", "function", "encapsVar", "(", ")", "{", "static", "$", "offset_types", "=", "[", "T_STRING", ",", "T_NUM_STRING", ",", "T_VARIABLE", "]", ";", "$", "node", "=", "new", "StringVariableNode", "(", ")", ";", "if", "(", "$", "this", "->", "tryMatc...
Parse an encaps variable. @return StringVariableNode @throws ParserException
[ "Parse", "an", "encaps", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1699-L1742
train
grom358/pharborist
src/Parser.php
Parser.exprClass
private function exprClass(Node $class_name) { $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_STRING) { $class_constant = $this->mustMatchToken(T_STRING); if ($this->currentType === '(') { return $this->classMethodCall($class_name, $colon_node, $class_constant); } else { return $this->classConstant($class_name, $colon_node, $class_constant); } } elseif ($this->currentType === T_CLASS) { return $this->classNameScalar($class_name, $colon_node); } else { return $this->classVariable($class_name, $colon_node); } }
php
private function exprClass(Node $class_name) { $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_STRING) { $class_constant = $this->mustMatchToken(T_STRING); if ($this->currentType === '(') { return $this->classMethodCall($class_name, $colon_node, $class_constant); } else { return $this->classConstant($class_name, $colon_node, $class_constant); } } elseif ($this->currentType === T_CLASS) { return $this->classNameScalar($class_name, $colon_node); } else { return $this->classVariable($class_name, $colon_node); } }
[ "private", "function", "exprClass", "(", "Node", "$", "class_name", ")", "{", "$", "colon_node", "=", "new", "PartialNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_DOUBLE_COLON", ",", "$", "colon_node", ")", ";", "if", "(", "$", "this", ...
Parse expression operand given class name. @param Node $class_name @return Node
[ "Parse", "expression", "operand", "given", "class", "name", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1749-L1767
train
grom358/pharborist
src/Parser.php
Parser.classConstant
private function classConstant($class_name, $colon_node, $class_constant) { $node = new ClassConstantLookupNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $node->addChild($class_constant, 'constantName'); return $node; }
php
private function classConstant($class_name, $colon_node, $class_constant) { $node = new ClassConstantLookupNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $node->addChild($class_constant, 'constantName'); return $node; }
[ "private", "function", "classConstant", "(", "$", "class_name", ",", "$", "colon_node", ",", "$", "class_constant", ")", "{", "$", "node", "=", "new", "ClassConstantLookupNode", "(", ")", ";", "$", "node", "->", "addChild", "(", "$", "class_name", ",", "'c...
Construct a class constant. @param $class_name @param $colon_node @param $class_constant @return ClassConstantLookupNode
[ "Construct", "a", "class", "constant", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1776-L1782
train
grom358/pharborist
src/Parser.php
Parser.classMethodCall
private function classMethodCall($class_name, $colon_node, $method_name) { $node = new ClassMethodCallNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $node->addChild($method_name, 'methodName'); $this->functionCallParameterList($node); return $this->objectDereference($this->arrayDeference($node)); }
php
private function classMethodCall($class_name, $colon_node, $method_name) { $node = new ClassMethodCallNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $node->addChild($method_name, 'methodName'); $this->functionCallParameterList($node); return $this->objectDereference($this->arrayDeference($node)); }
[ "private", "function", "classMethodCall", "(", "$", "class_name", ",", "$", "colon_node", ",", "$", "method_name", ")", "{", "$", "node", "=", "new", "ClassMethodCallNode", "(", ")", ";", "$", "node", "->", "addChild", "(", "$", "class_name", ",", "'classN...
Construct a class method call. @param Node $class_name @param ParentNode $colon_node @param Node $method_name @return Node
[ "Construct", "a", "class", "method", "call", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1791-L1798
train
grom358/pharborist
src/Parser.php
Parser.classNameScalar
private function classNameScalar($class_name, $colon_node) { $node = new ClassNameScalarNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $this->mustMatch(T_CLASS, $node, NULL, TRUE); return $node; }
php
private function classNameScalar($class_name, $colon_node) { $node = new ClassNameScalarNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $this->mustMatch(T_CLASS, $node, NULL, TRUE); return $node; }
[ "private", "function", "classNameScalar", "(", "$", "class_name", ",", "$", "colon_node", ")", "{", "$", "node", "=", "new", "ClassNameScalarNode", "(", ")", ";", "$", "node", "->", "addChild", "(", "$", "class_name", ",", "'className'", ")", ";", "$", "...
Construct a class name scalar. @param $class_name @param $colon_node @return ClassNameScalarNode
[ "Construct", "a", "class", "name", "scalar", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1806-L1812
train
grom358/pharborist
src/Parser.php
Parser.variable
private function variable() { switch ($this->currentType) { case T_STRING: case T_NS_SEPARATOR: case T_NAMESPACE: $namespace_path = $this->name(); if ($this->currentType === '(') { return $this->functionCall($namespace_path); } elseif ($this->currentType === T_DOUBLE_COLON) { return $this->varClass($namespace_path); } break; case T_STATIC: $class_name = $this->mustMatchToken(T_STATIC); return $this->varClass($class_name); case '$': case T_VARIABLE: $var = $this->indirectReference(); if ($this->currentType === '(') { return $this->functionCall($var, TRUE); } elseif (!($var instanceof VariableVariableNode) && $this->currentType === T_DOUBLE_COLON) { return $this->varClass($var); } else { return $this->objectDereference($var); } } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "expected variable"); }
php
private function variable() { switch ($this->currentType) { case T_STRING: case T_NS_SEPARATOR: case T_NAMESPACE: $namespace_path = $this->name(); if ($this->currentType === '(') { return $this->functionCall($namespace_path); } elseif ($this->currentType === T_DOUBLE_COLON) { return $this->varClass($namespace_path); } break; case T_STATIC: $class_name = $this->mustMatchToken(T_STATIC); return $this->varClass($class_name); case '$': case T_VARIABLE: $var = $this->indirectReference(); if ($this->currentType === '(') { return $this->functionCall($var, TRUE); } elseif (!($var instanceof VariableVariableNode) && $this->currentType === T_DOUBLE_COLON) { return $this->varClass($var); } else { return $this->objectDereference($var); } } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "expected variable"); }
[ "private", "function", "variable", "(", ")", "{", "switch", "(", "$", "this", "->", "currentType", ")", "{", "case", "T_STRING", ":", "case", "T_NS_SEPARATOR", ":", "case", "T_NAMESPACE", ":", "$", "namespace_path", "=", "$", "this", "->", "name", "(", "...
Parse variable. @return Node @throws ParserException
[ "Parse", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1870-L1904
train
grom358/pharborist
src/Parser.php
Parser.varClass
private function varClass(Node $class_name) { $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_STRING) { $method_name = $this->mustMatchToken(T_STRING); return $this->classMethodCall($class_name, $colon_node, $method_name); } else { return $this->classVariable($class_name, $colon_node); } }
php
private function varClass(Node $class_name) { $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_STRING) { $method_name = $this->mustMatchToken(T_STRING); return $this->classMethodCall($class_name, $colon_node, $method_name); } else { return $this->classVariable($class_name, $colon_node); } }
[ "private", "function", "varClass", "(", "Node", "$", "class_name", ")", "{", "$", "colon_node", "=", "new", "PartialNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "T_DOUBLE_COLON", ",", "$", "colon_node", ")", ";", "if", "(", "$", "this", "...
Parse variable given class name. @param Node $class_name @return Node
[ "Parse", "variable", "given", "class", "name", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1911-L1921
train
grom358/pharborist
src/Parser.php
Parser.functionCall
private function functionCall(Node $function_reference, $dynamic = FALSE) { if ($dynamic) { $node = new CallbackCallNode(); $node->addChild($function_reference, 'callback'); } else { if ($function_reference instanceof NameNode && $function_reference->childCount() === 1 && $function_reference == 'define') { $node = new DefineNode(); } else { $node = new FunctionCallNode(); } $node->addChild($function_reference, 'name'); } $this->functionCallParameterList($node); return $this->objectDereference($this->arrayDeference($node)); }
php
private function functionCall(Node $function_reference, $dynamic = FALSE) { if ($dynamic) { $node = new CallbackCallNode(); $node->addChild($function_reference, 'callback'); } else { if ($function_reference instanceof NameNode && $function_reference->childCount() === 1 && $function_reference == 'define') { $node = new DefineNode(); } else { $node = new FunctionCallNode(); } $node->addChild($function_reference, 'name'); } $this->functionCallParameterList($node); return $this->objectDereference($this->arrayDeference($node)); }
[ "private", "function", "functionCall", "(", "Node", "$", "function_reference", ",", "$", "dynamic", "=", "FALSE", ")", "{", "if", "(", "$", "dynamic", ")", "{", "$", "node", "=", "new", "CallbackCallNode", "(", ")", ";", "$", "node", "->", "addChild", ...
Apply any function call, array and object deference. @param Node $function_reference @param bool $dynamic TRUE if the function call is dynamic @return Node
[ "Apply", "any", "function", "call", "array", "and", "object", "deference", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1929-L1945
train
grom358/pharborist
src/Parser.php
Parser.objectDereference
private function objectDereference(Node $object) { while ($this->currentType === T_OBJECT_OPERATOR) { $operator_node = new PartialNode(); $this->mustMatch(T_OBJECT_OPERATOR, $operator_node, 'operator'); $object_property = $this->objectProperty(); if ($this->currentType === '(') { $node = new ObjectMethodCallNode(); $node->addChild($object, 'object'); $node->mergeNode($operator_node); $node->addChild($object_property, 'methodName'); $this->functionCallParameterList($node); $node = $this->arrayDeference($node); } else { $node = new ObjectPropertyNode(); $node->addChild($object, 'object'); $node->mergeNode($operator_node); $node->addChild($object_property, 'property'); $node = $this->offsetVariable($node); if ($this->currentType === '(') { $call = new CallbackCallNode(); $call->addChild($node, 'callback'); $this->functionCallParameterList($call); $node = $this->arrayDeference($call); } } $object = $node; } return $object; }
php
private function objectDereference(Node $object) { while ($this->currentType === T_OBJECT_OPERATOR) { $operator_node = new PartialNode(); $this->mustMatch(T_OBJECT_OPERATOR, $operator_node, 'operator'); $object_property = $this->objectProperty(); if ($this->currentType === '(') { $node = new ObjectMethodCallNode(); $node->addChild($object, 'object'); $node->mergeNode($operator_node); $node->addChild($object_property, 'methodName'); $this->functionCallParameterList($node); $node = $this->arrayDeference($node); } else { $node = new ObjectPropertyNode(); $node->addChild($object, 'object'); $node->mergeNode($operator_node); $node->addChild($object_property, 'property'); $node = $this->offsetVariable($node); if ($this->currentType === '(') { $call = new CallbackCallNode(); $call->addChild($node, 'callback'); $this->functionCallParameterList($call); $node = $this->arrayDeference($call); } } $object = $node; } return $object; }
[ "private", "function", "objectDereference", "(", "Node", "$", "object", ")", "{", "while", "(", "$", "this", "->", "currentType", "===", "T_OBJECT_OPERATOR", ")", "{", "$", "operator_node", "=", "new", "PartialNode", "(", ")", ";", "$", "this", "->", "must...
Apply any object dereference to object operand. @param Node $object @return Node
[ "Apply", "any", "object", "dereference", "to", "object", "operand", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1952-L1983
train
grom358/pharborist
src/Parser.php
Parser.objectProperty
private function objectProperty() { if ($this->currentType === T_STRING) { return $this->mustMatchToken(T_STRING); } elseif ($this->currentType === '{') { return $this->bracesExpr(); } else { return $this->indirectReference(); } }
php
private function objectProperty() { if ($this->currentType === T_STRING) { return $this->mustMatchToken(T_STRING); } elseif ($this->currentType === '{') { return $this->bracesExpr(); } else { return $this->indirectReference(); } }
[ "private", "function", "objectProperty", "(", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "T_STRING", ")", "{", "return", "$", "this", "->", "mustMatchToken", "(", "T_STRING", ")", ";", "}", "elseif", "(", "$", "this", "->", "currentTyp...
Parse object property. @return Node
[ "Parse", "object", "property", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L1989-L1999
train
grom358/pharborist
src/Parser.php
Parser.indirectReference
private function indirectReference() { if ($this->currentType === '$' && !$this->isLookAhead('{')) { $node = new VariableVariableNode(); $this->mustMatch('$', $node); $node->addChild($this->indirectReference(), 'variable'); return $node; } return $this->referenceVariable(); }
php
private function indirectReference() { if ($this->currentType === '$' && !$this->isLookAhead('{')) { $node = new VariableVariableNode(); $this->mustMatch('$', $node); $node->addChild($this->indirectReference(), 'variable'); return $node; } return $this->referenceVariable(); }
[ "private", "function", "indirectReference", "(", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "'$'", "&&", "!", "$", "this", "->", "isLookAhead", "(", "'{'", ")", ")", "{", "$", "node", "=", "new", "VariableVariableNode", "(", ")", ";"...
Parse indirect variable reference. @return Node
[ "Parse", "indirect", "variable", "reference", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L2005-L2013
train
grom358/pharborist
src/Parser.php
Parser.offsetVariable
private function offsetVariable(Node $var) { if ($this->currentType === '{') { $node = new ArrayLookupNode(); $node->addChild($var, 'array'); $this->mustMatch('{', $node); $node->addChild($this->expr(), 'key'); $this->mustMatch('}', $node, NULL, TRUE); return $this->offsetVariable($node); } elseif ($this->currentType === '[') { $node = new ArrayLookupNode(); $node->addChild($var, 'array'); $this->dimOffset($node); return $this->offsetVariable($node); } else { return $var; } }
php
private function offsetVariable(Node $var) { if ($this->currentType === '{') { $node = new ArrayLookupNode(); $node->addChild($var, 'array'); $this->mustMatch('{', $node); $node->addChild($this->expr(), 'key'); $this->mustMatch('}', $node, NULL, TRUE); return $this->offsetVariable($node); } elseif ($this->currentType === '[') { $node = new ArrayLookupNode(); $node->addChild($var, 'array'); $this->dimOffset($node); return $this->offsetVariable($node); } else { return $var; } }
[ "private", "function", "offsetVariable", "(", "Node", "$", "var", ")", "{", "if", "(", "$", "this", "->", "currentType", "===", "'{'", ")", "{", "$", "node", "=", "new", "ArrayLookupNode", "(", ")", ";", "$", "node", "->", "addChild", "(", "$", "var"...
Apply any offset to variable. @param Node $var @return Node
[ "Apply", "any", "offset", "to", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L2028-L2046
train
grom358/pharborist
src/Parser.php
Parser._compoundVariable
private function _compoundVariable() { $node = new CompoundVariableNode(); $this->mustMatch('$', $node); $this->mustMatch('{', $node); $node->addChild($this->expr(), 'expression'); $this->mustMatch('}', $node, NULL, TRUE); return $node; }
php
private function _compoundVariable() { $node = new CompoundVariableNode(); $this->mustMatch('$', $node); $this->mustMatch('{', $node); $node->addChild($this->expr(), 'expression'); $this->mustMatch('}', $node, NULL, TRUE); return $node; }
[ "private", "function", "_compoundVariable", "(", ")", "{", "$", "node", "=", "new", "CompoundVariableNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "'$'", ",", "$", "node", ")", ";", "$", "this", "->", "mustMatch", "(", "'{'", ",", "$", "...
Parse compound variable. @return CompoundVariableNode
[ "Parse", "compound", "variable", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L2065-L2072
train
grom358/pharborist
src/Parser.php
Parser.bracesExpr
private function bracesExpr() { $node = new NameExpressionNode(); $this->mustMatch('{', $node); $node->addChild($this->expr()); $this->mustMatch('}', $node, NULL, TRUE); return $node; }
php
private function bracesExpr() { $node = new NameExpressionNode(); $this->mustMatch('{', $node); $node->addChild($this->expr()); $this->mustMatch('}', $node, NULL, TRUE); return $node; }
[ "private", "function", "bracesExpr", "(", ")", "{", "$", "node", "=", "new", "NameExpressionNode", "(", ")", ";", "$", "this", "->", "mustMatch", "(", "'{'", ",", "$", "node", ")", ";", "$", "node", "->", "addChild", "(", "$", "this", "->", "expr", ...
Parse braces expression. @return NameExpressionNode
[ "Parse", "braces", "expression", "." ]
0db9e51299a80e95b06857ed1809f59bbbab1af6
https://github.com/grom358/pharborist/blob/0db9e51299a80e95b06857ed1809f59bbbab1af6/src/Parser.php#L2078-L2084
train