From 77983d8e20e614bf06648b205bfb611a619564ad Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 10 Nov 2014 19:14:58 +0100 Subject: [PATCH] Changed and/or to &&/|| --- src/Controllers/AuthController.php | 2 +- src/Controllers/CommentController.php | 2 +- src/Controllers/ViewProxies/CommentViewProxy.php | 2 +- src/Controllers/ViewProxies/PostViewProxy.php | 2 +- src/Dao/AbstractDao.php | 4 ++-- src/Dao/TagDao.php | 2 +- src/Dao/TokenDao.php | 2 +- src/Dao/UserDao.php | 2 +- src/FormData/UploadFormData.php | 2 +- src/Helpers/InputReader.php | 2 +- src/Helpers/MimeHelper.php | 8 ++++---- src/Helpers/TypeHelper.php | 2 +- src/PDOEx/SelectQuery.php | 4 ++-- .../Parsers/AbstractSearchParser.php | 6 +++--- src/SearchServices/Parsers/PostSearchParser.php | 14 +++++++------- src/SearchServices/Parsers/TagSearchParser.php | 2 +- src/SearchServices/Parsers/UserSearchParser.php | 2 +- src/Services/AuthService.php | 2 +- src/Services/HistoryService.php | 4 ++-- src/Services/ImageConverter.php | 4 ++-- src/Services/NetworkingService.php | 4 ++-- src/Services/PostFeatureService.php | 2 +- src/Services/PostService.php | 6 +++--- src/Services/PostSnapshotProvider.php | 2 +- src/Services/PrivilegeService.php | 2 +- src/Services/ScoreService.php | 4 ++-- src/Services/TagService.php | 2 +- src/Services/ThumbnailService.php | 4 ++-- src/Services/UserService.php | 4 ++-- tests/Services/ImageManipulatorTest.php | 2 +- 30 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index cbc5939f..d8d90cff 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -46,7 +46,7 @@ final class AuthController extends AbstractController public function login() { - if (isset($this->inputReader->userNameOrEmail) and isset($this->inputReader->password)) + if (isset($this->inputReader->userNameOrEmail) && isset($this->inputReader->password)) { $formData = new LoginFormData($this->inputReader); $this->authService->loginFromCredentials($formData); diff --git a/src/Controllers/CommentController.php b/src/Controllers/CommentController.php index 0db4537d..03416b08 100644 --- a/src/Controllers/CommentController.php +++ b/src/Controllers/CommentController.php @@ -125,7 +125,7 @@ final class CommentController extends AbstractController $comment = $this->commentService->getById($commentId); $this->privilegeService->assertPrivilege( - ($comment->getUser() and $this->privilegeService->isLoggedIn($comment->getUser())) + ($comment->getUser() && $this->privilegeService->isLoggedIn($comment->getUser())) ? Privilege::EDIT_OWN_COMMENTS : Privilege::EDIT_ALL_COMMENTS); diff --git a/src/Controllers/ViewProxies/CommentViewProxy.php b/src/Controllers/ViewProxies/CommentViewProxy.php index 92259b82..442c3365 100644 --- a/src/Controllers/ViewProxies/CommentViewProxy.php +++ b/src/Controllers/ViewProxies/CommentViewProxy.php @@ -34,7 +34,7 @@ class CommentViewProxy extends AbstractViewProxy $result->user = $this->userViewProxy->fromEntity($comment->getUser()); $result->score = $comment->getScore(); - if (!empty($config[self::FETCH_OWN_SCORE]) and $this->authService->isLoggedIn()) + if (!empty($config[self::FETCH_OWN_SCORE]) && $this->authService->isLoggedIn()) $result->ownScore = $this->scoreService->getUserScoreValue($this->authService->getLoggedInUser(), $comment); } return $result; diff --git a/src/Controllers/ViewProxies/PostViewProxy.php b/src/Controllers/ViewProxies/PostViewProxy.php index 2896d3a7..5be84d06 100644 --- a/src/Controllers/ViewProxies/PostViewProxy.php +++ b/src/Controllers/ViewProxies/PostViewProxy.php @@ -107,7 +107,7 @@ class PostViewProxy extends AbstractViewProxy $result->history = []; } - if (!empty($config[self::FETCH_OWN_SCORE]) and $this->authService->isLoggedIn()) + if (!empty($config[self::FETCH_OWN_SCORE]) && $this->authService->isLoggedIn()) $result->ownScore = $this->scoreService->getUserScoreValue($this->authService->getLoggedInUser(), $post); if (!empty($config[self::FETCH_FAVORITES])) diff --git a/src/Dao/AbstractDao.php b/src/Dao/AbstractDao.php index 1dcd7523..f46aeec2 100644 --- a/src/Dao/AbstractDao.php +++ b/src/Dao/AbstractDao.php @@ -154,7 +154,7 @@ abstract class AbstractDao implements ICrudDao, IBatchDao protected function findBy($columnName, $value) { - if (is_array($value) and empty($value)) + if (is_array($value) && empty($value)) return []; $query = $this->pdo->from($this->tableName)->where($columnName, $value); $arrayEntities = iterator_to_array($query); @@ -210,7 +210,7 @@ abstract class AbstractDao implements ICrudDao, IBatchDao else if ($value instanceof RequirementRangedValue) { - if ($value->getMinValue() and $value->getMaxValue()) + if ($value->getMinValue() && $value->getMaxValue()) { $sql = $sqlColumn . ' >= ? AND ' . $sqlColumn . ' <= ?'; $bindings = [$value->getMinValue(), $value->getMaxValue()]; diff --git a/src/Dao/TagDao.php b/src/Dao/TagDao.php index 7f5d4d81..dc46ce4a 100644 --- a/src/Dao/TagDao.php +++ b/src/Dao/TagDao.php @@ -103,7 +103,7 @@ class TagDao extends AbstractDao implements ICrudDao else continue; - if (!isset($exported[$key1]) or !isset($exported[$key2])) + if (!isset($exported[$key1]) || !isset($exported[$key2])) continue; if (!isset($exported[$key1][$target])) diff --git a/src/Dao/TokenDao.php b/src/Dao/TokenDao.php index 7a75a144..07130d8c 100644 --- a/src/Dao/TokenDao.php +++ b/src/Dao/TokenDao.php @@ -25,7 +25,7 @@ class TokenDao extends AbstractDao ->where('purpose', $purpose); $arrayEntities = iterator_to_array($query); $entities = $this->arrayToEntities($arrayEntities); - if (!$entities or !count($entities)) + if (!$entities || !count($entities)) return null; $entity = array_shift($entities); return $entity; diff --git a/src/Dao/UserDao.php b/src/Dao/UserDao.php index 3bfe0bab..e5bd78b3 100644 --- a/src/Dao/UserDao.php +++ b/src/Dao/UserDao.php @@ -37,7 +37,7 @@ class UserDao extends AbstractDao implements ICrudDao public function findByEmail($userEmail, $allowUnconfirmed = false) { $result = $this->findOneBy('email', $userEmail); - if (!$result and $allowUnconfirmed) + if (!$result && $allowUnconfirmed) { $result = $this->findOneBy('emailUnconfirmed', $userEmail); } diff --git a/src/FormData/UploadFormData.php b/src/FormData/UploadFormData.php index 674d8706..b5500fcb 100644 --- a/src/FormData/UploadFormData.php +++ b/src/FormData/UploadFormData.php @@ -30,7 +30,7 @@ class UploadFormData implements IValidatable public function validate(Validator $validator) { - if ($this->content === null and $this->url === null) + if ($this->content === null && $this->url === null) throw new \DomainException('Neither data or URL provided.'); $validator->validatePostTags($this->tags); diff --git a/src/Helpers/InputReader.php b/src/Helpers/InputReader.php index a47d9c08..b366a8aa 100644 --- a/src/Helpers/InputReader.php +++ b/src/Helpers/InputReader.php @@ -8,7 +8,7 @@ final class InputReader extends \ArrayObject parent::setFlags(parent::ARRAY_AS_PROPS | parent::STD_PROP_LIST); $_PUT = []; - if (isset($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] === 'PUT') + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') parse_str(file_get_contents('php://input'), $_PUT); foreach ([$_GET, $_POST, $_PUT] as $source) diff --git a/src/Helpers/MimeHelper.php b/src/Helpers/MimeHelper.php index 92666d99..8d9166a2 100644 --- a/src/Helpers/MimeHelper.php +++ b/src/Helpers/MimeHelper.php @@ -25,7 +25,7 @@ class MimeHelper public static function isVideo($mime) { - return strtolower($mime) === 'application/ogg' or preg_match('/video\//i', $mime); + return strtolower($mime) === 'application/ogg' || preg_match('/video\//i', $mime); } public static function isImage($mime) @@ -59,7 +59,7 @@ class MimeHelper if ($bytes === false) return false; - if (strncmp($bytes, 'CWS', 3) === 0 or strncmp($bytes, 'FWS', 3) === 0 or strncmp($bytes, 'ZWS', 3) === 0) + if (strncmp($bytes, 'CWS', 3) === 0 || strncmp($bytes, 'FWS', 3) === 0 || strncmp($bytes, 'ZWS', 3) === 0) return 'application/x-shockwave-flash'; if (strncmp($bytes, "\xff\xd8\xff", 3) === 0) @@ -68,13 +68,13 @@ class MimeHelper if (strncmp($bytes, "\x89PNG\x0d\x0a", 6) === 0) return 'image/png'; - if (strncmp($bytes, 'GIF87a', 6) === 0 or strncmp($bytes, 'GIF89a', 6) === 0) + if (strncmp($bytes, 'GIF87a', 6) === 0 || strncmp($bytes, 'GIF89a', 6) === 0) return 'image/gif'; if (strncmp($bytes, "\x1a\x45\xdf\xa3", 4) === 0) return 'video/webm'; - if (strncmp(substr($bytes, 4), 'ftypisom', 8) === 0 or strncmp(substr($bytes, 4), 'ftypmp42', 8) === 0) + if (strncmp(substr($bytes, 4), 'ftypisom', 8) === 0 || strncmp(substr($bytes, 4), 'ftypmp42', 8) === 0) return 'video/mp4'; if (strncmp($bytes, "\x46\x4c\x56\x01", 4) === 0) diff --git a/src/Helpers/TypeHelper.php b/src/Helpers/TypeHelper.php index 44bdd109..ea1354f9 100644 --- a/src/Helpers/TypeHelper.php +++ b/src/Helpers/TypeHelper.php @@ -11,7 +11,7 @@ class TypeHelper return false; if ($value === false) return false; - if (is_array($value) and count($value) === 1) + if (is_array($value) && count($value) === 1) return false; if ($value === null) return false; diff --git a/src/PDOEx/SelectQuery.php b/src/PDOEx/SelectQuery.php index 71386900..e19e282e 100644 --- a/src/PDOEx/SelectQuery.php +++ b/src/PDOEx/SelectQuery.php @@ -10,7 +10,7 @@ class SelectQuery extends BaseQuery implements \Countable public function limit($limit) { - if ($limit === null or $limit === false) + if ($limit === null || $limit === false) $this->limit = null; else $this->limit = intval($limit); @@ -87,7 +87,7 @@ class SelectQuery extends BaseQuery implements \Countable if ($this->limit !== null) { $sql .= 'LIMIT ' . $this->limit; - if ($this->offset !== null and $this->offset !== 0) + if ($this->offset !== null && $this->offset !== 0) $sql .= ' OFFSET ' . intval($this->offset); } $this->clauses[self::CLAUSE_LIMIT] = $sql; diff --git a/src/SearchServices/Parsers/AbstractSearchParser.php b/src/SearchServices/Parsers/AbstractSearchParser.php index e35d944b..f93680ea 100644 --- a/src/SearchServices/Parsers/AbstractSearchParser.php +++ b/src/SearchServices/Parsers/AbstractSearchParser.php @@ -63,7 +63,7 @@ abstract class AbstractSearchParser }; } - if ((($flags & self::ALLOW_RANGES) === self::ALLOW_RANGES) and substr_count($text, '..') === 1) + if ((($flags & self::ALLOW_RANGES) === self::ALLOW_RANGES) && substr_count($text, '..') === 1) { list ($minValue, $maxValue) = explode('..', $text); $minValue = $valueDecorator($minValue); @@ -73,7 +73,7 @@ abstract class AbstractSearchParser $tokenValue->setMaxValue($maxValue); return $tokenValue; } - else if ((($flags & self::ALLOW_COMPOSITE) === self::ALLOW_COMPOSITE) and strpos($text, ',') !== false) + else if ((($flags & self::ALLOW_COMPOSITE) === self::ALLOW_COMPOSITE) && strpos($text, ',') !== false) { $values = explode(',', $text); $values = array_map($valueDecorator, $values); @@ -145,7 +145,7 @@ abstract class AbstractSearchParser } $colonPosition = strpos($tokenText, ':'); - if (($colonPosition !== false) and ($colonPosition > 0)) + if (($colonPosition !== false) && ($colonPosition > 0)) { $searchToken = new NamedSearchToken(); list ($tokenKey, $tokenValue) = explode(':', $tokenText, 2); diff --git a/src/SearchServices/Parsers/PostSearchParser.php b/src/SearchServices/Parsers/PostSearchParser.php index 10fb0654..cb9fc1b0 100644 --- a/src/SearchServices/Parsers/PostSearchParser.php +++ b/src/SearchServices/Parsers/PostSearchParser.php @@ -76,19 +76,19 @@ class PostSearchParser extends AbstractSearchParser elseif ($token->getKey() === 'comment') $this->addCommentRequirement($filter, $token); - elseif ($token->getKey() === 'special' and $token->getValue() === 'liked') + elseif ($token->getKey() === 'special' && $token->getValue() === 'liked') { $this->privilegeService->assertLoggedIn(); $this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), 1, $token->isNegated()); } - elseif ($token->getKey() === 'special' and $token->getValue() === 'disliked') + elseif ($token->getKey() === 'special' && $token->getValue() === 'disliked') { $this->privilegeService->assertLoggedIn(); $this->addUserScoreRequirement($filter, $this->authService->getLoggedInUser()->getName(), -1, $token->isNegated()); } - elseif ($token->getKey() === 'special' and $token->getValue() === 'fav') + elseif ($token->getKey() === 'special' && $token->getValue() === 'fav') { $this->privilegeService->assertLoggedIn(); $token = new NamedSearchToken(); @@ -109,7 +109,7 @@ class PostSearchParser extends AbstractSearchParser elseif ($tokenText === 'id') return PostFilter::ORDER_ID; - elseif ($tokenText === 'time' or $tokenText === 'date') + elseif ($tokenText === 'time' || $tokenText === 'date') return PostFilter::ORDER_LAST_EDIT_TIME; elseif ($tokenText === 'score') @@ -127,13 +127,13 @@ class PostSearchParser extends AbstractSearchParser elseif ($tokenText === 'comment_count') return PostFilter::ORDER_COMMENT_COUNT; - elseif ($tokenText === 'fav_time' or $tokenText === 'fav_date') + elseif ($tokenText === 'fav_time' || $tokenText === 'fav_date') return PostFilter::ORDER_LAST_FAV_TIME; - elseif ($tokenText === 'comment_time' or $tokenText === 'comment_date') + elseif ($tokenText === 'comment_time' || $tokenText === 'comment_date') return PostFilter::ORDER_LAST_COMMENT_TIME; - elseif ($tokenText === 'feature_time' or $tokenText === 'feature_date') + elseif ($tokenText === 'feature_time' || $tokenText === 'feature_date') return PostFilter::ORDER_LAST_FEATURE_TIME; else diff --git a/src/SearchServices/Parsers/TagSearchParser.php b/src/SearchServices/Parsers/TagSearchParser.php index 64d6e36c..3206b787 100644 --- a/src/SearchServices/Parsers/TagSearchParser.php +++ b/src/SearchServices/Parsers/TagSearchParser.php @@ -47,7 +47,7 @@ class TagSearchParser extends AbstractSearchParser elseif ($tokenText === 'name') return TagFilter::ORDER_NAME; - elseif ($tokenText === 'creation_time' or $tokenText === 'creation_date') + elseif ($tokenText === 'creation_time' || $tokenText === 'creation_date') return TagFilter::ORDER_CREATION_TIME; elseif ($tokenText === 'usage_count') diff --git a/src/SearchServices/Parsers/UserSearchParser.php b/src/SearchServices/Parsers/UserSearchParser.php index 2ecd2cd6..fb07e298 100644 --- a/src/SearchServices/Parsers/UserSearchParser.php +++ b/src/SearchServices/Parsers/UserSearchParser.php @@ -28,7 +28,7 @@ class UserSearchParser extends AbstractSearchParser if ($tokenText === 'name') return UserFilter::ORDER_NAME; - elseif ($tokenText === 'registration_time' or $tokenText === 'registration_date') + elseif ($tokenText === 'registration_time' || $tokenText === 'registration_date') return UserFilter::ORDER_REGISTRATION_TIME; else diff --git a/src/Services/AuthService.php b/src/Services/AuthService.php index 9cdd502e..e5ce8fd4 100644 --- a/src/Services/AuthService.php +++ b/src/Services/AuthService.php @@ -110,7 +110,7 @@ class AuthService private function doFinalChecksOnUser($user) { - if (!$user->isAccountConfirmed() and $this->config->security->needEmailActivationToRegister) + if (!$user->isAccountConfirmed() && $this->config->security->needEmailActivationToRegister) throw new \DomainException('User didn\'t confirm account yet.'); if ($user->isBanned()) diff --git a/src/Services/HistoryService.php b/src/Services/HistoryService.php index 90c2d777..24af14ff 100644 --- a/src/Services/HistoryService.php +++ b/src/Services/HistoryService.php @@ -73,11 +73,11 @@ class HistoryService { foreach ($base[$key] as $subValue) { - if (!isset($other[$key]) or !in_array($subValue, $other[$key])) + if (!isset($other[$key]) || !in_array($subValue, $other[$key])) $result[] = [$key, $subValue]; } } - elseif (!isset($other[$key]) or $base[$key] !== $other[$key]) + elseif (!isset($other[$key]) || $base[$key] !== $other[$key]) { $result[] = [$key, $value]; } diff --git a/src/Services/ImageConverter.php b/src/Services/ImageConverter.php index 12128a1f..c2d53d77 100644 --- a/src/Services/ImageConverter.php +++ b/src/Services/ImageConverter.php @@ -70,7 +70,7 @@ class ImageConverter ]); } - if (!file_exists($targetPath) and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_SWFRENDER)) + if (!file_exists($targetPath) && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_SWFRENDER)) { ProgramExecutor::run( self::PROGRAM_NAME_SWFRENDER, @@ -100,7 +100,7 @@ class ImageConverter ]); } - if (!file_exists($targetPath) and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_FFMPEG)) + if (!file_exists($targetPath) && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_FFMPEG)) { ProgramExecutor::run(self::PROGRAM_NAME_FFMEPG, [ diff --git a/src/Services/NetworkingService.php b/src/Services/NetworkingService.php index 1a60c0a6..4b5ec39b 100644 --- a/src/Services/NetworkingService.php +++ b/src/Services/NetworkingService.php @@ -37,7 +37,7 @@ class NetworkingService if ($customFileName) $this->httpHelper->setHeader('Content-Disposition', 'inline; filename="' . $customFileName . '"'); - if (strtotime($ifModifiedSince) === $lastModified or $eTagHeader === $eTag) + if (strtotime($ifModifiedSince) === $lastModified || $eTagHeader === $eTag) { $this->httpHelper->setResponseCode(304); } @@ -70,7 +70,7 @@ class NetworkingService while (!feof($srcHandle)) { $buffer = fread($srcHandle, 4 * 1024); - if ($maxBytes !== null and strlen($result) > $maxBytes) + if ($maxBytes !== null && strlen($result) > $maxBytes) { throw new \Exception( 'File is too big (maximum size: %s)', diff --git a/src/Services/PostFeatureService.php b/src/Services/PostFeatureService.php index 17486596..0a1835a9 100644 --- a/src/Services/PostFeatureService.php +++ b/src/Services/PostFeatureService.php @@ -69,7 +69,7 @@ class PostFeatureService { $previousFeaturedPost = $this->getFeaturedPost(); - if (($previousFeaturedPost === null) or ($previousFeaturedPost->getId() !== $post->getId())) + if (($previousFeaturedPost === null) || ($previousFeaturedPost->getId() !== $post->getId())) { $post->setLastFeatureTime($this->timeService->getCurrentTime()); $post->setFeatureCount($post->getFeatureCount() + 1); diff --git a/src/Services/PostService.php b/src/Services/PostService.php index 93f67659..86d7c7f4 100644 --- a/src/Services/PostService.php +++ b/src/Services/PostService.php @@ -342,7 +342,7 @@ class PostService if (!$userSettings) return; - if (!empty($userSettings->listPosts) and !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_SAFETY))) + if (!empty($userSettings->listPosts) && !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_SAFETY))) { $values = []; if (!TypeHelper::toBool($userSettings->listPosts->safe)) @@ -363,7 +363,7 @@ class PostService } } - if (!empty($userSettings->hideDownvoted) and !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_USER_SCORE))) + if (!empty($userSettings->hideDownvoted) && !count($filter->getRequirementsByType(PostFilter::REQUIREMENT_USER_SCORE))) { $requirementValue = new RequirementCompositeValue(); $requirementValue->setValues([$currentUser->getName(), -1]); @@ -379,7 +379,7 @@ class PostService { $checksumToCheck = $parent->getContentChecksum(); $postWithThisChecksum = $this->postDao->findByContentChecksum($checksumToCheck); - if ($postWithThisChecksum and $postWithThisChecksum->getId() !== $parent->getId()) + if ($postWithThisChecksum && $postWithThisChecksum->getId() !== $parent->getId()) throw new \DomainException('Duplicate post: ' . $postWithThisChecksum->getIdMarkdown()); } diff --git a/src/Services/PostSnapshotProvider.php b/src/Services/PostSnapshotProvider.php index 8fec8680..a8458a2d 100644 --- a/src/Services/PostSnapshotProvider.php +++ b/src/Services/PostSnapshotProvider.php @@ -60,7 +60,7 @@ class PostSnapshotProvider implements ISnapshotProvider static $featuredPostParam = null; if ($featuredPostParam === null) $featuredPostParam = $this->globalParamDao->findByKey(GlobalParam::KEY_FEATURED_POST); - $isFeatured = ($featuredPostParam and intval($featuredPostParam->getValue()) === $post->getId()); + $isFeatured = ($featuredPostParam && intval($featuredPostParam->getValue()) === $post->getId()); $flags = []; if ($post->getFlags() & Post::FLAG_LOOP) diff --git a/src/Services/PrivilegeService.php b/src/Services/PrivilegeService.php index 0e030575..744301a0 100644 --- a/src/Services/PrivilegeService.php +++ b/src/Services/PrivilegeService.php @@ -70,7 +70,7 @@ class PrivilegeService $loggedInUser = $this->authService->getLoggedInUser(); if ($userIdentifier instanceof User) { - return $loggedInUser->getId() and ($loggedInUser->getId() === $userIdentifier->getId()); + return $loggedInUser->getId() && ($loggedInUser->getId() === $userIdentifier->getId()); } elseif (is_string($userIdentifier)) { diff --git a/src/Services/ScoreService.php b/src/Services/ScoreService.php index 8c095476..df8ed3ca 100644 --- a/src/Services/ScoreService.php +++ b/src/Services/ScoreService.php @@ -59,12 +59,12 @@ class ScoreService public function setUserScore(User $user, Entity $entity, $scoreValue) { - if ($scoreValue !== 1 and $scoreValue !== 0 and $scoreValue !== -1) + if ($scoreValue !== 1 && $scoreValue !== 0 && $scoreValue !== -1) throw new \DomainException('Bad score'); $transactionFunc = function() use ($user, $entity, $scoreValue) { - if (($scoreValue !== 1) and ($entity instanceof Post)) + if (($scoreValue !== 1) && ($entity instanceof Post)) $this->favoritesDao->delete($user, $entity); return $this->scoreDao->setUserScore($user, $entity, $scoreValue); diff --git a/src/Services/TagService.php b/src/Services/TagService.php index a7de8457..57fc70b5 100644 --- a/src/Services/TagService.php +++ b/src/Services/TagService.php @@ -212,7 +212,7 @@ class TagService private function updateTagName(Tag $tag, $newName) { $otherTag = $this->tagDao->findByName($newName); - if ($otherTag and $otherTag->getId() !== $tag->getId()) + if ($otherTag && $otherTag->getId() !== $tag->getId()) throw new \DomainException('Tag with this name already exists.'); $tag->setName($newName); } diff --git a/src/Services/ThumbnailService.php b/src/Services/ThumbnailService.php index f0508576..ba6d422d 100644 --- a/src/Services/ThumbnailService.php +++ b/src/Services/ThumbnailService.php @@ -114,7 +114,7 @@ class ThumbnailService { $sourcePath = $this->fileDao->getFullPath($sourceName); - if ($format === IImageManipulator::FORMAT_JPEG and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_JPEGOPTIM)) + if ($format === IImageManipulator::FORMAT_JPEG && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_JPEGOPTIM)) { ProgramExecutor::run( self::PROGRAM_NAME_JPEGOPTIM, @@ -125,7 +125,7 @@ class ThumbnailService ]); } - elseif ($format === IImageManipulator::FORMAT_PNG and ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_OPTIPNG)) + elseif ($format === IImageManipulator::FORMAT_PNG && ProgramExecutor::isProgramAvailable(self::PROGRAM_NAME_OPTIPNG)) { ProgramExecutor::run( self::PROGRAM_NAME_OPTIPNG, diff --git a/src/Services/UserService.php b/src/Services/UserService.php index b95919ea..3b33d5ff 100644 --- a/src/Services/UserService.php +++ b/src/Services/UserService.php @@ -313,7 +313,7 @@ class UserService private function assertNoUserWithThisName(User $owner, $nameToCheck) { $userWithThisName = $this->userDao->findByName($nameToCheck); - if ($userWithThisName and $userWithThisName->getId() !== $owner->getId()) + if ($userWithThisName && $userWithThisName->getId() !== $owner->getId()) throw new \DomainException('User with this name already exists.'); } @@ -322,7 +322,7 @@ class UserService if (!$emailToCheck) return; $userWithThisEmail = $this->userDao->findByEmail($emailToCheck); - if ($userWithThisEmail and $userWithThisEmail->getId() !== $owner->getId()) + if ($userWithThisEmail && $userWithThisEmail->getId() !== $owner->getId()) throw new \DomainException('User with this e-mail already exists.'); } diff --git a/tests/Services/ImageManipulatorTest.php b/tests/Services/ImageManipulatorTest.php index 329fe434..14617f3c 100644 --- a/tests/Services/ImageManipulatorTest.php +++ b/tests/Services/ImageManipulatorTest.php @@ -138,7 +138,7 @@ final class ImageManipulatorTest extends AbstractTestCase private static function getAutoImageManipulator() { - if (extension_loaded('gd') and extension_loaded('imagick')) + if (extension_loaded('gd') && extension_loaded('imagick')) { return new ImageManipulator( self::getImagickImageManipulator(),