Completed
Pull Request — 4.3 (#149)
by Dorian
13:16
created
src/Mouf/Database/TDBM/Commands/GenerateCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
         $alteredConf = new AlteredConfiguration($this->configuration);
40 40
 
41 41
 
42
-        $loggers = [ new ConsoleLogger($output) ];
42
+        $loggers = [new ConsoleLogger($output)];
43 43
 
44 44
         $logger = $alteredConf->getLogger();
45 45
         if ($logger) {
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,48 +12,48 @@
 block discarded – undo
12 12
 class GenerateCommand extends Command
13 13
 {
14 14
 
15
-    /**
16
-     * @var ConfigurationInterface
17
-     */
18
-    private $configuration;
15
+	/**
16
+	 * @var ConfigurationInterface
17
+	 */
18
+	private $configuration;
19 19
 
20
-    public function __construct(ConfigurationInterface $configuration)
21
-    {
22
-        parent::__construct();
23
-        $this->configuration = $configuration;
24
-    }
20
+	public function __construct(ConfigurationInterface $configuration)
21
+	{
22
+		parent::__construct();
23
+		$this->configuration = $configuration;
24
+	}
25 25
 
26
-    protected function configure()
27
-    {
28
-        $this->setName('tdbm:generate')
29
-            ->setDescription('Generates DAOs and beans.')
30
-            ->setHelp('Use this command to generate or regenerate the DAOs and beans for your project.')
31
-        ;
32
-    }
26
+	protected function configure()
27
+	{
28
+		$this->setName('tdbm:generate')
29
+			->setDescription('Generates DAOs and beans.')
30
+			->setHelp('Use this command to generate or regenerate the DAOs and beans for your project.')
31
+		;
32
+	}
33 33
 
34
-    protected function execute(InputInterface $input, OutputInterface $output)
35
-    {
36
-        // TODO: externalize composer.json file for autoloading (no more parameters for generateAllDaosAndBeans)
34
+	protected function execute(InputInterface $input, OutputInterface $output)
35
+	{
36
+		// TODO: externalize composer.json file for autoloading (no more parameters for generateAllDaosAndBeans)
37 37
 
38
-        $alteredConf = new AlteredConfiguration($this->configuration);
38
+		$alteredConf = new AlteredConfiguration($this->configuration);
39 39
 
40 40
 
41
-        $loggers = [ new ConsoleLogger($output) ];
41
+		$loggers = [ new ConsoleLogger($output) ];
42 42
 
43
-        $logger = $alteredConf->getLogger();
44
-        if ($logger) {
45
-            $loggers[] = $logger;
46
-        }
43
+		$logger = $alteredConf->getLogger();
44
+		if ($logger) {
45
+			$loggers[] = $logger;
46
+		}
47 47
 
48
-        $multiLogger = new MultiLogger($loggers);
48
+		$multiLogger = new MultiLogger($loggers);
49 49
 
50
-        $alteredConf->setLogger($multiLogger);
50
+		$alteredConf->setLogger($multiLogger);
51 51
 
52
-        $multiLogger->notice('Starting regenerating DAOs and beans');
52
+		$multiLogger->notice('Starting regenerating DAOs and beans');
53 53
 
54
-        $tdbmService = new TDBMService($this->configuration);
55
-        $tdbmService->generateAllDaosAndBeans();
54
+		$tdbmService = new TDBMService($this->configuration);
55
+		$tdbmService->generateAllDaosAndBeans();
56 56
 
57
-        $multiLogger->notice('Finished regenerating DAOs and beans');
58
-    }
57
+		$multiLogger->notice('Finished regenerating DAOs and beans');
58
+	}
59 59
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Configuration.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
     /**
136 136
      * @return LoggerInterface
137 137
      */
138
-    public function getLogger(): ?LoggerInterface
138
+    public function getLogger(): ? LoggerInterface
139 139
     {
140 140
         return $this->logger;
141 141
     }
Please login to merge, or discard this patch.
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -17,165 +17,165 @@
 block discarded – undo
17 17
 class Configuration implements ConfigurationInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    private $beanNamespace;
24
-    /**
25
-     * @var string
26
-     */
27
-    private $daoNamespace;
28
-    /**
29
-     * @var Connection
30
-     */
31
-    private $connection;
32
-    /**
33
-     * @var Cache
34
-     */
35
-    private $cache;
36
-    /**
37
-     * @var SchemaAnalyzer
38
-     */
39
-    private $schemaAnalyzer;
40
-    /**
41
-     * @var LoggerInterface
42
-     */
43
-    private $logger;
44
-    /**
45
-     * @var GeneratorListenerInterface
46
-     */
47
-    private $generatorEventDispatcher;
48
-    /**
49
-     * @var NamingStrategyInterface
50
-     */
51
-    private $namingStrategy;
52
-    /**
53
-     * @var PathFinderInterface
54
-     */
55
-    private $pathFinder;
56
-
57
-    /**
58
-     * @param string $beanNamespace The namespace hosting the beans
59
-     * @param string $daoNamespace The namespace hosting the DAOs
60
-     * @param Connection $connection The connection to the database
61
-     * @param Cache|null $cache The Doctrine cache to store database metadata
62
-     * @param SchemaAnalyzer|null $schemaAnalyzer The schema analyzer that will be used to find shortest paths... Will be automatically created if not passed
63
-     * @param LoggerInterface|null $logger The logger
64
-     * @param GeneratorListenerInterface[] $generatorListeners A list of listeners that will be triggered when beans/daos are generated
65
-     */
66
-    public function __construct(string $beanNamespace, string $daoNamespace, Connection $connection, NamingStrategyInterface $namingStrategy, Cache $cache = null, SchemaAnalyzer $schemaAnalyzer = null, LoggerInterface $logger = null, array $generatorListeners = [])
67
-    {
68
-        $this->beanNamespace = rtrim($beanNamespace, '\\');
69
-        $this->daoNamespace = rtrim($daoNamespace, '\\');
70
-        $this->connection = $connection;
71
-        $this->namingStrategy = $namingStrategy;
72
-        if ($cache !== null) {
73
-            $this->cache = $cache;
74
-        } else {
75
-            $this->cache = new VoidCache();
76
-        }
77
-        if ($schemaAnalyzer !== null) {
78
-            $this->schemaAnalyzer = $schemaAnalyzer;
79
-        } else {
80
-            $this->schemaAnalyzer = new SchemaAnalyzer($this->connection->getSchemaManager(), $this->cache, $this->getConnectionUniqueId());
81
-        }
82
-        $this->logger = $logger;
83
-        $this->generatorEventDispatcher = new GeneratorEventDispatcher($generatorListeners);
84
-        $this->pathFinder = new PathFinder();
85
-    }
86
-
87
-    /**
88
-     * @return string
89
-     */
90
-    public function getBeanNamespace(): string
91
-    {
92
-        return $this->beanNamespace;
93
-    }
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getDaoNamespace(): string
99
-    {
100
-        return $this->daoNamespace;
101
-    }
102
-
103
-    /**
104
-     * @return Connection
105
-     */
106
-    public function getConnection(): Connection
107
-    {
108
-        return $this->connection;
109
-    }
110
-
111
-    /**
112
-     * @return NamingStrategyInterface
113
-     */
114
-    public function getNamingStrategy(): NamingStrategyInterface
115
-    {
116
-        return $this->namingStrategy;
117
-    }
118
-
119
-    /**
120
-     * @return Cache
121
-     */
122
-    public function getCache(): Cache
123
-    {
124
-        return $this->cache;
125
-    }
126
-
127
-    /**
128
-     * @return SchemaAnalyzer
129
-     */
130
-    public function getSchemaAnalyzer(): SchemaAnalyzer
131
-    {
132
-        return $this->schemaAnalyzer;
133
-    }
134
-
135
-    /**
136
-     * @return LoggerInterface
137
-     */
138
-    public function getLogger(): ?LoggerInterface
139
-    {
140
-        return $this->logger;
141
-    }
142
-
143
-    /**
144
-     * @return GeneratorListenerInterface
145
-     */
146
-    public function getGeneratorEventDispatcher(): GeneratorListenerInterface
147
-    {
148
-        return $this->generatorEventDispatcher;
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * Creates a unique cache key for the current connection.
155
-     *
156
-     * @return string
157
-     */
158
-    private function getConnectionUniqueId(): string
159
-    {
160
-        return hash('md4', $this->connection->getHost().'-'.$this->connection->getPort().'-'.$this->connection->getDatabase().'-'.$this->connection->getDriver()->getName());
161
-    }
162
-
163
-    /**
164
-     * Returns a class able to find the place of a PHP file based on the class name.
165
-     * Useful to find the path where DAOs and beans should be written to.
166
-     *
167
-     * @return PathFinderInterface
168
-     */
169
-    public function getPathFinder(): PathFinderInterface
170
-    {
171
-        return $this->pathFinder;
172
-    }
173
-
174
-    /**
175
-     * @param PathFinderInterface $pathFinder
176
-     */
177
-    public function setPathFinder(PathFinderInterface $pathFinder)
178
-    {
179
-        $this->pathFinder = $pathFinder;
180
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	private $beanNamespace;
24
+	/**
25
+	 * @var string
26
+	 */
27
+	private $daoNamespace;
28
+	/**
29
+	 * @var Connection
30
+	 */
31
+	private $connection;
32
+	/**
33
+	 * @var Cache
34
+	 */
35
+	private $cache;
36
+	/**
37
+	 * @var SchemaAnalyzer
38
+	 */
39
+	private $schemaAnalyzer;
40
+	/**
41
+	 * @var LoggerInterface
42
+	 */
43
+	private $logger;
44
+	/**
45
+	 * @var GeneratorListenerInterface
46
+	 */
47
+	private $generatorEventDispatcher;
48
+	/**
49
+	 * @var NamingStrategyInterface
50
+	 */
51
+	private $namingStrategy;
52
+	/**
53
+	 * @var PathFinderInterface
54
+	 */
55
+	private $pathFinder;
56
+
57
+	/**
58
+	 * @param string $beanNamespace The namespace hosting the beans
59
+	 * @param string $daoNamespace The namespace hosting the DAOs
60
+	 * @param Connection $connection The connection to the database
61
+	 * @param Cache|null $cache The Doctrine cache to store database metadata
62
+	 * @param SchemaAnalyzer|null $schemaAnalyzer The schema analyzer that will be used to find shortest paths... Will be automatically created if not passed
63
+	 * @param LoggerInterface|null $logger The logger
64
+	 * @param GeneratorListenerInterface[] $generatorListeners A list of listeners that will be triggered when beans/daos are generated
65
+	 */
66
+	public function __construct(string $beanNamespace, string $daoNamespace, Connection $connection, NamingStrategyInterface $namingStrategy, Cache $cache = null, SchemaAnalyzer $schemaAnalyzer = null, LoggerInterface $logger = null, array $generatorListeners = [])
67
+	{
68
+		$this->beanNamespace = rtrim($beanNamespace, '\\');
69
+		$this->daoNamespace = rtrim($daoNamespace, '\\');
70
+		$this->connection = $connection;
71
+		$this->namingStrategy = $namingStrategy;
72
+		if ($cache !== null) {
73
+			$this->cache = $cache;
74
+		} else {
75
+			$this->cache = new VoidCache();
76
+		}
77
+		if ($schemaAnalyzer !== null) {
78
+			$this->schemaAnalyzer = $schemaAnalyzer;
79
+		} else {
80
+			$this->schemaAnalyzer = new SchemaAnalyzer($this->connection->getSchemaManager(), $this->cache, $this->getConnectionUniqueId());
81
+		}
82
+		$this->logger = $logger;
83
+		$this->generatorEventDispatcher = new GeneratorEventDispatcher($generatorListeners);
84
+		$this->pathFinder = new PathFinder();
85
+	}
86
+
87
+	/**
88
+	 * @return string
89
+	 */
90
+	public function getBeanNamespace(): string
91
+	{
92
+		return $this->beanNamespace;
93
+	}
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getDaoNamespace(): string
99
+	{
100
+		return $this->daoNamespace;
101
+	}
102
+
103
+	/**
104
+	 * @return Connection
105
+	 */
106
+	public function getConnection(): Connection
107
+	{
108
+		return $this->connection;
109
+	}
110
+
111
+	/**
112
+	 * @return NamingStrategyInterface
113
+	 */
114
+	public function getNamingStrategy(): NamingStrategyInterface
115
+	{
116
+		return $this->namingStrategy;
117
+	}
118
+
119
+	/**
120
+	 * @return Cache
121
+	 */
122
+	public function getCache(): Cache
123
+	{
124
+		return $this->cache;
125
+	}
126
+
127
+	/**
128
+	 * @return SchemaAnalyzer
129
+	 */
130
+	public function getSchemaAnalyzer(): SchemaAnalyzer
131
+	{
132
+		return $this->schemaAnalyzer;
133
+	}
134
+
135
+	/**
136
+	 * @return LoggerInterface
137
+	 */
138
+	public function getLogger(): ?LoggerInterface
139
+	{
140
+		return $this->logger;
141
+	}
142
+
143
+	/**
144
+	 * @return GeneratorListenerInterface
145
+	 */
146
+	public function getGeneratorEventDispatcher(): GeneratorListenerInterface
147
+	{
148
+		return $this->generatorEventDispatcher;
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * Creates a unique cache key for the current connection.
155
+	 *
156
+	 * @return string
157
+	 */
158
+	private function getConnectionUniqueId(): string
159
+	{
160
+		return hash('md4', $this->connection->getHost().'-'.$this->connection->getPort().'-'.$this->connection->getDatabase().'-'.$this->connection->getDriver()->getName());
161
+	}
162
+
163
+	/**
164
+	 * Returns a class able to find the place of a PHP file based on the class name.
165
+	 * Useful to find the path where DAOs and beans should be written to.
166
+	 *
167
+	 * @return PathFinderInterface
168
+	 */
169
+	public function getPathFinder(): PathFinderInterface
170
+	{
171
+		return $this->pathFinder;
172
+	}
173
+
174
+	/**
175
+	 * @param PathFinderInterface $pathFinder
176
+	 */
177
+	public function setPathFinder(PathFinderInterface $pathFinder)
178
+	{
179
+		$this->pathFinder = $pathFinder;
180
+	}
181 181
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/PathFinder/PathFinderInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 block discarded – undo
5 5
 
6 6
 interface PathFinderInterface
7 7
 {
8
-    /**
9
-     * Returns the path of a class file given the fully qualified class name.
10
-     *
11
-     * @param string $className
12
-     * @return \SplFileInfo
13
-     * @throws NoPathFoundException
14
-     */
15
-    public function getPath(string $className) : \SplFileInfo;
8
+	/**
9
+	 * Returns the path of a class file given the fully qualified class name.
10
+	 *
11
+	 * @param string $className
12
+	 * @return \SplFileInfo
13
+	 * @throws NoPathFoundException
14
+	 */
15
+	public function getPath(string $className) : \SplFileInfo;
16 16
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/PathFinder/NoPathFoundException.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
  */
11 11
 class NoPathFoundException extends TDBMException
12 12
 {
13
-    public static function create(string $className)
14
-    {
15
-        return new self(sprintf('Could not find a path where class %s would be autoloadable. Maybe consider editing your composer.json autoload section accordingly.', $className));
16
-    }
13
+	public static function create(string $className)
14
+	{
15
+		return new self(sprintf('Could not find a path where class %s would be autoloadable. Maybe consider editing your composer.json autoload section accordingly.', $className));
16
+	}
17 17
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Commands/AlteredConfiguration.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -20,103 +20,103 @@
 block discarded – undo
20 20
  */
21 21
 class AlteredConfiguration implements ConfigurationInterface
22 22
 {
23
-    /**
24
-     * @var ConfigurationInterface
25
-     */
26
-    private $configuration;
27
-
28
-    /**
29
-     * @var LoggerInterface
30
-     */
31
-    private $logger;
32
-
33
-    public function __construct(ConfigurationInterface $configuration)
34
-    {
35
-        $this->configuration = $configuration;
36
-        $this->logger = $configuration->getLogger();
37
-    }
38
-
39
-
40
-    /**
41
-     * @return string
42
-     */
43
-    public function getBeanNamespace(): string
44
-    {
45
-        return $this->configuration->getBeanNamespace();
46
-    }
47
-
48
-    /**
49
-     * @return string
50
-     */
51
-    public function getDaoNamespace(): string
52
-    {
53
-        return $this->configuration->getDaoNamespace();
54
-    }
55
-
56
-    /**
57
-     * @return Connection
58
-     */
59
-    public function getConnection(): Connection
60
-    {
61
-        return $this->configuration->getConnection();
62
-    }
63
-
64
-    /**
65
-     * @return Cache
66
-     */
67
-    public function getCache(): Cache
68
-    {
69
-        return $this->configuration->getCache();
70
-    }
71
-
72
-    /**
73
-     * @return NamingStrategyInterface
74
-     */
75
-    public function getNamingStrategy(): NamingStrategyInterface
76
-    {
77
-        return $this->configuration->getNamingStrategy();
78
-    }
79
-
80
-    /**
81
-     * @return SchemaAnalyzer
82
-     */
83
-    public function getSchemaAnalyzer(): SchemaAnalyzer
84
-    {
85
-        return $this->configuration->getSchemaAnalyzer();
86
-    }
87
-
88
-    /**
89
-     * @return LoggerInterface
90
-     */
91
-    public function getLogger(): ?LoggerInterface
92
-    {
93
-        return $this->logger;
94
-    }
95
-
96
-    /**
97
-     * @return GeneratorListenerInterface
98
-     */
99
-    public function getGeneratorEventDispatcher(): GeneratorListenerInterface
100
-    {
101
-        return $this->configuration->getGeneratorEventDispatcher();
102
-    }
103
-
104
-    /**
105
-     * @param LoggerInterface $logger
106
-     */
107
-    public function setLogger(LoggerInterface $logger)
108
-    {
109
-        $this->logger = $logger;
110
-    }
111
-
112
-    /**
113
-     * Returns a class able to find the place of a PHP file based on the class name.
114
-     * Useful to find the path where DAOs and beans should be written to.
115
-     *
116
-     * @return PathFinderInterface
117
-     */
118
-    public function getPathFinder(): PathFinderInterface
119
-    {
120
-        return $this->configuration->getPathFinder();
121
-    }
23
+	/**
24
+	 * @var ConfigurationInterface
25
+	 */
26
+	private $configuration;
27
+
28
+	/**
29
+	 * @var LoggerInterface
30
+	 */
31
+	private $logger;
32
+
33
+	public function __construct(ConfigurationInterface $configuration)
34
+	{
35
+		$this->configuration = $configuration;
36
+		$this->logger = $configuration->getLogger();
37
+	}
38
+
39
+
40
+	/**
41
+	 * @return string
42
+	 */
43
+	public function getBeanNamespace(): string
44
+	{
45
+		return $this->configuration->getBeanNamespace();
46
+	}
47
+
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function getDaoNamespace(): string
52
+	{
53
+		return $this->configuration->getDaoNamespace();
54
+	}
55
+
56
+	/**
57
+	 * @return Connection
58
+	 */
59
+	public function getConnection(): Connection
60
+	{
61
+		return $this->configuration->getConnection();
62
+	}
63
+
64
+	/**
65
+	 * @return Cache
66
+	 */
67
+	public function getCache(): Cache
68
+	{
69
+		return $this->configuration->getCache();
70
+	}
71
+
72
+	/**
73
+	 * @return NamingStrategyInterface
74
+	 */
75
+	public function getNamingStrategy(): NamingStrategyInterface
76
+	{
77
+		return $this->configuration->getNamingStrategy();
78
+	}
79
+
80
+	/**
81
+	 * @return SchemaAnalyzer
82
+	 */
83
+	public function getSchemaAnalyzer(): SchemaAnalyzer
84
+	{
85
+		return $this->configuration->getSchemaAnalyzer();
86
+	}
87
+
88
+	/**
89
+	 * @return LoggerInterface
90
+	 */
91
+	public function getLogger(): ?LoggerInterface
92
+	{
93
+		return $this->logger;
94
+	}
95
+
96
+	/**
97
+	 * @return GeneratorListenerInterface
98
+	 */
99
+	public function getGeneratorEventDispatcher(): GeneratorListenerInterface
100
+	{
101
+		return $this->configuration->getGeneratorEventDispatcher();
102
+	}
103
+
104
+	/**
105
+	 * @param LoggerInterface $logger
106
+	 */
107
+	public function setLogger(LoggerInterface $logger)
108
+	{
109
+		$this->logger = $logger;
110
+	}
111
+
112
+	/**
113
+	 * Returns a class able to find the place of a PHP file based on the class name.
114
+	 * Useful to find the path where DAOs and beans should be written to.
115
+	 *
116
+	 * @return PathFinderInterface
117
+	 */
118
+	public function getPathFinder(): PathFinderInterface
119
+	{
120
+		return $this->configuration->getPathFinder();
121
+	}
122 122
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
     /**
136 136
      * @return LoggerInterface
137 137
      */
138
-    public function getLogger(): ?LoggerInterface
138
+    public function getLogger(): ? LoggerInterface
139 139
     {
140 140
         return $this->logger;
141 141
     }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/PathFinder/PathFinder.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -5,58 +5,58 @@
 block discarded – undo
5 5
 
6 6
 class PathFinder implements PathFinderInterface
7 7
 {
8
-    /**
9
-     * @var string
10
-     */
11
-    private $composerFile;
12
-
13
-    /**
14
-     * @var string
15
-     */
16
-    private $rootPath;
17
-
18
-    /**
19
-     * @var bool
20
-     */
21
-    private $useAutoloadDev;
22
-
23
-    /**
24
-     * @var ClassNameMapper
25
-     */
26
-    private $classNameMapper;
27
-
28
-    public function __construct(string $composerFile = null, string $rootPath = null, bool $useAutoloadDev = false)
29
-    {
30
-        $this->composerFile = $composerFile;
31
-        $this->useAutoloadDev = $useAutoloadDev;
32
-        if ($rootPath === null) {
33
-            $this->rootPath = dirname(__DIR__, 9);
34
-        } else {
35
-            $this->rootPath = $rootPath;
36
-        }
37
-    }
38
-
39
-    private function getClassNameMapper() : ClassNameMapper
40
-    {
41
-        if ($this->classNameMapper === null) {
42
-            $this->classNameMapper = ClassNameMapper::createFromComposerFile($this->composerFile, $this->rootPath, $this->useAutoloadDev);
43
-        }
44
-        return $this->classNameMapper;
45
-    }
46
-
47
-    /**
48
-     * Returns the path of a class file given the fully qualified class name.
49
-     *
50
-     * @param string $className
51
-     * @return \SplFileInfo
52
-     * @throws NoPathFoundException
53
-     */
54
-    public function getPath(string $className): \SplFileInfo
55
-    {
56
-        $paths = $this->getClassNameMapper()->getPossibleFileNames($className);
57
-        if (empty($paths)) {
58
-            throw NoPathFoundException::create($className);
59
-        }
60
-        return new \SplFileInfo($this->rootPath.'/'.$paths[0]);
61
-    }
8
+	/**
9
+	 * @var string
10
+	 */
11
+	private $composerFile;
12
+
13
+	/**
14
+	 * @var string
15
+	 */
16
+	private $rootPath;
17
+
18
+	/**
19
+	 * @var bool
20
+	 */
21
+	private $useAutoloadDev;
22
+
23
+	/**
24
+	 * @var ClassNameMapper
25
+	 */
26
+	private $classNameMapper;
27
+
28
+	public function __construct(string $composerFile = null, string $rootPath = null, bool $useAutoloadDev = false)
29
+	{
30
+		$this->composerFile = $composerFile;
31
+		$this->useAutoloadDev = $useAutoloadDev;
32
+		if ($rootPath === null) {
33
+			$this->rootPath = dirname(__DIR__, 9);
34
+		} else {
35
+			$this->rootPath = $rootPath;
36
+		}
37
+	}
38
+
39
+	private function getClassNameMapper() : ClassNameMapper
40
+	{
41
+		if ($this->classNameMapper === null) {
42
+			$this->classNameMapper = ClassNameMapper::createFromComposerFile($this->composerFile, $this->rootPath, $this->useAutoloadDev);
43
+		}
44
+		return $this->classNameMapper;
45
+	}
46
+
47
+	/**
48
+	 * Returns the path of a class file given the fully qualified class name.
49
+	 *
50
+	 * @param string $className
51
+	 * @return \SplFileInfo
52
+	 * @throws NoPathFoundException
53
+	 */
54
+	public function getPath(string $className): \SplFileInfo
55
+	{
56
+		$paths = $this->getClassNameMapper()->getPossibleFileNames($className);
57
+		if (empty($paths)) {
58
+			throw NoPathFoundException::create($className);
59
+		}
60
+		return new \SplFileInfo($this->rootPath.'/'.$paths[0]);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/DefaultNamingStrategy.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -7,193 +7,193 @@
 block discarded – undo
7 7
 
8 8
 class DefaultNamingStrategy implements NamingStrategyInterface
9 9
 {
10
-    private $beanPrefix = '';
11
-    private $beanSuffix = '';
12
-    private $baseBeanPrefix = 'Abstract';
13
-    private $baseBeanSuffix = '';
14
-    private $daoPrefix = '';
15
-    private $daoSuffix = 'Dao';
16
-    private $baseDaoPrefix = 'Abstract';
17
-    private $baseDaoSuffix = 'Dao';
18
-    private $exceptions = [];
19
-
20
-    /**
21
-     * Sets the string prefix to any bean class name.
22
-     *
23
-     * @param string $beanPrefix
24
-     */
25
-    public function setBeanPrefix(string $beanPrefix)
26
-    {
27
-        $this->beanPrefix = $beanPrefix;
28
-    }
29
-
30
-    /**
31
-     * Sets the string suffix to any bean class name.
32
-     *
33
-     * @param string $beanSuffix
34
-     */
35
-    public function setBeanSuffix(string $beanSuffix)
36
-    {
37
-        $this->beanSuffix = $beanSuffix;
38
-    }
39
-
40
-    /**
41
-     * Sets the string prefix to any base bean class name.
42
-     *
43
-     * @param string $baseBeanPrefix
44
-     */
45
-    public function setBaseBeanPrefix(string $baseBeanPrefix)
46
-    {
47
-        $this->baseBeanPrefix = $baseBeanPrefix;
48
-    }
49
-
50
-    /**
51
-     * Sets the string suffix to any base bean class name.
52
-     *
53
-     * @param string $baseBeanSuffix
54
-     */
55
-    public function setBaseBeanSuffix(string $baseBeanSuffix)
56
-    {
57
-        $this->baseBeanSuffix = $baseBeanSuffix;
58
-    }
59
-
60
-    /**
61
-     * Sets the string prefix to any DAO class name.
62
-     *
63
-     * @param string $daoPrefix
64
-     */
65
-    public function setDaoPrefix(string $daoPrefix)
66
-    {
67
-        $this->daoPrefix = $daoPrefix;
68
-    }
69
-
70
-    /**
71
-     * Sets the string suffix to any DAO class name.
72
-     *
73
-     * @param string $daoSuffix
74
-     */
75
-    public function setDaoSuffix(string $daoSuffix)
76
-    {
77
-        $this->daoSuffix = $daoSuffix;
78
-    }
79
-
80
-    /**
81
-     * Sets the string prefix to any base DAO class name.
82
-     *
83
-     * @param string $baseDaoPrefix
84
-     */
85
-    public function setBaseDaoPrefix(string $baseDaoPrefix)
86
-    {
87
-        $this->baseDaoPrefix = $baseDaoPrefix;
88
-    }
89
-
90
-    /**
91
-     * Sets the string suffix to any base DAO class name.
92
-     *
93
-     * @param string $baseDaoSuffix
94
-     */
95
-    public function setBaseDaoSuffix(string $baseDaoSuffix)
96
-    {
97
-        $this->baseDaoSuffix = $baseDaoSuffix;
98
-    }
99
-
100
-
101
-    /**
102
-     * Returns the bean class name from the table name (excluding the namespace).
103
-     *
104
-     * @param string $tableName
105
-     * @return string
106
-     */
107
-    public function getBeanClassName(string $tableName): string
108
-    {
109
-        return $this->beanPrefix.$this->toSingularCamelCase($tableName).$this->beanSuffix;
110
-    }
111
-
112
-    /**
113
-     * Returns the base bean class name from the table name (excluding the namespace).
114
-     *
115
-     * @param string $tableName
116
-     * @return string
117
-     */
118
-    public function getBaseBeanClassName(string $tableName): string
119
-    {
120
-        return $this->baseBeanPrefix.$this->toSingularCamelCase($tableName).$this->baseBeanSuffix;
121
-    }
122
-
123
-    /**
124
-     * Returns the name of the DAO class from the table name (excluding the namespace).
125
-     *
126
-     * @param string $tableName
127
-     * @return string
128
-     */
129
-    public function getDaoClassName(string $tableName): string
130
-    {
131
-        return $this->daoPrefix.$this->toSingularCamelCase($tableName).$this->daoSuffix;
132
-    }
133
-
134
-    /**
135
-     * Returns the name of the base DAO class from the table name (excluding the namespace).
136
-     *
137
-     * @param string $tableName
138
-     * @return string
139
-     */
140
-    public function getBaseDaoClassName(string $tableName): string
141
-    {
142
-        return $this->baseDaoPrefix.$this->toSingularCamelCase($tableName).$this->baseDaoSuffix;
143
-    }
144
-
145
-    /**
146
-     * Tries to put string to the singular form (if it is plural) and camel case form.
147
-     * We assume the table names are in english.
148
-     *
149
-     * @param $str string
150
-     *
151
-     * @return string
152
-     */
153
-    private function toSingularCamelCase(string $str): string
154
-    {
155
-        // Let's first check if this is not in the exceptions directory.
156
-        if (isset($this->exceptions[$str])) {
157
-            return $this->exceptions[$str];
158
-        }
159
-
160
-        $tokens = preg_split("/[_ ]+/", $str);
161
-        $tokens = array_map([Inflector::class, 'singularize'], $tokens);
162
-
163
-        $str = '';
164
-        foreach ($tokens as $token) {
165
-            $str .= ucfirst(Inflector::singularize($token));
166
-        }
167
-
168
-        return $str;
169
-    }
170
-
171
-    /**
172
-     * Returns the class name for the DAO factory.
173
-     *
174
-     * @return string
175
-     */
176
-    public function getDaoFactoryClassName(): string
177
-    {
178
-        return 'DaoFactory';
179
-    }
180
-
181
-    /**
182
-     * Sets exceptions in the naming of classes.
183
-     * The key is the name of the table, the value the "base" name of beans and DAOs.
184
-     *
185
-     * This is very useful for dealing with plural to singular translations in non english table names.
186
-     *
187
-     * For instance if you are dealing with a table containing horses in French ("chevaux" that has a singular "cheval"):
188
-     *
189
-     * [
190
-     *     "chevaux" => "Cheval"
191
-     * ]
192
-     *
193
-     * @param array<string,string> $exceptions
194
-     */
195
-    public function setExceptions(array $exceptions)
196
-    {
197
-        $this->exceptions = $exceptions;
198
-    }
10
+	private $beanPrefix = '';
11
+	private $beanSuffix = '';
12
+	private $baseBeanPrefix = 'Abstract';
13
+	private $baseBeanSuffix = '';
14
+	private $daoPrefix = '';
15
+	private $daoSuffix = 'Dao';
16
+	private $baseDaoPrefix = 'Abstract';
17
+	private $baseDaoSuffix = 'Dao';
18
+	private $exceptions = [];
19
+
20
+	/**
21
+	 * Sets the string prefix to any bean class name.
22
+	 *
23
+	 * @param string $beanPrefix
24
+	 */
25
+	public function setBeanPrefix(string $beanPrefix)
26
+	{
27
+		$this->beanPrefix = $beanPrefix;
28
+	}
29
+
30
+	/**
31
+	 * Sets the string suffix to any bean class name.
32
+	 *
33
+	 * @param string $beanSuffix
34
+	 */
35
+	public function setBeanSuffix(string $beanSuffix)
36
+	{
37
+		$this->beanSuffix = $beanSuffix;
38
+	}
39
+
40
+	/**
41
+	 * Sets the string prefix to any base bean class name.
42
+	 *
43
+	 * @param string $baseBeanPrefix
44
+	 */
45
+	public function setBaseBeanPrefix(string $baseBeanPrefix)
46
+	{
47
+		$this->baseBeanPrefix = $baseBeanPrefix;
48
+	}
49
+
50
+	/**
51
+	 * Sets the string suffix to any base bean class name.
52
+	 *
53
+	 * @param string $baseBeanSuffix
54
+	 */
55
+	public function setBaseBeanSuffix(string $baseBeanSuffix)
56
+	{
57
+		$this->baseBeanSuffix = $baseBeanSuffix;
58
+	}
59
+
60
+	/**
61
+	 * Sets the string prefix to any DAO class name.
62
+	 *
63
+	 * @param string $daoPrefix
64
+	 */
65
+	public function setDaoPrefix(string $daoPrefix)
66
+	{
67
+		$this->daoPrefix = $daoPrefix;
68
+	}
69
+
70
+	/**
71
+	 * Sets the string suffix to any DAO class name.
72
+	 *
73
+	 * @param string $daoSuffix
74
+	 */
75
+	public function setDaoSuffix(string $daoSuffix)
76
+	{
77
+		$this->daoSuffix = $daoSuffix;
78
+	}
79
+
80
+	/**
81
+	 * Sets the string prefix to any base DAO class name.
82
+	 *
83
+	 * @param string $baseDaoPrefix
84
+	 */
85
+	public function setBaseDaoPrefix(string $baseDaoPrefix)
86
+	{
87
+		$this->baseDaoPrefix = $baseDaoPrefix;
88
+	}
89
+
90
+	/**
91
+	 * Sets the string suffix to any base DAO class name.
92
+	 *
93
+	 * @param string $baseDaoSuffix
94
+	 */
95
+	public function setBaseDaoSuffix(string $baseDaoSuffix)
96
+	{
97
+		$this->baseDaoSuffix = $baseDaoSuffix;
98
+	}
99
+
100
+
101
+	/**
102
+	 * Returns the bean class name from the table name (excluding the namespace).
103
+	 *
104
+	 * @param string $tableName
105
+	 * @return string
106
+	 */
107
+	public function getBeanClassName(string $tableName): string
108
+	{
109
+		return $this->beanPrefix.$this->toSingularCamelCase($tableName).$this->beanSuffix;
110
+	}
111
+
112
+	/**
113
+	 * Returns the base bean class name from the table name (excluding the namespace).
114
+	 *
115
+	 * @param string $tableName
116
+	 * @return string
117
+	 */
118
+	public function getBaseBeanClassName(string $tableName): string
119
+	{
120
+		return $this->baseBeanPrefix.$this->toSingularCamelCase($tableName).$this->baseBeanSuffix;
121
+	}
122
+
123
+	/**
124
+	 * Returns the name of the DAO class from the table name (excluding the namespace).
125
+	 *
126
+	 * @param string $tableName
127
+	 * @return string
128
+	 */
129
+	public function getDaoClassName(string $tableName): string
130
+	{
131
+		return $this->daoPrefix.$this->toSingularCamelCase($tableName).$this->daoSuffix;
132
+	}
133
+
134
+	/**
135
+	 * Returns the name of the base DAO class from the table name (excluding the namespace).
136
+	 *
137
+	 * @param string $tableName
138
+	 * @return string
139
+	 */
140
+	public function getBaseDaoClassName(string $tableName): string
141
+	{
142
+		return $this->baseDaoPrefix.$this->toSingularCamelCase($tableName).$this->baseDaoSuffix;
143
+	}
144
+
145
+	/**
146
+	 * Tries to put string to the singular form (if it is plural) and camel case form.
147
+	 * We assume the table names are in english.
148
+	 *
149
+	 * @param $str string
150
+	 *
151
+	 * @return string
152
+	 */
153
+	private function toSingularCamelCase(string $str): string
154
+	{
155
+		// Let's first check if this is not in the exceptions directory.
156
+		if (isset($this->exceptions[$str])) {
157
+			return $this->exceptions[$str];
158
+		}
159
+
160
+		$tokens = preg_split("/[_ ]+/", $str);
161
+		$tokens = array_map([Inflector::class, 'singularize'], $tokens);
162
+
163
+		$str = '';
164
+		foreach ($tokens as $token) {
165
+			$str .= ucfirst(Inflector::singularize($token));
166
+		}
167
+
168
+		return $str;
169
+	}
170
+
171
+	/**
172
+	 * Returns the class name for the DAO factory.
173
+	 *
174
+	 * @return string
175
+	 */
176
+	public function getDaoFactoryClassName(): string
177
+	{
178
+		return 'DaoFactory';
179
+	}
180
+
181
+	/**
182
+	 * Sets exceptions in the naming of classes.
183
+	 * The key is the name of the table, the value the "base" name of beans and DAOs.
184
+	 *
185
+	 * This is very useful for dealing with plural to singular translations in non english table names.
186
+	 *
187
+	 * For instance if you are dealing with a table containing horses in French ("chevaux" that has a singular "cheval"):
188
+	 *
189
+	 * [
190
+	 *     "chevaux" => "Cheval"
191
+	 * ]
192
+	 *
193
+	 * @param array<string,string> $exceptions
194
+	 */
195
+	public function setExceptions(array $exceptions)
196
+	{
197
+		$this->exceptions = $exceptions;
198
+	}
199 199
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/QueryFactory/FindObjectsFromSqlQueryFactory.php 2 patches
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -15,168 +15,168 @@
 block discarded – undo
15 15
  */
16 16
 class FindObjectsFromSqlQueryFactory extends AbstractQueryFactory
17 17
 {
18
-    private $mainTable;
19
-    private $from;
20
-    private $filterString;
21
-    private $cache;
22
-    private $cachePrefix;
23
-
24
-    public function __construct(string $mainTable, string $from, $filterString, $orderBy, TDBMService $tdbmService, Schema $schema, OrderByAnalyzer $orderByAnalyzer, SchemaAnalyzer $schemaAnalyzer, Cache $cache, string $cachePrefix)
25
-    {
26
-        parent::__construct($tdbmService, $schema, $orderByAnalyzer, $orderBy);
27
-        $this->mainTable = $mainTable;
28
-        $this->from = $from;
29
-        $this->filterString = $filterString;
30
-        $this->schemaAnalyzer = $schemaAnalyzer;
31
-        $this->cache = $cache;
32
-        $this->cachePrefix = $cachePrefix;
33
-    }
34
-
35
-    protected function compute()
36
-    {
37
-        $connection = $this->tdbmService->getConnection();
38
-
39
-        $columnsList = null;
40
-
41
-        $allFetchedTables = $this->tdbmService->_getRelatedTablesByInheritance($this->mainTable);
42
-
43
-        list($columnDescList, $columnsList, $orderString) = $this->getColumnsList($this->mainTable, [], $this->orderBy);
44
-
45
-        $sql = 'SELECT DISTINCT '.implode(', ', $columnsList).' FROM '.$this->from;
46
-
47
-        // Let's compute the COUNT.
48
-        $pkColumnNames = $this->schema->getTable($this->mainTable)->getPrimaryKeyColumns();
49
-        $pkColumnNames = array_map(function ($pkColumn) {
50
-            return $this->tdbmService->getConnection()->quoteIdentifier($this->mainTable).'.'.$this->tdbmService->getConnection()->quoteIdentifier($pkColumn);
51
-        }, $pkColumnNames);
52
-
53
-        $countSql = 'SELECT COUNT(DISTINCT '.implode(', ', $pkColumnNames).') FROM '.$this->from;
54
-
55
-        // Add joins on inherited tables if necessary
56
-        if (count($allFetchedTables) > 1) {
57
-            $joinSql = '';
58
-            $parentFks = $this->getParentRelationshipForeignKeys($this->mainTable);
59
-            foreach ($parentFks as $fk) {
60
-                $joinSql .= sprintf(' JOIN %s ON (%s.%s = %s.%s)',
61
-                    $connection->quoteIdentifier($fk->getForeignTableName()),
62
-                    $connection->quoteIdentifier($fk->getLocalTableName()),
63
-                    $connection->quoteIdentifier($fk->getLocalColumns()[0]),
64
-                    $connection->quoteIdentifier($fk->getForeignTableName()),
65
-                    $connection->quoteIdentifier($fk->getForeignColumns()[0])
66
-                );
67
-            }
68
-
69
-            $childrenFks = $this->getChildrenRelationshipForeignKeys($this->mainTable);
70
-            foreach ($childrenFks as $fk) {
71
-                $joinSql .= sprintf(' LEFT JOIN %s ON (%s.%s = %s.%s)',
72
-                    $connection->quoteIdentifier($fk->getLocalTableName()),
73
-                    $connection->quoteIdentifier($fk->getForeignTableName()),
74
-                    $connection->quoteIdentifier($fk->getForeignColumns()[0]),
75
-                    $connection->quoteIdentifier($fk->getLocalTableName()),
76
-                    $connection->quoteIdentifier($fk->getLocalColumns()[0])
77
-                );
78
-            }
79
-
80
-            $sql .= $joinSql;
81
-        }
82
-
83
-        if (!empty($this->filterString)) {
84
-            $sql .= ' WHERE '.$this->filterString;
85
-            $countSql .= ' WHERE '.$this->filterString;
86
-        }
87
-
88
-        if (!empty($orderString)) {
89
-            $sql .= ' ORDER BY '.$orderString;
90
-        }
91
-
92
-        if (stripos($countSql, 'GROUP BY') !== false) {
93
-            throw new TDBMException('Unsupported use of GROUP BY in SQL request.');
94
-        }
95
-
96
-        $this->magicSql = $sql;
97
-        $this->magicSqlCount = $countSql;
98
-        $this->columnDescList = $columnDescList;
99
-    }
100
-
101
-    /**
102
-     * @param string $tableName
103
-     *
104
-     * @return ForeignKeyConstraint[]
105
-     */
106
-    private function getParentRelationshipForeignKeys($tableName)
107
-    {
108
-        return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function () use ($tableName) {
109
-            return $this->getParentRelationshipForeignKeysWithoutCache($tableName);
110
-        });
111
-    }
112
-
113
-    /**
114
-     * @param string $tableName
115
-     *
116
-     * @return ForeignKeyConstraint[]
117
-     */
118
-    private function getParentRelationshipForeignKeysWithoutCache($tableName)
119
-    {
120
-        $parentFks = [];
121
-        $currentTable = $tableName;
122
-        while ($currentFk = $this->schemaAnalyzer->getParentRelationship($currentTable)) {
123
-            $currentTable = $currentFk->getForeignTableName();
124
-            $parentFks[] = $currentFk;
125
-        }
126
-
127
-        return $parentFks;
128
-    }
129
-
130
-    /**
131
-     * @param string $tableName
132
-     *
133
-     * @return ForeignKeyConstraint[]
134
-     */
135
-    private function getChildrenRelationshipForeignKeys(string $tableName) : array
136
-    {
137
-        return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function () use ($tableName) {
138
-            return $this->getChildrenRelationshipForeignKeysWithoutCache($tableName);
139
-        });
140
-    }
141
-
142
-    /**
143
-     * @param string $tableName
144
-     *
145
-     * @return ForeignKeyConstraint[]
146
-     */
147
-    private function getChildrenRelationshipForeignKeysWithoutCache(string $tableName) : array
148
-    {
149
-        $children = $this->schemaAnalyzer->getChildrenRelationships($tableName);
150
-
151
-        if (!empty($children)) {
152
-            $fksTables = array_map(function (ForeignKeyConstraint $fk) {
153
-                return $this->getChildrenRelationshipForeignKeys($fk->getLocalTableName());
154
-            }, $children);
155
-
156
-            $fks = array_merge($children, call_user_func_array('array_merge', $fksTables));
157
-
158
-            return $fks;
159
-        } else {
160
-            return [];
161
-        }
162
-    }
163
-
164
-    /**
165
-     * Returns an item from cache or computes it using $closure and puts it in cache.
166
-     *
167
-     * @param string   $key
168
-     * @param callable $closure
169
-     *
170
-     * @return mixed
171
-     */
172
-    protected function fromCache(string $key, callable $closure)
173
-    {
174
-        $item = $this->cache->fetch($key);
175
-        if ($item === false) {
176
-            $item = $closure();
177
-            $this->cache->save($key, $item);
178
-        }
179
-
180
-        return $item;
181
-    }
18
+	private $mainTable;
19
+	private $from;
20
+	private $filterString;
21
+	private $cache;
22
+	private $cachePrefix;
23
+
24
+	public function __construct(string $mainTable, string $from, $filterString, $orderBy, TDBMService $tdbmService, Schema $schema, OrderByAnalyzer $orderByAnalyzer, SchemaAnalyzer $schemaAnalyzer, Cache $cache, string $cachePrefix)
25
+	{
26
+		parent::__construct($tdbmService, $schema, $orderByAnalyzer, $orderBy);
27
+		$this->mainTable = $mainTable;
28
+		$this->from = $from;
29
+		$this->filterString = $filterString;
30
+		$this->schemaAnalyzer = $schemaAnalyzer;
31
+		$this->cache = $cache;
32
+		$this->cachePrefix = $cachePrefix;
33
+	}
34
+
35
+	protected function compute()
36
+	{
37
+		$connection = $this->tdbmService->getConnection();
38
+
39
+		$columnsList = null;
40
+
41
+		$allFetchedTables = $this->tdbmService->_getRelatedTablesByInheritance($this->mainTable);
42
+
43
+		list($columnDescList, $columnsList, $orderString) = $this->getColumnsList($this->mainTable, [], $this->orderBy);
44
+
45
+		$sql = 'SELECT DISTINCT '.implode(', ', $columnsList).' FROM '.$this->from;
46
+
47
+		// Let's compute the COUNT.
48
+		$pkColumnNames = $this->schema->getTable($this->mainTable)->getPrimaryKeyColumns();
49
+		$pkColumnNames = array_map(function ($pkColumn) {
50
+			return $this->tdbmService->getConnection()->quoteIdentifier($this->mainTable).'.'.$this->tdbmService->getConnection()->quoteIdentifier($pkColumn);
51
+		}, $pkColumnNames);
52
+
53
+		$countSql = 'SELECT COUNT(DISTINCT '.implode(', ', $pkColumnNames).') FROM '.$this->from;
54
+
55
+		// Add joins on inherited tables if necessary
56
+		if (count($allFetchedTables) > 1) {
57
+			$joinSql = '';
58
+			$parentFks = $this->getParentRelationshipForeignKeys($this->mainTable);
59
+			foreach ($parentFks as $fk) {
60
+				$joinSql .= sprintf(' JOIN %s ON (%s.%s = %s.%s)',
61
+					$connection->quoteIdentifier($fk->getForeignTableName()),
62
+					$connection->quoteIdentifier($fk->getLocalTableName()),
63
+					$connection->quoteIdentifier($fk->getLocalColumns()[0]),
64
+					$connection->quoteIdentifier($fk->getForeignTableName()),
65
+					$connection->quoteIdentifier($fk->getForeignColumns()[0])
66
+				);
67
+			}
68
+
69
+			$childrenFks = $this->getChildrenRelationshipForeignKeys($this->mainTable);
70
+			foreach ($childrenFks as $fk) {
71
+				$joinSql .= sprintf(' LEFT JOIN %s ON (%s.%s = %s.%s)',
72
+					$connection->quoteIdentifier($fk->getLocalTableName()),
73
+					$connection->quoteIdentifier($fk->getForeignTableName()),
74
+					$connection->quoteIdentifier($fk->getForeignColumns()[0]),
75
+					$connection->quoteIdentifier($fk->getLocalTableName()),
76
+					$connection->quoteIdentifier($fk->getLocalColumns()[0])
77
+				);
78
+			}
79
+
80
+			$sql .= $joinSql;
81
+		}
82
+
83
+		if (!empty($this->filterString)) {
84
+			$sql .= ' WHERE '.$this->filterString;
85
+			$countSql .= ' WHERE '.$this->filterString;
86
+		}
87
+
88
+		if (!empty($orderString)) {
89
+			$sql .= ' ORDER BY '.$orderString;
90
+		}
91
+
92
+		if (stripos($countSql, 'GROUP BY') !== false) {
93
+			throw new TDBMException('Unsupported use of GROUP BY in SQL request.');
94
+		}
95
+
96
+		$this->magicSql = $sql;
97
+		$this->magicSqlCount = $countSql;
98
+		$this->columnDescList = $columnDescList;
99
+	}
100
+
101
+	/**
102
+	 * @param string $tableName
103
+	 *
104
+	 * @return ForeignKeyConstraint[]
105
+	 */
106
+	private function getParentRelationshipForeignKeys($tableName)
107
+	{
108
+		return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function () use ($tableName) {
109
+			return $this->getParentRelationshipForeignKeysWithoutCache($tableName);
110
+		});
111
+	}
112
+
113
+	/**
114
+	 * @param string $tableName
115
+	 *
116
+	 * @return ForeignKeyConstraint[]
117
+	 */
118
+	private function getParentRelationshipForeignKeysWithoutCache($tableName)
119
+	{
120
+		$parentFks = [];
121
+		$currentTable = $tableName;
122
+		while ($currentFk = $this->schemaAnalyzer->getParentRelationship($currentTable)) {
123
+			$currentTable = $currentFk->getForeignTableName();
124
+			$parentFks[] = $currentFk;
125
+		}
126
+
127
+		return $parentFks;
128
+	}
129
+
130
+	/**
131
+	 * @param string $tableName
132
+	 *
133
+	 * @return ForeignKeyConstraint[]
134
+	 */
135
+	private function getChildrenRelationshipForeignKeys(string $tableName) : array
136
+	{
137
+		return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function () use ($tableName) {
138
+			return $this->getChildrenRelationshipForeignKeysWithoutCache($tableName);
139
+		});
140
+	}
141
+
142
+	/**
143
+	 * @param string $tableName
144
+	 *
145
+	 * @return ForeignKeyConstraint[]
146
+	 */
147
+	private function getChildrenRelationshipForeignKeysWithoutCache(string $tableName) : array
148
+	{
149
+		$children = $this->schemaAnalyzer->getChildrenRelationships($tableName);
150
+
151
+		if (!empty($children)) {
152
+			$fksTables = array_map(function (ForeignKeyConstraint $fk) {
153
+				return $this->getChildrenRelationshipForeignKeys($fk->getLocalTableName());
154
+			}, $children);
155
+
156
+			$fks = array_merge($children, call_user_func_array('array_merge', $fksTables));
157
+
158
+			return $fks;
159
+		} else {
160
+			return [];
161
+		}
162
+	}
163
+
164
+	/**
165
+	 * Returns an item from cache or computes it using $closure and puts it in cache.
166
+	 *
167
+	 * @param string   $key
168
+	 * @param callable $closure
169
+	 *
170
+	 * @return mixed
171
+	 */
172
+	protected function fromCache(string $key, callable $closure)
173
+	{
174
+		$item = $this->cache->fetch($key);
175
+		if ($item === false) {
176
+			$item = $closure();
177
+			$this->cache->save($key, $item);
178
+		}
179
+
180
+		return $item;
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
         // Let's compute the COUNT.
48 48
         $pkColumnNames = $this->schema->getTable($this->mainTable)->getPrimaryKeyColumns();
49
-        $pkColumnNames = array_map(function ($pkColumn) {
49
+        $pkColumnNames = array_map(function($pkColumn) {
50 50
             return $this->tdbmService->getConnection()->quoteIdentifier($this->mainTable).'.'.$this->tdbmService->getConnection()->quoteIdentifier($pkColumn);
51 51
         }, $pkColumnNames);
52 52
 
53 53
         $countSql = 'SELECT COUNT(DISTINCT '.implode(', ', $pkColumnNames).') FROM '.$this->from;
54 54
 
55 55
         // Add joins on inherited tables if necessary
56
-        if (count($allFetchedTables) > 1) {
56
+        if (count($allFetchedTables)>1) {
57 57
             $joinSql = '';
58 58
             $parentFks = $this->getParentRelationshipForeignKeys($this->mainTable);
59 59
             foreach ($parentFks as $fk) {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     private function getParentRelationshipForeignKeys($tableName)
107 107
     {
108
-        return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function () use ($tableName) {
108
+        return $this->fromCache($this->cachePrefix.'_parentrelationshipfks_'.$tableName, function() use ($tableName) {
109 109
             return $this->getParentRelationshipForeignKeysWithoutCache($tableName);
110 110
         });
111 111
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function getChildrenRelationshipForeignKeys(string $tableName) : array
136 136
     {
137
-        return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function () use ($tableName) {
137
+        return $this->fromCache($this->cachePrefix.'_childrenrelationshipfks_'.$tableName, function() use ($tableName) {
138 138
             return $this->getChildrenRelationshipForeignKeysWithoutCache($tableName);
139 139
         });
140 140
     }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $children = $this->schemaAnalyzer->getChildrenRelationships($tableName);
150 150
 
151 151
         if (!empty($children)) {
152
-            $fksTables = array_map(function (ForeignKeyConstraint $fk) {
152
+            $fksTables = array_map(function(ForeignKeyConstraint $fk) {
153 153
                 return $this->getChildrenRelationshipForeignKeys($fk->getLocalTableName());
154 154
             }, $children);
155 155
 
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/InnerResultIterator.php 1 patch
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -29,271 +29,271 @@
 block discarded – undo
29 29
  */
30 30
 class InnerResultIterator implements \Iterator, \Countable, \ArrayAccess
31 31
 {
32
-    /**
33
-     * @var Statement
34
-     */
35
-    protected $statement;
36
-
37
-    protected $fetchStarted = false;
38
-    private $objectStorage;
39
-    private $className;
40
-
41
-    private $tdbmService;
42
-    private $magicSql;
43
-    private $parameters;
44
-    private $limit;
45
-    private $offset;
46
-    private $columnDescriptors;
47
-    private $magicQuery;
48
-
49
-    /**
50
-     * The key of the current retrieved object.
51
-     *
52
-     * @var int
53
-     */
54
-    protected $key = -1;
55
-
56
-    protected $current = null;
57
-
58
-    private $databasePlatform;
59
-
60
-    /**
61
-     * @var LoggerInterface
62
-     */
63
-    private $logger;
64
-
65
-    public function __construct($magicSql, array $parameters, $limit, $offset, array $columnDescriptors, $objectStorage, $className, TDBMService $tdbmService, MagicQuery $magicQuery, LoggerInterface $logger)
66
-    {
67
-        $this->magicSql = $magicSql;
68
-        $this->objectStorage = $objectStorage;
69
-        $this->className = $className;
70
-        $this->tdbmService = $tdbmService;
71
-        $this->parameters = $parameters;
72
-        $this->limit = $limit;
73
-        $this->offset = $offset;
74
-        $this->columnDescriptors = $columnDescriptors;
75
-        $this->magicQuery = $magicQuery;
76
-        $this->databasePlatform = $this->tdbmService->getConnection()->getDatabasePlatform();
77
-        $this->logger = $logger;
78
-    }
79
-
80
-    protected function executeQuery()
81
-    {
82
-        $sql = $this->magicQuery->build($this->magicSql, $this->parameters);
83
-        $sql = $this->tdbmService->getConnection()->getDatabasePlatform()->modifyLimitQuery($sql, $this->limit, $this->offset);
84
-
85
-        $this->logger->debug('Running SQL request: '.$sql);
86
-
87
-        $this->statement = $this->tdbmService->getConnection()->executeQuery($sql, $this->parameters);
88
-
89
-        $this->fetchStarted = true;
90
-    }
91
-
92
-    /**
93
-     * Counts found records (this is the number of records fetched, taking into account the LIMIT and OFFSET settings).
94
-     *
95
-     * @return int
96
-     */
97
-    public function count()
98
-    {
99
-        if (!$this->fetchStarted) {
100
-            $this->executeQuery();
101
-        }
102
-
103
-        return $this->statement->rowCount();
104
-    }
105
-
106
-    /**
107
-     * Fetches record at current cursor.
108
-     *
109
-     * @return AbstractTDBMObject|null
110
-     */
111
-    public function current()
112
-    {
113
-        return $this->current;
114
-    }
115
-
116
-    /**
117
-     * Returns the current result's key.
118
-     *
119
-     * @return int
120
-     */
121
-    public function key()
122
-    {
123
-        return $this->key;
124
-    }
125
-
126
-    /**
127
-     * Advances the cursor to the next result.
128
-     * Casts the database result into one (or several) beans.
129
-     */
130
-    public function next()
131
-    {
132
-        $row = $this->statement->fetch(\PDO::FETCH_LAZY);
133
-        if ($row) {
134
-
135
-            // array<tablegroup, array<table, array<column, value>>>
136
-            $beansData = [];
137
-            foreach ($row as $key => $value) {
138
-                if (!isset($this->columnDescriptors[$key])) {
139
-                    continue;
140
-                }
141
-
142
-                $columnDescriptor = $this->columnDescriptors[$key];
143
-
144
-                if ($columnDescriptor['tableGroup'] === null) {
145
-                    // A column can have no tableGroup (if it comes from an ORDER BY expression)
146
-                    continue;
147
-                }
148
-
149
-                // Let's cast the value according to its type
150
-                $value = $columnDescriptor['type']->convertToPHPValue($value, $this->databasePlatform);
151
-
152
-                $beansData[$columnDescriptor['tableGroup']][$columnDescriptor['table']][$columnDescriptor['column']] = $value;
153
-            }
154
-
155
-            $reflectionClassCache = [];
156
-            $firstBean = true;
157
-            foreach ($beansData as $beanData) {
158
-
159
-                // Let's find the bean class name associated to the bean.
160
-
161
-                list($actualClassName, $mainBeanTableName, $tablesUsed) = $this->tdbmService->_getClassNameFromBeanData($beanData);
162
-
163
-                if ($this->className !== null) {
164
-                    $actualClassName = $this->className;
165
-                }
166
-
167
-                // Let's filter out the beanData that is not used (because it belongs to a part of the hierarchy that is not fetched:
168
-                foreach ($beanData as $tableName => $descriptors) {
169
-                    if (!in_array($tableName, $tablesUsed)) {
170
-                        unset($beanData[$tableName]);
171
-                    }
172
-                }
173
-
174
-                // Must we create the bean? Let's see in the cache if we have a mapping DbRow?
175
-                // Let's get the first object mapping a row:
176
-                // We do this loop only for the first table
177
-
178
-                $primaryKeys = $this->tdbmService->_getPrimaryKeysFromObjectData($mainBeanTableName, $beanData[$mainBeanTableName]);
179
-                $hash = $this->tdbmService->getObjectHash($primaryKeys);
180
-
181
-                if ($this->objectStorage->has($mainBeanTableName, $hash)) {
182
-                    $dbRow = $this->objectStorage->get($mainBeanTableName, $hash);
183
-                    $bean = $dbRow->getTDBMObject();
184
-                } else {
185
-                    // Let's construct the bean
186
-                    if (!isset($reflectionClassCache[$actualClassName])) {
187
-                        $reflectionClassCache[$actualClassName] = new \ReflectionClass($actualClassName);
188
-                    }
189
-                    // Let's bypass the constructor when creating the bean!
190
-                    $bean = $reflectionClassCache[$actualClassName]->newInstanceWithoutConstructor();
191
-                    $bean->_constructFromData($beanData, $this->tdbmService);
192
-                }
193
-
194
-                // The first bean is the one containing the main table.
195
-                if ($firstBean) {
196
-                    $firstBean = false;
197
-                    $this->current = $bean;
198
-                }
199
-            }
200
-
201
-            ++$this->key;
202
-        } else {
203
-            $this->current = null;
204
-        }
205
-    }
206
-
207
-    /**
208
-     * Moves the cursor to the beginning of the result set.
209
-     */
210
-    public function rewind()
211
-    {
212
-        $this->executeQuery();
213
-        $this->key = -1;
214
-        $this->next();
215
-    }
216
-    /**
217
-     * Checks if the cursor is reading a valid result.
218
-     *
219
-     * @return bool
220
-     */
221
-    public function valid()
222
-    {
223
-        return $this->current !== null;
224
-    }
225
-
226
-    /**
227
-     * Whether a offset exists.
228
-     *
229
-     * @link http://php.net/manual/en/arrayaccess.offsetexists.php
230
-     *
231
-     * @param mixed $offset <p>
232
-     *                      An offset to check for.
233
-     *                      </p>
234
-     *
235
-     * @return bool true on success or false on failure.
236
-     *              </p>
237
-     *              <p>
238
-     *              The return value will be casted to boolean if non-boolean was returned
239
-     *
240
-     * @since 5.0.0
241
-     */
242
-    public function offsetExists($offset)
243
-    {
244
-        throw new TDBMInvalidOperationException('You cannot access this result set via index because it was fetched in CURSOR mode. Use ARRAY_MODE instead.');
245
-    }
246
-
247
-    /**
248
-     * Offset to retrieve.
249
-     *
250
-     * @link http://php.net/manual/en/arrayaccess.offsetget.php
251
-     *
252
-     * @param mixed $offset <p>
253
-     *                      The offset to retrieve.
254
-     *                      </p>
255
-     *
256
-     * @return mixed Can return all value types
257
-     *
258
-     * @since 5.0.0
259
-     */
260
-    public function offsetGet($offset)
261
-    {
262
-        throw new TDBMInvalidOperationException('You cannot access this result set via index because it was fetched in CURSOR mode. Use ARRAY_MODE instead.');
263
-    }
264
-
265
-    /**
266
-     * Offset to set.
267
-     *
268
-     * @link http://php.net/manual/en/arrayaccess.offsetset.php
269
-     *
270
-     * @param mixed $offset <p>
271
-     *                      The offset to assign the value to.
272
-     *                      </p>
273
-     * @param mixed $value  <p>
274
-     *                      The value to set.
275
-     *                      </p>
276
-     *
277
-     * @since 5.0.0
278
-     */
279
-    public function offsetSet($offset, $value)
280
-    {
281
-        throw new TDBMInvalidOperationException('You can set values in a TDBM result set.');
282
-    }
283
-
284
-    /**
285
-     * Offset to unset.
286
-     *
287
-     * @link http://php.net/manual/en/arrayaccess.offsetunset.php
288
-     *
289
-     * @param mixed $offset <p>
290
-     *                      The offset to unset.
291
-     *                      </p>
292
-     *
293
-     * @since 5.0.0
294
-     */
295
-    public function offsetUnset($offset)
296
-    {
297
-        throw new TDBMInvalidOperationException('You can unset values in a TDBM result set.');
298
-    }
32
+	/**
33
+	 * @var Statement
34
+	 */
35
+	protected $statement;
36
+
37
+	protected $fetchStarted = false;
38
+	private $objectStorage;
39
+	private $className;
40
+
41
+	private $tdbmService;
42
+	private $magicSql;
43
+	private $parameters;
44
+	private $limit;
45
+	private $offset;
46
+	private $columnDescriptors;
47
+	private $magicQuery;
48
+
49
+	/**
50
+	 * The key of the current retrieved object.
51
+	 *
52
+	 * @var int
53
+	 */
54
+	protected $key = -1;
55
+
56
+	protected $current = null;
57
+
58
+	private $databasePlatform;
59
+
60
+	/**
61
+	 * @var LoggerInterface
62
+	 */
63
+	private $logger;
64
+
65
+	public function __construct($magicSql, array $parameters, $limit, $offset, array $columnDescriptors, $objectStorage, $className, TDBMService $tdbmService, MagicQuery $magicQuery, LoggerInterface $logger)
66
+	{
67
+		$this->magicSql = $magicSql;
68
+		$this->objectStorage = $objectStorage;
69
+		$this->className = $className;
70
+		$this->tdbmService = $tdbmService;
71
+		$this->parameters = $parameters;
72
+		$this->limit = $limit;
73
+		$this->offset = $offset;
74
+		$this->columnDescriptors = $columnDescriptors;
75
+		$this->magicQuery = $magicQuery;
76
+		$this->databasePlatform = $this->tdbmService->getConnection()->getDatabasePlatform();
77
+		$this->logger = $logger;
78
+	}
79
+
80
+	protected function executeQuery()
81
+	{
82
+		$sql = $this->magicQuery->build($this->magicSql, $this->parameters);
83
+		$sql = $this->tdbmService->getConnection()->getDatabasePlatform()->modifyLimitQuery($sql, $this->limit, $this->offset);
84
+
85
+		$this->logger->debug('Running SQL request: '.$sql);
86
+
87
+		$this->statement = $this->tdbmService->getConnection()->executeQuery($sql, $this->parameters);
88
+
89
+		$this->fetchStarted = true;
90
+	}
91
+
92
+	/**
93
+	 * Counts found records (this is the number of records fetched, taking into account the LIMIT and OFFSET settings).
94
+	 *
95
+	 * @return int
96
+	 */
97
+	public function count()
98
+	{
99
+		if (!$this->fetchStarted) {
100
+			$this->executeQuery();
101
+		}
102
+
103
+		return $this->statement->rowCount();
104
+	}
105
+
106
+	/**
107
+	 * Fetches record at current cursor.
108
+	 *
109
+	 * @return AbstractTDBMObject|null
110
+	 */
111
+	public function current()
112
+	{
113
+		return $this->current;
114
+	}
115
+
116
+	/**
117
+	 * Returns the current result's key.
118
+	 *
119
+	 * @return int
120
+	 */
121
+	public function key()
122
+	{
123
+		return $this->key;
124
+	}
125
+
126
+	/**
127
+	 * Advances the cursor to the next result.
128
+	 * Casts the database result into one (or several) beans.
129
+	 */
130
+	public function next()
131
+	{
132
+		$row = $this->statement->fetch(\PDO::FETCH_LAZY);
133
+		if ($row) {
134
+
135
+			// array<tablegroup, array<table, array<column, value>>>
136
+			$beansData = [];
137
+			foreach ($row as $key => $value) {
138
+				if (!isset($this->columnDescriptors[$key])) {
139
+					continue;
140
+				}
141
+
142
+				$columnDescriptor = $this->columnDescriptors[$key];
143
+
144
+				if ($columnDescriptor['tableGroup'] === null) {
145
+					// A column can have no tableGroup (if it comes from an ORDER BY expression)
146
+					continue;
147
+				}
148
+
149
+				// Let's cast the value according to its type
150
+				$value = $columnDescriptor['type']->convertToPHPValue($value, $this->databasePlatform);
151
+
152
+				$beansData[$columnDescriptor['tableGroup']][$columnDescriptor['table']][$columnDescriptor['column']] = $value;
153
+			}
154
+
155
+			$reflectionClassCache = [];
156
+			$firstBean = true;
157
+			foreach ($beansData as $beanData) {
158
+
159
+				// Let's find the bean class name associated to the bean.
160
+
161
+				list($actualClassName, $mainBeanTableName, $tablesUsed) = $this->tdbmService->_getClassNameFromBeanData($beanData);
162
+
163
+				if ($this->className !== null) {
164
+					$actualClassName = $this->className;
165
+				}
166
+
167
+				// Let's filter out the beanData that is not used (because it belongs to a part of the hierarchy that is not fetched:
168
+				foreach ($beanData as $tableName => $descriptors) {
169
+					if (!in_array($tableName, $tablesUsed)) {
170
+						unset($beanData[$tableName]);
171
+					}
172
+				}
173
+
174
+				// Must we create the bean? Let's see in the cache if we have a mapping DbRow?
175
+				// Let's get the first object mapping a row:
176
+				// We do this loop only for the first table
177
+
178
+				$primaryKeys = $this->tdbmService->_getPrimaryKeysFromObjectData($mainBeanTableName, $beanData[$mainBeanTableName]);
179
+				$hash = $this->tdbmService->getObjectHash($primaryKeys);
180
+
181
+				if ($this->objectStorage->has($mainBeanTableName, $hash)) {
182
+					$dbRow = $this->objectStorage->get($mainBeanTableName, $hash);
183
+					$bean = $dbRow->getTDBMObject();
184
+				} else {
185
+					// Let's construct the bean
186
+					if (!isset($reflectionClassCache[$actualClassName])) {
187
+						$reflectionClassCache[$actualClassName] = new \ReflectionClass($actualClassName);
188
+					}
189
+					// Let's bypass the constructor when creating the bean!
190
+					$bean = $reflectionClassCache[$actualClassName]->newInstanceWithoutConstructor();
191
+					$bean->_constructFromData($beanData, $this->tdbmService);
192
+				}
193
+
194
+				// The first bean is the one containing the main table.
195
+				if ($firstBean) {
196
+					$firstBean = false;
197
+					$this->current = $bean;
198
+				}
199
+			}
200
+
201
+			++$this->key;
202
+		} else {
203
+			$this->current = null;
204
+		}
205
+	}
206
+
207
+	/**
208
+	 * Moves the cursor to the beginning of the result set.
209
+	 */
210
+	public function rewind()
211
+	{
212
+		$this->executeQuery();
213
+		$this->key = -1;
214
+		$this->next();
215
+	}
216
+	/**
217
+	 * Checks if the cursor is reading a valid result.
218
+	 *
219
+	 * @return bool
220
+	 */
221
+	public function valid()
222
+	{
223
+		return $this->current !== null;
224
+	}
225
+
226
+	/**
227
+	 * Whether a offset exists.
228
+	 *
229
+	 * @link http://php.net/manual/en/arrayaccess.offsetexists.php
230
+	 *
231
+	 * @param mixed $offset <p>
232
+	 *                      An offset to check for.
233
+	 *                      </p>
234
+	 *
235
+	 * @return bool true on success or false on failure.
236
+	 *              </p>
237
+	 *              <p>
238
+	 *              The return value will be casted to boolean if non-boolean was returned
239
+	 *
240
+	 * @since 5.0.0
241
+	 */
242
+	public function offsetExists($offset)
243
+	{
244
+		throw new TDBMInvalidOperationException('You cannot access this result set via index because it was fetched in CURSOR mode. Use ARRAY_MODE instead.');
245
+	}
246
+
247
+	/**
248
+	 * Offset to retrieve.
249
+	 *
250
+	 * @link http://php.net/manual/en/arrayaccess.offsetget.php
251
+	 *
252
+	 * @param mixed $offset <p>
253
+	 *                      The offset to retrieve.
254
+	 *                      </p>
255
+	 *
256
+	 * @return mixed Can return all value types
257
+	 *
258
+	 * @since 5.0.0
259
+	 */
260
+	public function offsetGet($offset)
261
+	{
262
+		throw new TDBMInvalidOperationException('You cannot access this result set via index because it was fetched in CURSOR mode. Use ARRAY_MODE instead.');
263
+	}
264
+
265
+	/**
266
+	 * Offset to set.
267
+	 *
268
+	 * @link http://php.net/manual/en/arrayaccess.offsetset.php
269
+	 *
270
+	 * @param mixed $offset <p>
271
+	 *                      The offset to assign the value to.
272
+	 *                      </p>
273
+	 * @param mixed $value  <p>
274
+	 *                      The value to set.
275
+	 *                      </p>
276
+	 *
277
+	 * @since 5.0.0
278
+	 */
279
+	public function offsetSet($offset, $value)
280
+	{
281
+		throw new TDBMInvalidOperationException('You can set values in a TDBM result set.');
282
+	}
283
+
284
+	/**
285
+	 * Offset to unset.
286
+	 *
287
+	 * @link http://php.net/manual/en/arrayaccess.offsetunset.php
288
+	 *
289
+	 * @param mixed $offset <p>
290
+	 *                      The offset to unset.
291
+	 *                      </p>
292
+	 *
293
+	 * @since 5.0.0
294
+	 */
295
+	public function offsetUnset($offset)
296
+	{
297
+		throw new TDBMInvalidOperationException('You can unset values in a TDBM result set.');
298
+	}
299 299
 }
Please login to merge, or discard this patch.