From f48b6165e8ba9a17d8bad919c28f4b80ca67a3ad Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 3 Apr 2024 10:23:35 +0200 Subject: [PATCH] fix phpdoc and a bug with AutoSaveSubscriber --- CHANGELOG.md | 6 ++ src/PHPCR/Shell/Console/.gitignore | 1 - .../Application/.ShellApplication.php.swl | Bin 32768 -> 0 bytes .../Shell/Console/Command/BaseCommand.php | 2 +- .../Shell/DependencyInjection/Container.php | 89 ++++++++++++------ src/PHPCR/Shell/Event/Event.php | 11 +-- src/PHPCR/Shell/Phpcr/PhpcrSession.php | 78 ++++++++------- src/PHPCR/Shell/Phpcr/SessionManager.php | 7 +- src/PHPCR/Shell/PhpcrShell.php | 4 +- src/PHPCR/Shell/Query/FunctionOperand.php | 5 +- src/PHPCR/Shell/Query/UpdateParser.php | 2 +- src/PHPCR/Shell/Query/UpdateProcessor.php | 27 +++--- src/PHPCR/Shell/Query/Validator.php | 2 +- src/PHPCR/Shell/Serializer/NodeNormalizer.php | 2 +- .../Shell/Subscriber/AliasSubscriber.php | 4 +- .../Shell/Subscriber/AutoSaveSubscriber.php | 6 ++ .../Transport/Transport/DoctrineDbal.php | 2 +- .../Shell/Transport/Transport/JackalopeFs.php | 3 +- .../Shell/Transport/Transport/Jackrabbit.php | 3 +- .../Transport/TransportRegistryInterface.php | 2 +- 20 files changed, 143 insertions(+), 113 deletions(-) delete mode 100644 src/PHPCR/Shell/Console/.gitignore delete mode 100755 src/PHPCR/Shell/Console/Application/.ShellApplication.php.swl diff --git a/CHANGELOG.md b/CHANGELOG.md index 17596180..8a3becd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ========= +1.6.1 +----- + +- Fixed phpdoc comments +- Fixed AutoSaveSubscriber to actually work + 1.6.0 ----- diff --git a/src/PHPCR/Shell/Console/.gitignore b/src/PHPCR/Shell/Console/.gitignore deleted file mode 100644 index 22d0d82f..00000000 --- a/src/PHPCR/Shell/Console/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor diff --git a/src/PHPCR/Shell/Console/Application/.ShellApplication.php.swl b/src/PHPCR/Shell/Console/Application/.ShellApplication.php.swl deleted file mode 100755 index 77849e0d671c342ab885f056faf4c5860aa007a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI4dyE}deSn7)0(m;vBy9vqPmIxCTVAgnpv7x@@v>gWTkYEGeIyVzxU=`3yLa&2 zncJDUUa!|lN|T5`pnyn~N1ag7K&412QPS{IP(mpo5u$CNP2#p`E264WqgGI&AX?I< z-#K$;?%dbz-U)v+Vy^so_Rh?C{mx^~?=g3N=e1)K;x~7^$KrE|WnFFEK6A^aKd{am zwycuvI&yB96PV69?HH*z}$R&_VpdOa{-*=Jq?yIAT`p(T)iA@`4 zbGhUa$R&_VAeTTcfm{N)1ab-F638X+OC*7?cCK|Z?LEh|xnz!SXgR*we1EGs%9iVI zG~f4_uZ}uAghZm(B6fmg~P_zF%gJ!c;J>r#YP;atY)T$R&_VAeTTc zfm{N)1ab-F638WxOCXm(E`bgbuu=FOl>bYW0+0Vc*8l%|gJt~}{1yBq{4oSD2(O^T ze-G}0d9Yy{ymXOeeFyFa7e-(sJb$5OJp{MGt*{8ga5?NwJj?nI_&z)hPr)Pb0Ne_noou7?l7Q8*udhSB0b;RoRoFv8&E0lI;_rUzga?xU4_so{|&P?66poe*aMXcR|-q z$IFbKkZu?Z4h~OFj*pED&x{>8d~EFS*vxjZMXF2bzR@QrNOf&0nr4hz=xka_ZW6_G z$Uv~Go+}$dY3uf;6zTh{IO~Q8)EQrfb>D4dC54skB12A=c3ArCHnBhSO5UKDp%3kO?}QXVQM$J8c)|&U>j|2>Abs62 z+r^Sp{VQxS>3d~{+zv7AiA8&vtesF4ZP(-)XU-YMLfpZ6OxTT>rlbz@vP_-yWi!LZ z+*&;p6*~~~Qo16L;SOEJrpt@q zoMVTFCq}o6Zdb1zotkDnGI@9I+jJ=n$+UIr%6`XX33S2(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jK}{B&GCzA& zjC{N6{53OOjA@GcH8UOmUqLs23Y7jI|GxiObp7Yxi=f{9pN5^V4YtBn@Dud?7vWL( zGMs^container = $container; } - protected function get($serviceId) + public function get($serviceId) { if (null === $this->container) { throw new \RuntimeException( diff --git a/src/PHPCR/Shell/DependencyInjection/Container.php b/src/PHPCR/Shell/DependencyInjection/Container.php index 1484f93d..e5d00839 100644 --- a/src/PHPCR/Shell/DependencyInjection/Container.php +++ b/src/PHPCR/Shell/DependencyInjection/Container.php @@ -12,9 +12,38 @@ namespace PHPCR\Shell\DependencyInjection; +use DTL\Glob\GlobHelper; +use PHPCR\Shell\Config\Config; +use PHPCR\Shell\Config\ConfigManager; +use PHPCR\Shell\Config\Profile; +use PHPCR\Shell\Config\ProfileLoader; +use PHPCR\Shell\Console\Application\EmbeddedApplication; +use PHPCR\Shell\Console\Application\ShellApplication; +use PHPCR\Shell\Console\Helper\EditorHelper; +use PHPCR\Shell\Console\Helper\NodeHelper; +use PHPCR\Shell\Console\Helper\PathHelper; +use PHPCR\Shell\Console\Helper\RepositoryHelper; +use PHPCR\Shell\Console\Helper\ResultFormatterHelper; +use PHPCR\Shell\Console\Helper\TextHelper; +use PHPCR\Shell\Console\Input\AutoComplete; +use PHPCR\Shell\Phpcr\SessionManager; use PHPCR\Shell\PhpcrShell; +use PHPCR\Shell\Query\UpdateProcessor; +use PHPCR\Shell\Subscriber\AliasSubscriber; +use PHPCR\Shell\Subscriber\ConfigInitSubscriber; +use PHPCR\Shell\Subscriber\ExceptionSubscriber; +use PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber; +use PHPCR\Shell\Subscriber\ProfileLoaderSubscriber; +use PHPCR\Shell\Subscriber\ProfileWriterSubscriber; +use PHPCR\Shell\Transport\Transport\DoctrineDbal; +use PHPCR\Shell\Transport\Transport\JackalopeFs; +use PHPCR\Shell\Transport\Transport\Jackrabbit; +use PHPCR\Shell\Transport\TransportRegistry; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; class Container extends ContainerBuilder { @@ -24,9 +53,9 @@ class Container extends ContainerBuilder * @var array Transports */ protected $transports = [ - 'transport.transport.doctrinedbal' => 'PHPCR\Shell\Transport\Transport\DoctrineDbal', - 'transport.transport.jackrabbit' => 'PHPCR\Shell\Transport\Transport\Jackrabbit', - 'transport.transport.fs' => 'PHPCR\Shell\Transport\Transport\JackalopeFs', + 'transport.transport.doctrinedbal' => DoctrineDbal::class, + 'transport.transport.jackrabbit' => Jackrabbit::class, + 'transport.transport.fs' => JackalopeFs::class, ]; public function __construct($mode = PhpcrShell::MODE_STANDALONE) @@ -46,27 +75,27 @@ public function __construct($mode = PhpcrShell::MODE_STANDALONE) public function registerHelpers() { - $this->register('helper.question', 'Symfony\Component\Console\Helper\QuestionHelper'); - $this->register('helper.editor', 'PHPCR\Shell\Console\Helper\EditorHelper'); - $this->register('helper.path', 'PHPCR\Shell\Console\Helper\PathHelper'); - $this->register('helper.repository', 'PHPCR\Shell\Console\Helper\RepositoryHelper') + $this->register('helper.question', QuestionHelper::class); + $this->register('helper.editor', EditorHelper::class); + $this->register('helper.path', PathHelper::class); + $this->register('helper.repository', RepositoryHelper::class) ->addArgument(new Reference('phpcr.session_manager')); - $this->register('helper.text', 'PHPCR\Shell\Console\Helper\TextHelper'); - $this->register('helper.node', 'PHPCR\Shell\Console\Helper\NodeHelper'); - $this->register('helper.result_formatter', 'PHPCR\Shell\Console\Helper\ResultFormatterHelper') + $this->register('helper.text', TextHelper::class); + $this->register('helper.node', NodeHelper::class); + $this->register('helper.result_formatter', ResultFormatterHelper::class) ->addArgument(new Reference('helper.text')) ->addArgument(new Reference('config.config.phpcrsh')); } public function registerConfig() { - $this->register('config.manager', 'PHPCR\Shell\Config\ConfigManager') + $this->register('config.manager', ConfigManager::class) ->addArgument(new Reference('helper.question')); - $this->register('config.profile', 'PHPCR\Shell\Config\Profile'); - $this->register('config.profile_loader', 'PHPCR\Shell\Config\ProfileLoader') + $this->register('config.profile', Profile::class); + $this->register('config.profile_loader', ProfileLoader::class) ->addArgument(new Reference('config.manager')); - $this->register('config.config.phpcrsh', 'PHPCR\Shell\Config\Config') + $this->register('config.config.phpcrsh', Config::class) ->setFactory([new Reference('config.manager'), 'getPhpcrshConfig']); } @@ -77,17 +106,17 @@ public function registerPhpcr() $this->register($id, $class)->addArgument(new Reference('config.profile')); } - $registry = $this->register('phpcr.transport_registry', 'PHPCR\Shell\Transport\TransportRegistry'); + $registry = $this->register('phpcr.transport_registry', TransportRegistry::class); foreach (array_keys($this->transports) as $transportId) { $registry->addMethodCall('register', [new Reference($transportId)]); } - $this->register('phpcr.session_manager.active', 'PHPCR\Shell\Phpcr\SessionManager') + $this->register('phpcr.session_manager.active', SessionManager::class) ->addArgument(new Reference('phpcr.transport_registry')) ->addArgument(new Reference('config.profile')); - $this->register('phpcr.session_manager.passive', 'PHPCR\Shell\Phpcr\SessionManager') + $this->register('phpcr.session_manager.passive', SessionManager::class) ->addArgument(new Reference('phpcr.transport_registry')) ->addArgument(new Reference('config.profile')); @@ -99,7 +128,7 @@ public function registerPhpcr() $repositoryDefinition->setFactory([new Reference('phpcr.session_manager'), 'getRepository']); $sessionDefinition->setFactory([new Reference('phpcr.session_manager'), 'getSession']); - $this->register('dtl.glob.helper', 'DTL\Glob\GlobHelper'); + $this->register('dtl.glob.helper', GlobHelper::class); } public function registerEvent() @@ -107,12 +136,12 @@ public function registerEvent() if ($this->mode === PhpcrShell::MODE_STANDALONE) { $this->register( 'event.subscriber.profile_from_session_input', - 'PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber' + ProfileFromSessionInputSubscriber::class )->addTag('event.subscriber'); $this->register( 'event.subscriber.profile_loader', - 'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber' + ProfileLoaderSubscriber::class ) ->addArgument(new Reference('config.profile_loader')) ->addArgument(new Reference('helper.question')) @@ -120,7 +149,7 @@ public function registerEvent() $this->register( 'event.subscriber.profile_writer', - 'PHPCR\Shell\Subscriber\ProfileWriterSubscriber' + ProfileWriterSubscriber::class ) ->addArgument(new Reference('config.profile_loader')) ->addArgument(new Reference('helper.question')) @@ -128,7 +157,7 @@ public function registerEvent() $this->register( 'event.subscriber.config_init', - 'PHPCR\Shell\Subscriber\ConfigInitSubscriber' + ConfigInitSubscriber::class ) ->addArgument(new Reference('config.manager')) ->addTag('event.subscriber'); @@ -136,17 +165,17 @@ public function registerEvent() $this->register( 'event.subscriber.alias', - 'PHPCR\Shell\Subscriber\AliasSubscriber' + AliasSubscriber::class ) ->addArgument(new Reference('config.manager')) ->addTag('event.subscriber'); $this->register( 'event.subscriber.exception', - 'PHPCR\Shell\Subscriber\ExceptionSubscriber' + ExceptionSubscriber::class )->addTag('event.subscriber'); - $dispatcher = $this->register('event.dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher'); + $dispatcher = $this->register('event.dispatcher', EventDispatcher::class); foreach (array_keys($this->findTaggedServiceIds('event.subscriber')) as $id) { $dispatcher->addMethodCall('addSubscriber', [new Reference($id)]); @@ -156,22 +185,22 @@ public function registerEvent() public function registerConsole() { if ($this->mode === PhpcrShell::MODE_STANDALONE) { - $this->register('application', 'PHPCR\Shell\Console\Application\ShellApplication') + $this->register('application', ShellApplication::class) ->addArgument(new Reference('container')); } else { - $this->register('application', 'PHPCR\Shell\Console\Application\EmbeddedApplication') + $this->register('application', EmbeddedApplication::class) ->addArgument(new Reference('container')); } - $this->register('console.input.autocomplete', 'PHPCR\Shell\Console\Input\AutoComplete') + $this->register('console.input.autocomplete', AutoComplete::class) ->addArgument(new Reference('application')) ->addArgument(new Reference('phpcr.session')); } public function registerQuery() { - $this->register('query.update.expression_language', 'Symfony\Component\ExpressionLanguage\ExpressionLanguage'); - $this->register('query.update.processor', 'PHPCR\Shell\Query\UpdateProcessor') + $this->register('query.update.expression_language', ExpressionLanguage::class); + $this->register('query.update.processor', UpdateProcessor::class) ->addArgument(new Reference('query.update.expression_language')); } diff --git a/src/PHPCR/Shell/Event/Event.php b/src/PHPCR/Shell/Event/Event.php index 3e9b7ddc..aa6736ee 100644 --- a/src/PHPCR/Shell/Event/Event.php +++ b/src/PHPCR/Shell/Event/Event.php @@ -2,15 +2,8 @@ namespace PHPCR\Shell\Event; -use Symfony\Component\EventDispatcher\Event as OldEvent; use Symfony\Contracts\EventDispatcher\Event as ContractEvent; -if (class_exists(ContractEvent::class)) { - class Event extends ContractEvent - { - } -} else { - class Event extends OldEvent - { - } +class Event extends ContractEvent +{ } diff --git a/src/PHPCR/Shell/Phpcr/PhpcrSession.php b/src/PHPCR/Shell/Phpcr/PhpcrSession.php index 6a07fecc..61c9d9f6 100644 --- a/src/PHPCR/Shell/Phpcr/PhpcrSession.php +++ b/src/PHPCR/Shell/Phpcr/PhpcrSession.php @@ -14,6 +14,8 @@ use DTL\Glob\Finder\PhpcrTraversalFinder; use PHPCR\CredentialsInterface; +use PHPCR\ItemNotFoundException; +use PHPCR\NodeInterface; use PHPCR\PathNotFoundException; use PHPCR\SessionInterface; use PHPCR\Util\UUIDHelper; @@ -93,16 +95,14 @@ public function chdir($path) $newPath = $node->getPath(); } else { // absolute path - if (substr($path, 0, 1) == '/') { + if (str_starts_with($path, '/')) { $newPath = $path; - } elseif ($path == '..') { + } elseif ($path === '..') { $newPath = dirname($cwd); + } elseif ($this->cwd === '/') { + $newPath = sprintf('/%s', $path); } else { - if ($this->cwd == '/') { - $newPath = sprintf('/%s', $path); - } else { - $newPath = sprintf('%s/%s', $cwd, $path); - } + $newPath = sprintf('%s/%s', $cwd, $path); } if ($newPath !== '/') { @@ -238,54 +238,54 @@ public function getNodesByIdentifier($ids) return $this->session->getNodesByIdentifier($ids); } - public function getItem($path) + public function getItem($absPath) { - return $this->session->getItem($this->getAbsPath($path)); + return $this->session->getItem($this->getAbsPath($absPath)); } - public function getNode($path, $depthHint = -1) + public function getNode($absPath, $depthHint = -1) { - return $this->session->getNode($this->getAbsPath($path), $depthHint); + return $this->session->getNode($this->getAbsPath($absPath), $depthHint); } - public function getNodes($paths) + public function getNodes($absPaths) { - return $this->session->getNodes($this->getAbsPaths($paths)); + return $this->session->getNodes($this->getAbsPaths($absPaths)); } - public function getProperty($path) + public function getProperty($absPath) { - return $this->session->getProperty($this->getAbsPath($path)); + return $this->session->getProperty($this->getAbsPath($absPath)); } - public function getProperties($paths) + public function getProperties($absPaths) { - return $this->session->getProperties($this->getAbsPaths($paths)); + return $this->session->getProperties($this->getAbsPaths($absPaths)); } - public function itemExists($path) + public function itemExists($absPath) { - return $this->session->itemExists($this->getAbsPath($path)); + return $this->session->itemExists($this->getAbsPath($absPath)); } - public function nodeExists($path) + public function nodeExists($absPath) { - return $this->session->nodeExists($this->getAbsPath($path)); + return $this->session->nodeExists($this->getAbsPath($absPath)); } - public function propertyExists($path) + public function propertyExists($absPath) { - return $this->session->propertyExists($this->getAbsPath($path)); + return $this->session->propertyExists($this->getAbsPath($absPath)); } - public function move($srcPath, $destPath) + public function move($srcAbsPath, $destAbsPath) { - return $this->session->move($this->getAbsPath($srcPath), $this->getAbsTargetPath($srcPath, $destPath)); + return $this->session->move($this->getAbsPath($srcAbsPath), $this->getAbsTargetPath($srcAbsPath, $destAbsPath)); } - public function removeItem($path) + public function removeItem($absPath) { - return $this->session->removeItem($this->getAbsPath($path)); + return $this->session->removeItem($this->getAbsPath($absPath)); } public function save() @@ -303,19 +303,19 @@ public function hasPendingChanges() return $this->session->hasPendingChanges(); } - public function hasPermission($path, $actions) + public function hasPermission($absPath, $actions) { - return $this->session->hasPermission($this->getAbsPath($path), $actions); + return $this->session->hasPermission($this->getAbsPath($absPath), $actions); } - public function checkPermission($path, $actions) + public function checkPermission($absPath, $actions) { - return $this->session->checkPermission($this->getAbsPath($path), $actions); + return $this->session->checkPermission($this->getAbsPath($absPath), $actions); } - public function hasCapability($methodNames, $target, array $arguments) + public function hasCapability($methodName, $target, array $arguments) { - return $this->session->hasCapability($methodNames, $target, $arguments); + return $this->session->hasCapability($methodName, $target, $arguments); } public function importXML($parentAbsPath, $uri, $uuidBehavior) @@ -323,14 +323,14 @@ public function importXML($parentAbsPath, $uri, $uuidBehavior) return $this->session->importXML($this->getAbsPath($parentAbsPath), $uri, $uuidBehavior); } - public function exportSystemView($path, $stream, $skipBinary, $noRecurse) + public function exportSystemView($absPath, $stream, $skipBinary, $noRecurse) { - return $this->session->exportSystemView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse); + return $this->session->exportSystemView($this->getAbsPath($absPath), $stream, $skipBinary, $noRecurse); } - public function exportDocumentView($path, $stream, $skipBinary, $noRecurse) + public function exportDocumentView($absPath, $stream, $skipBinary, $noRecurse) { - return $this->session->exportDocumentView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse); + return $this->session->exportDocumentView($this->getAbsPath($absPath), $stream, $skipBinary, $noRecurse); } public function setNamespacePrefix($prefix, $uri) @@ -379,8 +379,6 @@ public function findNodes($patternOrId) return $this->getNodeByIdentifier($patternOrId); } - $res = $this->finder->find($this->getAbsPath($patternOrId)); - - return $res; + return $this->finder->find($this->getAbsPath($patternOrId)); } } diff --git a/src/PHPCR/Shell/Phpcr/SessionManager.php b/src/PHPCR/Shell/Phpcr/SessionManager.php index 1f4f3be4..8fd2b919 100644 --- a/src/PHPCR/Shell/Phpcr/SessionManager.php +++ b/src/PHPCR/Shell/Phpcr/SessionManager.php @@ -12,6 +12,7 @@ namespace PHPCR\Shell\Phpcr; +use PHPCR\RepositoryInterface; use PHPCR\SessionInterface; use PHPCR\Shell\Config\Profile; use PHPCR\Shell\Transport\TransportRegistryInterface; @@ -27,7 +28,7 @@ class SessionManager /** * Active PHPCR session. * - * @var \PHPCR\SessionInterface + * @var SessionInterface */ protected $session; @@ -123,7 +124,7 @@ public function relogin($username, $password, $workspaceName = null) * Return the current PHPCR session. We lazy call * initialize. * - * @return \PHPCR\SessionInterface + * @return SessionInterface */ public function getSession() { @@ -135,7 +136,7 @@ public function getSession() /** * Proxy for getting the repository (make mocking easier). * - * @return \PHPCR\RepositoryInterface + * @return RepositoryInterface */ public function getRepository() { diff --git a/src/PHPCR/Shell/PhpcrShell.php b/src/PHPCR/Shell/PhpcrShell.php index 77b4d7a6..fff5d4bd 100644 --- a/src/PHPCR/Shell/PhpcrShell.php +++ b/src/PHPCR/Shell/PhpcrShell.php @@ -13,6 +13,7 @@ namespace PHPCR\Shell; use PHPCR\SessionInterface; +use PHPCR\Shell\Console\Application\EmbeddedApplication; use PHPCR\Shell\Console\Application\SessionApplication; use PHPCR\Shell\Console\Application\Shell; use PHPCR\Shell\DependencyInjection\Container; @@ -60,9 +61,8 @@ public static function createEmbeddedApplication(SessionInterface $session) { $container = new Container(self::MODE_EMBEDDED_COMMAND); $container->get('phpcr.session_manager')->setSession(new PhpcrSession($session)); - $application = $container->get('application'); - return $application; + return $container->get('application'); } /** diff --git a/src/PHPCR/Shell/Query/FunctionOperand.php b/src/PHPCR/Shell/Query/FunctionOperand.php index c2e324ec..2a0d21f1 100644 --- a/src/PHPCR/Shell/Query/FunctionOperand.php +++ b/src/PHPCR/Shell/Query/FunctionOperand.php @@ -74,9 +74,8 @@ public function execute($functionMap, $row) $args = $this->getArguments(); array_unshift($args, $row); array_unshift($args, $this); - $value = call_user_func_array($callable, $args); - return $value; + return call_user_func_array($callable, $args); } /** @@ -84,7 +83,7 @@ public function execute($functionMap, $row) * * @param array Array of values which must be scalars * - * @throws InvalidArgumentException + * @throws \InvalidArgumentException */ public function validateScalarArray($array) { diff --git a/src/PHPCR/Shell/Query/UpdateParser.php b/src/PHPCR/Shell/Query/UpdateParser.php index 2f146482..6d53bd7d 100644 --- a/src/PHPCR/Shell/Query/UpdateParser.php +++ b/src/PHPCR/Shell/Query/UpdateParser.php @@ -162,7 +162,7 @@ private function parseOperand() if ($token === 'NULL') { $this->scanner->fetchNextToken(); - return; + return null; } $columnData = $this->scanColumn(); diff --git a/src/PHPCR/Shell/Query/UpdateProcessor.php b/src/PHPCR/Shell/Query/UpdateProcessor.php index dc85c360..cd717014 100644 --- a/src/PHPCR/Shell/Query/UpdateProcessor.php +++ b/src/PHPCR/Shell/Query/UpdateProcessor.php @@ -27,6 +27,16 @@ class UpdateProcessor */ private $functionMap = []; + /** + * @var \Closure[] + */ + private array $functionMapApply; + + /** + * @var \Closure[] + */ + private array $functionMapSet; + public function __construct(ExpressionLanguage $expressionLanguage) { $this->functionMapApply = [ @@ -113,16 +123,18 @@ public function __construct(ExpressionLanguage $expressionLanguage) /** * Update a node indicated in $propertyData in $row. * - * @param PHPCR\Query\RowInterface + * @param RowInterface * @param array */ public function updateNodeSet(RowInterface $row, $propertyData) { $node = $row->getNode($propertyData['selector']); + if (!$node) { + throw new \InvalidArgumentException('Row was expected to contain a node at '.$propertyData['selector']); + } $value = $propertyData['value']; if ($value instanceof FunctionOperand) { - $value = $propertyData['value']; $value = $value->execute($this->functionMapSet, $row); } @@ -131,17 +143,6 @@ public function updateNodeSet(RowInterface $row, $propertyData) public function updateNodeApply(RowInterface $row, FunctionOperand $apply) { - if (!$apply instanceof FunctionOperand) { - throw new \InvalidArgumentException( - 'Was expecting a function operand but got something else' - ); - } - $apply->execute($this->functionMapApply, $row); } - - private function handleFunction($row, $propertyData) - { - return $value; - } } diff --git a/src/PHPCR/Shell/Query/Validator.php b/src/PHPCR/Shell/Query/Validator.php index 83a4f53d..ad8a5f2c 100644 --- a/src/PHPCR/Shell/Query/Validator.php +++ b/src/PHPCR/Shell/Query/Validator.php @@ -21,7 +21,7 @@ class Validator */ public static function validateQuery($sql2) { - if (substr($sql2, -1) !== ';') { + if (!str_ends_with($sql2, ';')) { throw new \InvalidArgumentException( 'Queries must be terminated with ";"' ); diff --git a/src/PHPCR/Shell/Serializer/NodeNormalizer.php b/src/PHPCR/Shell/Serializer/NodeNormalizer.php index be7d068b..8e9ded45 100644 --- a/src/PHPCR/Shell/Serializer/NodeNormalizer.php +++ b/src/PHPCR/Shell/Serializer/NodeNormalizer.php @@ -186,7 +186,7 @@ public function supportsDenormalization($data, $type, $format = null, array $con * * @param mixed * - * @return string + * @return string[] */ private function normalizeDatum($value) { diff --git a/src/PHPCR/Shell/Subscriber/AliasSubscriber.php b/src/PHPCR/Shell/Subscriber/AliasSubscriber.php index 58324b8b..8a03140d 100644 --- a/src/PHPCR/Shell/Subscriber/AliasSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/AliasSubscriber.php @@ -47,7 +47,7 @@ public static function getSubscribedEvents() * Check for an alias and replace the input with a new string command * if the alias exists. * - * @return string New command string (for testing purposes) + * @return string|null New command string (for testing purposes) */ public function handleAlias(CommandPreRunEvent $event) { @@ -58,7 +58,7 @@ public function handleAlias(CommandPreRunEvent $event) $aliasConfig = $this->configManager->getConfig('alias'); if (!isset($aliasConfig[$commandName])) { - return; + return null; } $command = $aliasConfig[$commandName]; diff --git a/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php b/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php index aee25682..e72b94ba 100644 --- a/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/AutoSaveSubscriber.php @@ -33,8 +33,14 @@ public static function getSubscribedEvents() public function handleTerminate(ConsoleTerminateEvent $event) { $command = $event->getCommand(); + if (!$command) { + return; + } $output = $event->getOutput(); $session = $command->get('phpcr.session'); + if (!$session) { + throw new \InvalidArgumentException('expected phpcr.session to exist'); + } if ($session->hasPendingChanges()) { $output->writeln('Auto-saving session'); diff --git a/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php b/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php index d6071615..2c8628df 100644 --- a/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php +++ b/src/PHPCR/Shell/Transport/Transport/DoctrineDbal.php @@ -26,7 +26,7 @@ public function getName() public function getRepository(Config $config) { - $connection = DriverManager::getConnection($ops = [ + $connection = DriverManager::getConnection([ 'user' => $config['db_username'], 'password' => $config['db_password'], 'host' => $config['db_host'], diff --git a/src/PHPCR/Shell/Transport/Transport/JackalopeFs.php b/src/PHPCR/Shell/Transport/Transport/JackalopeFs.php index 59f5b553..4721285d 100644 --- a/src/PHPCR/Shell/Transport/Transport/JackalopeFs.php +++ b/src/PHPCR/Shell/Transport/Transport/JackalopeFs.php @@ -29,8 +29,7 @@ public function getRepository(Config $config) 'path' => $config['repo_path'], ]; $factory = new RepositoryFactoryFilesystem(); - $repository = $factory->getRepository($params); - return $repository; + return $factory->getRepository($params); } } diff --git a/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php b/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php index e5089c7d..642a54b1 100644 --- a/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php +++ b/src/PHPCR/Shell/Transport/Transport/Jackrabbit.php @@ -29,8 +29,7 @@ public function getRepository(Config $config) 'jackalope.jackrabbit_uri' => $config['repo_url'], ]; $factory = new RepositoryFactoryJackrabbit(); - $repository = $factory->getRepository($params); - return $repository; + return $factory->getRepository($params); } } diff --git a/src/PHPCR/Shell/Transport/TransportRegistryInterface.php b/src/PHPCR/Shell/Transport/TransportRegistryInterface.php index 94d73d03..45d7521a 100644 --- a/src/PHPCR/Shell/Transport/TransportRegistryInterface.php +++ b/src/PHPCR/Shell/Transport/TransportRegistryInterface.php @@ -35,7 +35,7 @@ public function getTransportNames(); * * @param string $name * - * @return PHPCR\Shell\Transport\Transport\TransportInterface + * @return TransportInterface */ public function getTransport($name); }